aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-11-03 00:16:15 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-11-11 20:43:58 -0500
commit07042486c3c4b8e7083405ba9b34b1b87f8d396d (patch)
tree5ec7b68db2acbc1c68538a08b0b039477e8f8858 /sway/tree
parentAdd missing includes for wlr_input_device.h (diff)
downloadsway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.tar.gz
sway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.tar.zst
sway-07042486c3c4b8e7083405ba9b34b1b87f8d396d.zip
tree/container: introduce `container_is_sticky[_or_child]` functions
To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.)
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c8
-rw-r--r--sway/tree/view.c10
-rw-r--r--sway/tree/workspace.c4
3 files changed, 13 insertions, 9 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 8557210f..10d621b4 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1609,3 +1609,11 @@ bool container_is_scratchpad_hidden_or_child(struct sway_container *con) {
1609 con = container_toplevel_ancestor(con); 1609 con = container_toplevel_ancestor(con);
1610 return con->scratchpad && !con->workspace; 1610 return con->scratchpad && !con->workspace;
1611} 1611}
1612
1613bool container_is_sticky(struct sway_container *con) {
1614 return con->is_sticky && container_is_floating(con);
1615}
1616
1617bool container_is_sticky_or_child(struct sway_container *con) {
1618 return container_is_sticky(container_toplevel_ancestor(con));
1619}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index d699b01e..354f2d34 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -1244,13 +1244,9 @@ bool view_is_visible(struct sway_view *view) {
1244 return false; 1244 return false;
1245 } 1245 }
1246 } 1246 }
1247 // Determine if view is nested inside a floating container which is sticky 1247
1248 struct sway_container *floater = view->container; 1248 if (!container_is_sticky_or_child(view->container) && workspace &&
1249 while (floater->parent) { 1249 !workspace_is_visible(workspace)) {
1250 floater = floater->parent;
1251 }
1252 bool is_sticky = container_is_floating(floater) && floater->is_sticky;
1253 if (!is_sticky && workspace && !workspace_is_visible(workspace)) {
1254 return false; 1250 return false;
1255 } 1251 }
1256 // Check view isn't in a tabbed or stacked container on an inactive tab 1252 // Check view isn't in a tabbed or stacked container on an inactive tab
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 476c2568..ffcbe933 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -498,7 +498,7 @@ bool workspace_is_empty(struct sway_workspace *ws) {
498 // Sticky views are not considered to be part of this workspace 498 // Sticky views are not considered to be part of this workspace
499 for (int i = 0; i < ws->floating->length; ++i) { 499 for (int i = 0; i < ws->floating->length; ++i) {
500 struct sway_container *floater = ws->floating->items[i]; 500 struct sway_container *floater = ws->floating->items[i];
501 if (!floater->is_sticky) { 501 if (!container_is_sticky(floater)) {
502 return false; 502 return false;
503 } 503 }
504 } 504 }
@@ -819,7 +819,7 @@ size_t workspace_num_tiling_views(struct sway_workspace *ws) {
819} 819}
820 820
821static void count_sticky_containers(struct sway_container *con, void *data) { 821static void count_sticky_containers(struct sway_container *con, void *data) {
822 if (container_is_floating(con) && con->is_sticky) { 822 if (container_is_sticky(con)) {
823 size_t *count = data; 823 size_t *count = data;
824 *count += 1; 824 *count += 1;
825 } 825 }