diff options
author | 2018-08-11 15:36:19 +1000 | |
---|---|---|
committer | 2018-08-11 15:36:19 +1000 | |
commit | 31844bf42bc4b6549862ea4c4f077c1e19d9e7a1 (patch) | |
tree | f24bbab4a5a54936ddca9b823e4103ea630e993b /sway | |
parent | Merge pull request #2447 from ianyfan/swaynag-leak (diff) | |
download | sway-31844bf42bc4b6549862ea4c4f077c1e19d9e7a1.tar.gz sway-31844bf42bc4b6549862ea4c4f077c1e19d9e7a1.tar.zst sway-31844bf42bc4b6549862ea4c4f077c1e19d9e7a1.zip |
Remove container_has_child
In all cases you can use container_has_ancestor with the arguments
swapped, which is faster than container_has_child.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/seat.c | 6 | ||||
-rw-r--r-- | sway/tree/container.c | 13 |
2 files changed, 3 insertions, 16 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 6dd7cf7d..3cd079f4 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -145,14 +145,14 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, | |||
145 | continue; | 145 | continue; |
146 | } | 146 | } |
147 | 147 | ||
148 | if (container_has_child(container, current->container)) { | 148 | if (container_has_ancestor(current->container, container)) { |
149 | if (only_tiling && | 149 | if (only_tiling && |
150 | container_is_floating_or_child(current->container)) { | 150 | container_is_floating_or_child(current->container)) { |
151 | continue; | 151 | continue; |
152 | } | 152 | } |
153 | return current->container; | 153 | return current->container; |
154 | } | 154 | } |
155 | if (floating && container_has_child(floating, current->container)) { | 155 | if (floating && container_has_ancestor(current->container, floating)) { |
156 | return current->container; | 156 | return current->container; |
157 | } | 157 | } |
158 | } | 158 | } |
@@ -190,7 +190,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
190 | 190 | ||
191 | bool set_focus = | 191 | bool set_focus = |
192 | focus != NULL && | 192 | focus != NULL && |
193 | (focus == con || container_has_child(con, focus)) && | 193 | (focus == con || container_has_ancestor(focus, con)) && |
194 | con->type != C_WORKSPACE; | 194 | con->type != C_WORKSPACE; |
195 | 195 | ||
196 | seat_container_destroy(seat_con); | 196 | seat_container_destroy(seat_con); |
diff --git a/sway/tree/container.c b/sway/tree/container.c index aecb2ac6..cec51af4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -817,19 +817,6 @@ bool container_has_ancestor(struct sway_container *descendant, | |||
817 | return false; | 817 | return false; |
818 | } | 818 | } |
819 | 819 | ||
820 | static bool find_child_func(struct sway_container *con, void *data) { | ||
821 | struct sway_container *child = data; | ||
822 | return con == child; | ||
823 | } | ||
824 | |||
825 | bool container_has_child(struct sway_container *con, | ||
826 | struct sway_container *child) { | ||
827 | if (con == NULL || con->type == C_VIEW) { | ||
828 | return false; | ||
829 | } | ||
830 | return container_find(con, find_child_func, child); | ||
831 | } | ||
832 | |||
833 | int container_count_descendants_of_type(struct sway_container *con, | 820 | int container_count_descendants_of_type(struct sway_container *con, |
834 | enum sway_container_type type) { | 821 | enum sway_container_type type) { |
835 | int children = 0; | 822 | int children = 0; |