diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-08 16:05:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-08 16:05:03 -0400 |
commit | 07b6be62144f84539b97ce9d41e9a6c5792deb54 (patch) | |
tree | e5031e3e9a86c67bde038523b2d2cbf773a7303e /sway | |
parent | Merge pull request #1781 from swaywm/map-to-output (diff) | |
parent | 80char (diff) | |
download | sway-07b6be62144f84539b97ce9d41e9a6c5792deb54.tar.gz sway-07b6be62144f84539b97ce9d41e9a6c5792deb54.tar.zst sway-07b6be62144f84539b97ce9d41e9a6c5792deb54.zip |
Merge pull request #1769 from acrisci/focus-inactive-fixes
Focus inactive fixes
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/split.c | 1 | ||||
-rw-r--r-- | sway/criteria.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 74 | ||||
-rw-r--r-- | sway/ipc-json.c | 10 | ||||
-rw-r--r-- | sway/tree/layout.c | 5 |
5 files changed, 68 insertions, 24 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c index ab8565a9..130ed31f 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -11,6 +11,7 @@ | |||
11 | static struct cmd_results *do_split(int layout) { | 11 | static struct cmd_results *do_split(int layout) { |
12 | struct sway_container *con = config->handler_context.current_container; | 12 | struct sway_container *con = config->handler_context.current_container; |
13 | struct sway_container *parent = container_split(con, layout); | 13 | struct sway_container *parent = container_split(con, layout); |
14 | container_create_notify(parent); | ||
14 | arrange_windows(parent, -1, -1); | 15 | arrange_windows(parent, -1, -1); |
15 | 16 | ||
16 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 17 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/criteria.c b/sway/criteria.c index 5fee1888..22e9a49b 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -273,7 +273,7 @@ static int regex_cmp(const char *item, const pcre *regex) { | |||
273 | 273 | ||
274 | // test a single view if it matches list of criteria tokens (all of them). | 274 | // test a single view if it matches list of criteria tokens (all of them). |
275 | static bool criteria_test(struct sway_container *cont, list_t *tokens) { | 275 | static bool criteria_test(struct sway_container *cont, list_t *tokens) { |
276 | if (cont->type != C_VIEW) { | 276 | if (cont->type != C_CONTAINER && cont->type != C_VIEW) { |
277 | return false; | 277 | return false; |
278 | } | 278 | } |
279 | int matches = 0; | 279 | int matches = 0; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 7b01fe88..467e5087 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -87,6 +87,45 @@ static void seat_send_focus(struct sway_seat *seat, | |||
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, | ||
91 | struct sway_container *container, enum sway_container_type type) { | ||
92 | if (container->type == C_VIEW || container->children->length == 0) { | ||
93 | return container; | ||
94 | } | ||
95 | |||
96 | struct sway_seat_container *current = NULL; | ||
97 | wl_list_for_each(current, &seat->focus_stack, link) { | ||
98 | if (current->container->type != type && type != C_TYPES) { | ||
99 | continue; | ||
100 | } | ||
101 | |||
102 | if (container_has_child(container, current->container)) { | ||
103 | return current->container; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | return NULL; | ||
108 | } | ||
109 | |||
110 | void seat_focus_inactive_children_for_each(struct sway_seat *seat, | ||
111 | struct sway_container *container, | ||
112 | void (*f)(struct sway_container *container, void *data), void *data) { | ||
113 | struct sway_seat_container *current = NULL; | ||
114 | wl_list_for_each(current, &seat->focus_stack, link) { | ||
115 | if (current->container->parent == NULL) { | ||
116 | continue; | ||
117 | } | ||
118 | if (current->container->parent == container) { | ||
119 | f(current->container, data); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, | ||
125 | struct sway_container *container) { | ||
126 | return seat_get_focus_by_type(seat, container, C_VIEW); | ||
127 | } | ||
128 | |||
90 | static void handle_seat_container_destroy(struct wl_listener *listener, | 129 | static void handle_seat_container_destroy(struct wl_listener *listener, |
91 | void *data) { | 130 | void *data) { |
92 | struct sway_seat_container *seat_con = | 131 | struct sway_seat_container *seat_con = |
@@ -412,10 +451,23 @@ void seat_set_focus_warp(struct sway_seat *seat, | |||
412 | if (container) { | 451 | if (container) { |
413 | struct sway_seat_container *seat_con = | 452 | struct sway_seat_container *seat_con = |
414 | seat_container_from_container(seat, container); | 453 | seat_container_from_container(seat, container); |
415 | if (!seat_con) { | 454 | if (seat_con == NULL) { |
416 | return; | 455 | return; |
417 | } | 456 | } |
418 | 457 | ||
458 | // put all the anscestors of this container on top of the focus stack | ||
459 | struct sway_seat_container *parent = | ||
460 | seat_container_from_container(seat, | ||
461 | seat_con->container->parent); | ||
462 | while (parent) { | ||
463 | wl_list_remove(&parent->link); | ||
464 | wl_list_insert(&seat->focus_stack, &parent->link); | ||
465 | |||
466 | parent = | ||
467 | seat_container_from_container(seat, | ||
468 | parent->container->parent); | ||
469 | } | ||
470 | |||
419 | wl_list_remove(&seat_con->link); | 471 | wl_list_remove(&seat_con->link); |
420 | wl_list_insert(&seat->focus_stack, &seat_con->link); | 472 | wl_list_insert(&seat->focus_stack, &seat_con->link); |
421 | 473 | ||
@@ -590,26 +642,6 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { | |||
590 | return seat_get_focus_inactive(seat, &root_container); | 642 | return seat_get_focus_inactive(seat, &root_container); |
591 | } | 643 | } |
592 | 644 | ||
593 | struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, | ||
594 | struct sway_container *container, enum sway_container_type type) { | ||
595 | if (container->type == C_VIEW || container->children->length == 0) { | ||
596 | return container; | ||
597 | } | ||
598 | |||
599 | struct sway_seat_container *current = NULL; | ||
600 | wl_list_for_each(current, &seat->focus_stack, link) { | ||
601 | if (current->container->type != type && type != C_TYPES) { | ||
602 | continue; | ||
603 | } | ||
604 | |||
605 | if (container_has_child(container, current->container)) { | ||
606 | return current->container; | ||
607 | } | ||
608 | } | ||
609 | |||
610 | return NULL; | ||
611 | } | ||
612 | |||
613 | struct sway_container *seat_get_focus(struct sway_seat *seat) { | 645 | struct sway_container *seat_get_focus(struct sway_seat *seat) { |
614 | if (!seat->has_focus) { | 646 | if (!seat->has_focus) { |
615 | return NULL; | 647 | return NULL; |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index f9c6c90b..6158fc29 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -166,6 +166,11 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | static void focus_inactive_children_iterator(struct sway_container *c, void *data) { | ||
170 | json_object *focus = data; | ||
171 | json_object_array_add(focus, json_object_new_int(c->id)); | ||
172 | } | ||
173 | |||
169 | json_object *ipc_json_describe_container(struct sway_container *c) { | 174 | json_object *ipc_json_describe_container(struct sway_container *c) { |
170 | if (!(sway_assert(c, "Container must not be null."))) { | 175 | if (!(sway_assert(c, "Container must not be null."))) { |
171 | return NULL; | 176 | return NULL; |
@@ -183,6 +188,11 @@ json_object *ipc_json_describe_container(struct sway_container *c) { | |||
183 | json_object_object_add(object, "focused", | 188 | json_object_object_add(object, "focused", |
184 | json_object_new_boolean(focused)); | 189 | json_object_new_boolean(focused)); |
185 | 190 | ||
191 | json_object *focus = json_object_new_array(); | ||
192 | seat_focus_inactive_children_for_each(seat, c, | ||
193 | focus_inactive_children_iterator, focus); | ||
194 | json_object_object_add(object, "focus", focus); | ||
195 | |||
186 | switch (c->type) { | 196 | switch (c->type) { |
187 | case C_ROOT: | 197 | case C_ROOT: |
188 | ipc_json_describe_root(c, object); | 198 | ipc_json_describe_root(c, object); |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index e81facc6..ae76ca26 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -251,6 +251,7 @@ static void workspace_rejigger(struct sway_container *ws, | |||
251 | container_flatten(ws); | 251 | container_flatten(ws); |
252 | container_reap_empty_recursive(original_parent); | 252 | container_reap_empty_recursive(original_parent); |
253 | wl_signal_emit(&child->events.reparent, original_parent); | 253 | wl_signal_emit(&child->events.reparent, original_parent); |
254 | container_create_notify(new_parent); | ||
254 | arrange_windows(ws, -1, -1); | 255 | arrange_windows(ws, -1, -1); |
255 | } | 256 | } |
256 | 257 | ||
@@ -872,7 +873,7 @@ struct sway_container *container_get_in_direction( | |||
872 | } | 873 | } |
873 | if (next->children && next->children->length) { | 874 | if (next->children && next->children->length) { |
874 | // TODO consider floating children as well | 875 | // TODO consider floating children as well |
875 | return seat_get_focus_by_type(seat, next, C_VIEW); | 876 | return seat_get_focus_inactive_view(seat, next); |
876 | } else { | 877 | } else { |
877 | return next; | 878 | return next; |
878 | } | 879 | } |
@@ -910,7 +911,7 @@ struct sway_container *container_get_in_direction( | |||
910 | wlr_log(L_DEBUG, | 911 | wlr_log(L_DEBUG, |
911 | "cont %d-%p dir %i sibling %d: %p", idx, | 912 | "cont %d-%p dir %i sibling %d: %p", idx, |
912 | container, dir, desired, desired_con); | 913 | container, dir, desired, desired_con); |
913 | struct sway_container *next = seat_get_focus_by_type(seat, desired_con, C_VIEW); | 914 | struct sway_container *next = seat_get_focus_inactive_view(seat, desired_con); |
914 | return next; | 915 | return next; |
915 | } | 916 | } |
916 | } | 917 | } |