diff options
-rw-r--r-- | include/sway/tree/container.h | 6 | ||||
-rw-r--r-- | sway/input/seat.c | 6 | ||||
-rw-r--r-- | sway/tree/container.c | 13 |
3 files changed, 3 insertions, 22 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 4d0e6003..799c017d 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -256,12 +256,6 @@ void container_for_each_descendant_dfs(struct sway_container *container, | |||
256 | bool container_has_ancestor(struct sway_container *container, | 256 | bool container_has_ancestor(struct sway_container *container, |
257 | struct sway_container *ancestor); | 257 | struct sway_container *ancestor); |
258 | 258 | ||
259 | /** | ||
260 | * Returns true if the given container is a child descendant of this container. | ||
261 | */ | ||
262 | bool container_has_child(struct sway_container *con, | ||
263 | struct sway_container *child); | ||
264 | |||
265 | int container_count_descendants_of_type(struct sway_container *con, | 259 | int container_count_descendants_of_type(struct sway_container *con, |
266 | enum sway_container_type type); | 260 | enum sway_container_type type); |
267 | 261 | ||
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; |