From 0c9d47e56f2412d1b3e0fdfc097856c5ccc491ce Mon Sep 17 00:00:00 2001 From: Jelle De Loecker Date: Mon, 30 May 2022 10:00:14 +0200 Subject: [PATCH] xwayland-unmanaged: focus parent surface on unmap Re-focus on parent surface if it is available Fixes #352 relating to JetBrains and Intellij focus issues Backport of 61675b521c10496f289f88b230ec209d7219d523 --- src/xwayland-unmanaged.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/xwayland-unmanaged.c b/src/xwayland-unmanaged.c index b5c5922a..41ffc05f 100644 --- a/src/xwayland-unmanaged.c +++ b/src/xwayland-unmanaged.c @@ -56,6 +56,17 @@ unmanaged_handle_unmap(struct wl_listener *listener, void *data) struct seat *seat = &unmanaged->server->seat; if (seat->seat->keyboard_state.focused_surface == xsurface->surface) { + /* + * Try to focus on parent surface + * This seems to fix JetBrains/Intellij window focus issues + */ + if (xsurface->parent && xsurface->parent->surface + && wlr_xwayland_or_surface_wants_focus(xsurface->parent)) { + seat_focus_surface(seat, xsurface->parent->surface); + return; + } + + /* Try to focus on last created unmanaged xwayland surface */ struct xwayland_unmanaged *u; struct wl_list *list = &unmanaged->server->unmanaged_surfaces; wl_list_for_each (u, list, link) {