diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-06-04 14:28:43 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-06-07 10:46:14 +0200 |
commit | 53dc83fb68d2da079f2595994af41cc6b9acbeea (patch) | |
tree | 7532ea7ae132fcb592779b69606a54c6205dbbd9 /sway/tree | |
parent | common/util: fix `get_current_time_msec` returning microseconds (diff) | |
download | sway-53dc83fb68d2da079f2595994af41cc6b9acbeea.tar.gz sway-53dc83fb68d2da079f2595994af41cc6b9acbeea.tar.zst sway-53dc83fb68d2da079f2595994af41cc6b9acbeea.zip |
tree/container: introduce `container_toplevel_ancestor` helper
This allows us to not have to explicitly write the same while loop
everywhere.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 3e99aa75..2fbd0d38 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1108,11 +1108,17 @@ void container_set_fullscreen(struct sway_container *con, | |||
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | bool container_is_floating_or_child(struct sway_container *container) { | 1111 | struct sway_container *container_toplevel_ancestor( |
1112 | struct sway_container *container) { | ||
1112 | while (container->parent) { | 1113 | while (container->parent) { |
1113 | container = container->parent; | 1114 | container = container->parent; |
1114 | } | 1115 | } |
1115 | return container_is_floating(container); | 1116 | |
1117 | return container; | ||
1118 | } | ||
1119 | |||
1120 | bool container_is_floating_or_child(struct sway_container *container) { | ||
1121 | return container_is_floating(container_toplevel_ancestor(container)); | ||
1116 | } | 1122 | } |
1117 | 1123 | ||
1118 | bool container_is_fullscreen_or_child(struct sway_container *container) { | 1124 | bool container_is_fullscreen_or_child(struct sway_container *container) { |
@@ -1537,10 +1543,7 @@ void container_update_marks_textures(struct sway_container *con) { | |||
1537 | 1543 | ||
1538 | void container_raise_floating(struct sway_container *con) { | 1544 | void container_raise_floating(struct sway_container *con) { |
1539 | // Bring container to front by putting it at the end of the floating list. | 1545 | // Bring container to front by putting it at the end of the floating list. |
1540 | struct sway_container *floater = con; | 1546 | struct sway_container *floater = container_toplevel_ancestor(con); |
1541 | while (floater->parent) { | ||
1542 | floater = floater->parent; | ||
1543 | } | ||
1544 | if (container_is_floating(floater) && floater->workspace) { | 1547 | if (container_is_floating(floater) && floater->workspace) { |
1545 | list_move_to_end(floater->workspace->floating, floater); | 1548 | list_move_to_end(floater->workspace->floating, floater); |
1546 | node_set_dirty(&floater->workspace->node); | 1549 | node_set_dirty(&floater->workspace->node); |
@@ -1552,8 +1555,6 @@ bool container_is_scratchpad_hidden(struct sway_container *con) { | |||
1552 | } | 1555 | } |
1553 | 1556 | ||
1554 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { | 1557 | bool container_is_scratchpad_hidden_or_child(struct sway_container *con) { |
1555 | while (con->parent) { | 1558 | con = container_toplevel_ancestor(con); |
1556 | con = con->parent; | ||
1557 | } | ||
1558 | return con->scratchpad && !con->workspace; | 1559 | return con->scratchpad && !con->workspace; |
1559 | } | 1560 | } |