aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-07 16:06:36 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-07 16:06:36 -0400
commitc0f9ee7bd1fc70672dcf64a19c9fbbf5a80b12b0 (patch)
tree90e2f7261e5e9191bea374459a9b5c7fc0acedf3 /sway/input/seat.c
parentMerge pull request #1767 from emersion/fix-dmenu (diff)
downloadsway-c0f9ee7bd1fc70672dcf64a19c9fbbf5a80b12b0.tar.gz
sway-c0f9ee7bd1fc70672dcf64a19c9fbbf5a80b12b0.tar.zst
sway-c0f9ee7bd1fc70672dcf64a19c9fbbf5a80b12b0.zip
seat get focus inactive view
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index b94e3291..1a646715 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -86,6 +86,31 @@ static void seat_send_focus(struct sway_seat *seat,
86 } 86 }
87} 87}
88 88
89static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
90 struct sway_container *container, enum sway_container_type type) {
91 if (container->type == C_VIEW || container->children->length == 0) {
92 return container;
93 }
94
95 struct sway_seat_container *current = NULL;
96 wl_list_for_each(current, &seat->focus_stack, link) {
97 if (current->container->type != type && type != C_TYPES) {
98 continue;
99 }
100
101 if (container_has_child(container, current->container)) {
102 return current->container;
103 }
104 }
105
106 return NULL;
107}
108
109struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat,
110 struct sway_container *container) {
111 return seat_get_focus_by_type(seat, container, C_VIEW);
112}
113
89static void handle_seat_container_destroy(struct wl_listener *listener, 114static void handle_seat_container_destroy(struct wl_listener *listener,
90 void *data) { 115 void *data) {
91 struct sway_seat_container *seat_con = 116 struct sway_seat_container *seat_con =
@@ -549,26 +574,6 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
549 return seat_get_focus_inactive(seat, &root_container); 574 return seat_get_focus_inactive(seat, &root_container);
550} 575}
551 576
552struct sway_container *seat_get_focus_by_type(struct sway_seat *seat,
553 struct sway_container *container, enum sway_container_type type) {
554 if (container->type == C_VIEW || container->children->length == 0) {
555 return container;
556 }
557
558 struct sway_seat_container *current = NULL;
559 wl_list_for_each(current, &seat->focus_stack, link) {
560 if (current->container->type != type && type != C_TYPES) {
561 continue;
562 }
563
564 if (container_has_child(container, current->container)) {
565 return current->container;
566 }
567 }
568
569 return NULL;
570}
571
572struct sway_container *seat_get_focus(struct sway_seat *seat) { 577struct sway_container *seat_get_focus(struct sway_seat *seat) {
573 if (!seat->has_focus) { 578 if (!seat->has_focus) {
574 return NULL; 579 return NULL;