aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-07-18 20:00:48 +0100
committerLibravatar emersion <contact@emersion.fr>2018-07-18 20:00:48 +0100
commit747725b8bb35bf3fd38d442f5bb565e7a4b11ec4 (patch)
treeb486f3576982ab0f94183323d44bc4bbb3a456e3
parentHandle xwayland override_redirect flag change (diff)
downloadsway-747725b8bb35bf3fd38d442f5bb565e7a4b11ec4.tar.gz
sway-747725b8bb35bf3fd38d442f5bb565e7a4b11ec4.tar.zst
sway-747725b8bb35bf3fd38d442f5bb565e7a4b11ec4.zip
Don't unfocus when an override redirect window is mapped
-rw-r--r--include/sway/input/seat.h2
-rw-r--r--sway/desktop/xwayland.c37
-rw-r--r--sway/input/seat.c6
3 files changed, 19 insertions, 26 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 1f7792ba..eac1626b 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -83,7 +83,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
83 struct sway_container *container, bool warp); 83 struct sway_container *container, bool warp);
84 84
85void seat_set_focus_surface(struct sway_seat *seat, 85void seat_set_focus_surface(struct sway_seat *seat,
86 struct wlr_surface *surface); 86 struct wlr_surface *surface, bool unfocus);
87 87
88void seat_set_focus_layer(struct sway_seat *seat, 88void seat_set_focus_layer(struct sway_seat *seat,
89 struct wlr_layer_surface *layer); 89 struct wlr_layer_surface *layer);
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 1ee3f660..7737a33a 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -69,16 +69,11 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
69 surface->ly = xsurface->y; 69 surface->ly = xsurface->y;
70 desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); 70 desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
71 71
72 if (!xsurface->override_redirect) { 72 struct sway_seat *seat = input_manager_current_seat(input_manager);
73 struct sway_seat *seat = input_manager_current_seat(input_manager); 73 struct wlr_xwayland *xwayland =
74 struct wlr_xwayland *xwayland = 74 seat->input->server->xwayland.wlr_xwayland;
75 seat->input->server->xwayland.wlr_xwayland; 75 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
76 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 76 seat_set_focus_surface(seat, xsurface->surface, false);
77 seat_set_focus_surface(seat, xsurface->surface);
78 }
79
80 // TODO: we don't send surface enter/leave events to xwayland unmanaged
81 // surfaces, but xwayland doesn't support HiDPI anyway
82} 77}
83 78
84static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { 79static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
@@ -89,18 +84,16 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
89 wl_list_remove(&surface->link); 84 wl_list_remove(&surface->link);
90 wl_list_remove(&surface->commit.link); 85 wl_list_remove(&surface->commit.link);
91 86
92 if (!xsurface->override_redirect) { 87 struct sway_seat *seat = input_manager_current_seat(input_manager);
93 struct sway_seat *seat = input_manager_current_seat(input_manager); 88 if (seat->wlr_seat->keyboard_state.focused_surface ==
94 if (seat->wlr_seat->keyboard_state.focused_surface == 89 xsurface->surface) {
95 xsurface->surface) { 90 // Restore focus
96 // Restore focus 91 struct sway_container *previous =
97 struct sway_container *previous = 92 seat_get_focus_inactive(seat, &root_container);
98 seat_get_focus_inactive(seat, &root_container); 93 if (previous) {
99 if (previous) { 94 // Hack to get seat to re-focus the return value of get_focus
100 // Hack to get seat to re-focus the return value of get_focus 95 seat_set_focus(seat, previous->parent);
101 seat_set_focus(seat, previous->parent); 96 seat_set_focus(seat, previous);
102 seat_set_focus(seat, previous);
103 }
104 } 97 }
105 } 98 }
106} 99}
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 8ed4a3fe..eadf3b26 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -753,11 +753,11 @@ void seat_set_focus(struct sway_seat *seat,
753} 753}
754 754
755void seat_set_focus_surface(struct sway_seat *seat, 755void seat_set_focus_surface(struct sway_seat *seat,
756 struct wlr_surface *surface) { 756 struct wlr_surface *surface, bool unfocus) {
757 if (seat->focused_layer != NULL) { 757 if (seat->focused_layer != NULL) {
758 return; 758 return;
759 } 759 }
760 if (seat->has_focus) { 760 if (seat->has_focus && unfocus) {
761 struct sway_container *focus = seat_get_focus(seat); 761 struct sway_container *focus = seat_get_focus(seat);
762 seat_send_unfocus(focus, seat); 762 seat_send_unfocus(focus, seat);
763 seat->has_focus = false; 763 seat->has_focus = false;
@@ -789,7 +789,7 @@ void seat_set_focus_layer(struct sway_seat *seat,
789 } else if (!layer || seat->focused_layer == layer) { 789 } else if (!layer || seat->focused_layer == layer) {
790 return; 790 return;
791 } 791 }
792 seat_set_focus_surface(seat, layer->surface); 792 seat_set_focus_surface(seat, layer->surface, true);
793 if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { 793 if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
794 seat->focused_layer = layer; 794 seat->focused_layer = layer;
795 } 795 }