summaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-05-25 09:26:23 +1000
committerRyan Dwyer <[email protected]>2018-06-01 23:14:58 +1000
commitaaba7642b3e4e9a63aea49412b10221f399b17af (patch)
tree7e7c2f6fcd80a6a48e07e07e03c5f2dc0d248240 /sway/tree/container.c
parent34f35f0badc767d9b0cbaf2fd429af1d30592d08 (diff)
Replace is_floating boolean with function
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 17d29d92..c16f1748 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -924,7 +924,7 @@ static void configure_floating_view(struct sway_view *view) {
}
void container_set_floating(struct sway_container *container, bool enable) {
- if (container->is_floating == enable) {
+ if (container_is_floating(container) == enable) {
return;
}
@@ -935,7 +935,6 @@ void container_set_floating(struct sway_container *container, bool enable) {
if (enable) {
container_remove_child(container);
container_add_child(workspace->sway_workspace->floating, container);
- container->is_floating = true;
if (container->type == C_VIEW) {
configure_floating_view(container->sway_view);
}
@@ -950,7 +949,6 @@ void container_set_floating(struct sway_container *container, bool enable) {
if (container->type == C_VIEW) {
view_set_maximized(container->sway_view, true);
}
- container->is_floating = false;
container->is_sticky = false;
container_reap_empty_recursive(workspace->sway_workspace->floating);
}
@@ -962,7 +960,8 @@ void container_set_geometry_from_view(struct sway_container *container) {
if (!sway_assert(container->type == C_VIEW, "Expected a view")) {
return;
}
- if (!sway_assert(container->is_floating, "Expected a floating view")) {
+ if (!sway_assert(container_is_floating(container),
+ "Expected a floating view")) {
return;
}
struct sway_view *view = container->sway_view;
@@ -977,9 +976,18 @@ void container_set_geometry_from_view(struct sway_container *container) {
}
bool container_self_or_parent_floating(struct sway_container *container) {
- while (container->parent->type != C_WORKSPACE
- && container->parent->parent->type != C_WORKSPACE) {
- container = container->parent;
+ struct sway_container *workspace = container_parent(container, C_WORKSPACE);
+ if (!workspace) {
+ return false;
+ }
+ return container_has_anscestor(container,
+ workspace->sway_workspace->floating);
+}
+
+bool container_is_floating(struct sway_container *container) {
+ struct sway_container *workspace = container_parent(container, C_WORKSPACE);
+ if (!workspace) {
+ return false;
}
- return container->is_floating;
+ return container->parent == workspace->sway_workspace->floating;
}