aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h6
-rw-r--r--sway/input/seat.c6
-rw-r--r--sway/tree/container.c13
3 files changed, 3 insertions, 22 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 4170f6ba..2a22f196 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -250,12 +250,6 @@ void container_for_each_descendant(struct sway_container *container,
250bool container_has_ancestor(struct sway_container *container, 250bool container_has_ancestor(struct sway_container *container,
251 struct sway_container *ancestor); 251 struct sway_container *ancestor);
252 252
253/**
254 * Returns true if the given container is a child descendant of this container.
255 */
256bool container_has_child(struct sway_container *con,
257 struct sway_container *child);
258
259int container_count_descendants_of_type(struct sway_container *con, 253int container_count_descendants_of_type(struct sway_container *con,
260 enum sway_container_type type); 254 enum sway_container_type type);
261 255
diff --git a/sway/input/seat.c b/sway/input/seat.c
index f7d15c50..eb6d2dac 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 06b3b005..435d71e2 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -778,19 +778,6 @@ bool container_has_ancestor(struct sway_container *descendant,
778 return false; 778 return false;
779} 779}
780 780
781static bool find_child_func(struct sway_container *con, void *data) {
782 struct sway_container *child = data;
783 return con == child;
784}
785
786bool container_has_child(struct sway_container *con,
787 struct sway_container *child) {
788 if (con == NULL || con->type == C_VIEW) {
789 return false;
790 }
791 return container_find(con, find_child_func, child);
792}
793
794int container_count_descendants_of_type(struct sway_container *con, 781int container_count_descendants_of_type(struct sway_container *con,
795 enum sway_container_type type) { 782 enum sway_container_type type) {
796 int children = 0; 783 int children = 0;