aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-06-05 08:44:53 +0100
committerLibravatar GitHub <noreply@github.com>2018-06-05 08:44:53 +0100
commit6b9ffbad20995d322748bebc4ea43cbffb070381 (patch)
treee8c45627ec1d38d88349160aa04d53f4e4432525
parentMerge pull request #2106 from RedSoxFan/fix-2105 (diff)
parentDon't restore focus if unmapping surface wasn't focused (diff)
downloadsway-6b9ffbad20995d322748bebc4ea43cbffb070381.tar.gz
sway-6b9ffbad20995d322748bebc4ea43cbffb070381.tar.zst
sway-6b9ffbad20995d322748bebc4ea43cbffb070381.zip
Merge pull request #2103 from RyanDwyer/focus-fixes
Focus fixes
-rw-r--r--sway/desktop/layer_shell.c5
-rw-r--r--sway/desktop/xwayland.c15
-rw-r--r--sway/input/cursor.c2
-rw-r--r--sway/input/seat.c3
4 files changed, 23 insertions, 2 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index b60aa487..2d355b74 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -257,6 +257,11 @@ static void unmap(struct sway_layer_surface *sway_layer) {
257 } 257 }
258 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, 258 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
259 sway_layer->layer_surface->surface, true); 259 sway_layer->layer_surface->surface, true);
260
261 struct sway_seat *seat = input_manager_current_seat(input_manager);
262 if (seat->focused_layer == sway_layer->layer_surface) {
263 seat_set_focus_layer(seat, NULL);
264 }
260} 265}
261 266
262static void handle_destroy(struct wl_listener *listener, void *data) { 267static void handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 75bfb7b2..6447b711 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -77,6 +77,21 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
77 desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true); 77 desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true);
78 wl_list_remove(&surface->link); 78 wl_list_remove(&surface->link);
79 wl_list_remove(&surface->commit.link); 79 wl_list_remove(&surface->commit.link);
80
81 if (!wlr_xwayland_surface_is_unmanaged(xsurface)) {
82 struct sway_seat *seat = input_manager_current_seat(input_manager);
83 if (seat->wlr_seat->keyboard_state.focused_surface ==
84 xsurface->surface) {
85 // Restore focus
86 struct sway_container *previous =
87 seat_get_focus_inactive(seat, &root_container);
88 if (previous) {
89 // Hack to get seat to re-focus the return value of get_focus
90 seat_set_focus(seat, previous->parent);
91 seat_set_focus(seat, previous);
92 }
93 }
94 }
80} 95}
81 96
82static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { 97static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 16e5427b..d6e17ae1 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -264,7 +264,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
264 if (new_ws != old_ws) { 264 if (new_ws != old_ws) {
265 seat_set_focus(cursor->seat, cont); 265 seat_set_focus(cursor->seat, cont);
266 } 266 }
267 } else { 267 } else if (cont) {
268 seat_set_focus(cursor->seat, cont); 268 seat_set_focus(cursor->seat, cont);
269 } 269 }
270 270
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 0e539b70..071ef020 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -658,7 +658,8 @@ void seat_set_focus_layer(struct sway_seat *seat,
658 struct wlr_layer_surface *layer) { 658 struct wlr_layer_surface *layer) {
659 if (!layer && seat->focused_layer) { 659 if (!layer && seat->focused_layer) {
660 seat->focused_layer = NULL; 660 seat->focused_layer = NULL;
661 struct sway_container *previous = seat_get_focus(seat); 661 struct sway_container *previous =
662 seat_get_focus_inactive(seat, &root_container);
662 if (previous) { 663 if (previous) {
663 wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous, 664 wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous,
664 container_type_to_str(previous->type), previous->name); 665 container_type_to_str(previous->type), previous->name);