From de811823b60cc33fb6a65c6f1045e9d1fb497243 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 7 Apr 2018 16:14:12 -0400 Subject: seat focus inactive children foreach --- include/sway/input/seat.h | 7 +++++++ sway/input/seat.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 05fff6f7..308f5c6d 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -94,6 +94,13 @@ struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, struct sway_container *container); +/** + * Iterate over the focus-inactive children of the container calling the function on each. + */ +void seat_focus_inactive_children_for_each(struct sway_seat *seat, + struct sway_container *container, + void (*f)(struct sway_container *container, void *data), void *data); + void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); struct seat_config *seat_get_config(struct sway_seat *seat); diff --git a/sway/input/seat.c b/sway/input/seat.c index 1a646715..3656d6b6 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -106,6 +106,20 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, return NULL; } +void seat_focus_inactive_children_for_each(struct sway_seat *seat, + struct sway_container *container, + void (*f)(struct sway_container *container, void *data), void *data) { + struct sway_seat_container *current = NULL; + wl_list_for_each(current, &seat->focus_stack, link) { + if (current->container->parent == NULL) { + continue; + } + if (current->container->parent == container) { + f(current->container, data); + } + } +} + struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, struct sway_container *container) { return seat_get_focus_by_type(seat, container, C_VIEW); -- cgit v1.2.3-54-g00ecf