diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-03-31 00:44:17 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-03-31 15:37:16 -0400 |
commit | 7706d83160267be61accb1b6f7bdc2f43299cae7 (patch) | |
tree | 64b9751ee7edf613c9e3a06d1f5446501f4ddbaf /sway/input/seat.c | |
parent | 122b96abed9955f78e3f157167d34312f5bb551d (diff) |
basic split containers
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 32 |
1 files changed, 14 insertions, 18 deletions
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 <assert.h> #include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_xcursor_manager.h> @@ -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 |