aboutsummaryrefslogtreecommitdiff
path: root/sway/desktop
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-05-28 18:45:39 -0400
committerSimon Ser <contact@emersion.fr>2020-06-01 17:58:15 +0200
commit613abdda6fa978480067a35c3adc46fb414b0b5c (patch)
tree3f5d493fb8ded1cceb8afac6d2fcc036ac7f0644 /sway/desktop
parent83866558d37d8a16d88090df59b27365cf73490a (diff)
downloadsway-613abdda6fa978480067a35c3adc46fb414b0b5c.tar.xz
xwayland: pass focus to previous unmanaged surface on unmap
This is necessary because some applications (e.g. Jetbrains IDEs) represent their multi-level menus as unmanaged surfaces, and when closing a submenu, the main menu should get input focus. Closes #5347.
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/xwayland.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 8936c8bc..4bf5b6b8 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -94,6 +94,22 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
struct sway_seat *seat = input_manager_current_seat();
if (seat->wlr_seat->keyboard_state.focused_surface ==
xsurface->surface) {
+
+ // Try to find another unmanaged surface from the same process to pass
+ // focus to. This is necessary because some applications (e.g. Jetbrains
+ // IDEs) represent their multi-level menus as unmanaged surfaces, and
+ // when closing a submenu, the main menu should get input focus.
+ struct sway_xwayland_unmanaged *current;
+ wl_list_for_each(current, &root->xwayland_unmanaged, link) {
+ struct wlr_xwayland_surface *prev_xsurface =
+ current->wlr_xwayland_surface;
+ if (prev_xsurface->pid == xsurface->pid &&
+ wlr_xwayland_or_surface_wants_focus(prev_xsurface)) {
+ seat_set_focus_surface(seat, prev_xsurface->surface, false);
+ return;
+ }
+ }
+
// Restore focus
struct sway_node *previous = seat_get_focus_inactive(seat, &root->node);
if (previous) {