xserver: Branch 'master' - 3 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Mar 18 23:37:49 UTC 2024
hw/xwayland/xwayland-input.c | 42 ++++++++++++++++++++++++++++++++----------
hw/xwayland/xwayland-input.h | 3 +++
hw/xwayland/xwayland-screen.c | 11 +++++++++++
hw/xwayland/xwayland-screen.h | 2 ++
hw/xwayland/xwayland-window.c | 16 ++++++++++++++++
5 files changed, 64 insertions(+), 10 deletions(-)
New commits:
commit 792758faa5c089a484ed733d76eee00ddc278177
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Dec 14 18:26:33 2023 +0100
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 at redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1604
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
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
commit 122ad8a0dee8656e35cb9170f290aaac87f10462
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Dec 14 18:23:52 2023 +0100
xwayland: Introduce xwl_screen_lost_focus()
xwl_screen_lost_focus() calls the keyboard and pointer leave functions
for each seat.
No functional change.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index b1fce53ae..16e95f900 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -744,6 +744,17 @@ xwl_screen_get_next_output_serial(struct xwl_screen *xwl_screen)
return xwl_screen->output_name_serial++;
}
+void
+xwl_screen_lost_focus(struct xwl_screen *xwl_screen)
+{
+ struct xwl_seat *xwl_seat;
+
+ xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
+ xwl_seat_leave_ptr(xwl_seat, TRUE);
+ xwl_seat_leave_kbd(xwl_seat);
+ }
+}
+
Bool
xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
{
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index 2f0922a21..dae6445c2 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -164,5 +164,6 @@ void xwl_surface_damage(struct xwl_screen *xwl_screen,
struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
int xwl_screen_get_next_output_serial(struct xwl_screen * xwl_screen);
+void xwl_screen_lost_focus(struct xwl_screen *xwl_screen);
#endif /* XWAYLAND_SCREEN_H */
commit 654c354da971d11bafd310d9821578bc64bd7936
Author: Olivier Fourdan <ofourdan at redhat.com>
Date: Thu Dec 14 18:10:05 2023 +0100
xwayland: Move the leave kbd/ptr code
Move part of the code that deals with pointer or keyboard leave
notifications to their own function.
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 078e7c2d3..00949ba6b 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -587,14 +587,26 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
maybe_fake_grab_devices(xwl_seat);
}
+void
+xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost)
+{
+ DeviceIntPtr dev = get_pointer_device(xwl_seat);
+
+ if (focus_lost)
+ CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT));
+
+ maybe_fake_ungrab_devices(xwl_seat);
+}
+
static void
pointer_handle_leave(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface)
{
struct xwl_seat *xwl_seat = data;
- DeviceIntPtr dev = get_pointer_device(xwl_seat);
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+ Bool focus_lost = FALSE;
- xwl_seat->xwl_screen->serial = serial;
+ xwl_screen->serial = serial;
/* The pointer has left a known xwindow, save it for a possible match
* in sprite_check_lost_focus()
@@ -602,10 +614,10 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
if (xwl_seat->focus_window) {
xwl_seat->last_xwindow = xwl_seat->focus_window->window;
xwl_seat->focus_window = NULL;
- CheckMotion(NULL, GetMaster(dev, POINTER_OR_FLOAT));
+ focus_lost = TRUE;
}
- maybe_fake_ungrab_devices(xwl_seat);
+ xwl_seat_leave_ptr(xwl_seat, focus_lost);
}
static void
@@ -1177,15 +1189,11 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
maybe_fake_grab_devices(xwl_seat);
}
-static void
-keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
- uint32_t serial, struct wl_surface *surface)
+void
+xwl_seat_leave_kbd(struct xwl_seat *xwl_seat)
{
- struct xwl_seat *xwl_seat = data;
uint32_t *k;
- xwl_seat->xwl_screen->serial = serial;
-
wl_array_for_each(k, &xwl_seat->keys)
QueueKeyboardEvents(xwl_seat->keyboard, LeaveNotify, *k + 8);
@@ -1194,6 +1202,18 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
maybe_fake_ungrab_devices(xwl_seat);
}
+static void
+keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
+ uint32_t serial, struct wl_surface *surface)
+{
+ struct xwl_seat *xwl_seat = data;
+ struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+
+ xwl_screen->serial = serial;
+
+ xwl_seat_leave_kbd(xwl_seat);
+}
+
static void
keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t mods_depressed,
diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h
index ee94d73ae..2e686f945 100644
--- a/hw/xwayland/xwayland-input.h
+++ b/hw/xwayland/xwayland-input.h
@@ -190,6 +190,9 @@ struct xwl_tablet_pad {
struct xorg_list pad_group_list;
};
+void xwl_seat_leave_ptr(struct xwl_seat *xwl_seat, Bool focus_lost);
+void xwl_seat_leave_kbd(struct xwl_seat *xwl_seat);
+
void xwl_seat_destroy(struct xwl_seat *xwl_seat);
void xwl_seat_clear_touch(struct xwl_seat *xwl_seat, WindowPtr window);
More information about the xorg-commit
mailing list