diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-12-14 18:26:33 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-03-18 23:34:29 +0000 |
commit | 792758faa5c089a484ed733d76eee00ddc278177 (patch) | |
tree | 27df93f31353dca6a5d182cc5f290a2c1678a19a /hw/xwayland | |
parent | 122ad8a0dee8656e35cb9170f290aaac87f10462 (diff) |
xwayland: Update lost focus on deactivation
Use the "activated" state from xdg-shell to call the pointer and
keyboard leave events when running rootful.
The regular pointer and keyboard leave notifications are now ignored
when running rootful.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1604
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
Diffstat (limited to 'hw/xwayland')
-rw-r--r-- | hw/xwayland/xwayland-input.c | 6 | ||||
-rw-r--r-- | hw/xwayland/xwayland-screen.h | 1 | ||||
-rw-r--r-- | hw/xwayland/xwayland-window.c | 16 |
3 files changed, 21 insertions, 2 deletions
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index 00949ba6b..9c14b3ff4 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -617,7 +617,8 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer, focus_lost = TRUE; } - xwl_seat_leave_ptr(xwl_seat, focus_lost); + if (xwl_screen->rootless) + xwl_seat_leave_ptr(xwl_seat, focus_lost); } static void @@ -1211,7 +1212,8 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, xwl_screen->serial = serial; - xwl_seat_leave_kbd(xwl_seat); + if (xwl_screen->rootless) + xwl_seat_leave_kbd(xwl_seat); } static void diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index dae6445c2..2c7a8cef9 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -54,6 +54,7 @@ struct xwl_screen { int expecting_event; enum RootClipMode root_clip_mode; + Bool active; int rootless; xwl_glamor_mode_flags glamor; int present; diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 6774ba096..922b45ee9 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -795,6 +795,8 @@ xdg_toplevel_handle_configure(void *data, { struct xwl_window *xwl_window = data; struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + uint32_t *p; + Bool old_active = xwl_screen->active; /* Maintain our current size if no dimensions are requested */ if (width == 0 && height == 0) @@ -804,6 +806,20 @@ xdg_toplevel_handle_configure(void *data, /* This will be committed by the xdg_surface.configure handler */ xwl_window_maybe_resize(xwl_window, width, height); } + + xwl_screen->active = FALSE; + wl_array_for_each (p, states) { + uint32_t state = *p; + if (state == XDG_TOPLEVEL_STATE_ACTIVATED) { + xwl_screen->active = TRUE; + break; + } + } + + if (old_active != xwl_screen->active) { + if (!xwl_screen->active) + xwl_screen_lost_focus(xwl_screen); + } } static void |