From 7706d83160267be61accb1b6f7bdc2f43299cae7 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 31 Mar 2018 00:44:17 -0400 Subject: basic split containers --- sway/input/seat.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'sway/input/seat.c') diff --git a/sway/input/seat.c b/sway/input/seat.c index 9aa34aca..e0fd314a 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 700 +#include #include #include #include @@ -378,6 +379,18 @@ void sway_seat_set_focus(struct sway_seat *seat, } struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { + return sway_seat_get_focus_by_type(seat, container, C_TYPES); +} + +struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { + if (!seat->has_focus) { + return NULL; + } + return sway_seat_get_focus_inactive(seat, &root_container); +} + +struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, + struct sway_container *container, enum sway_container_type type) { struct sway_seat_container *current = NULL; struct sway_container *parent = NULL; wl_list_for_each(current, &seat->focus_stack, link) { @@ -388,7 +401,7 @@ struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, stru } while (parent) { - if (parent == container) { + if (parent == container && (type == C_TYPES || current->container->type == type)) { return current->container; } parent = parent->parent; @@ -398,23 +411,6 @@ struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, stru return NULL; } -struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { - if (!seat->has_focus) { - return NULL; - } - return sway_seat_get_focus_inactive(seat, &root_container); -} - -struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, - enum sway_container_type type) { - struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); - if (focus->type == type) { - return focus; - } - - return container_parent(focus, type); -} - void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config) { // clear configs -- cgit v1.2.3