xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 5 07:41:44 UTC 2025


 hw/xwayland/xwayland-input.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 8cb078f8b6be8f53d3ad53b74325b5369b90c704
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed May 28 17:10:41 2025 +0200

    xwayland: Do not pretend leaving the X11 surface if buttons are down
    
    Xwayland has its own XYToWindow() handler to account for the case when
    the pointer leaves an X11 surface to enter another Wayland native
    window.
    
    When that occurs, Xwayland will treat it as if the pointer had entered
    the root window so that the X11 clients receive an appropriate leave
    event.
    
    When the pointer leaves the X11 surface, Xwayland will call
    CheckMotion() to update the sprite coordinates and possibly the cursor.
    
    However, if we left the surface with a button down, it means the wayland
    compositor has grabbed the pointer so we will not get button release
    events from the compositor.
    
    Once the button is released, Xwayland will get a pointer enter event from
    the compositor, and Xwayland will clear up the buttons pressed.
    
    But that might confuse Xwayland in thinking the pointer has crossed the
    windows and leave the wrong cursor showing in the X11 surface.
    
    To avoid the issue, if buttons are down, do not pretend the cursor has
    left the X11 surface for the root window.
    
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1811
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2008>

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 35905829e..b137b816b 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -3246,6 +3246,15 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
     if (master->lastSlave != get_pointer_device(xwl_seat))
         return FALSE;
 
+    /* If we left the surface with a button down, it means the wayland compositor
+     * has grabbed the pointer so we will not get button release events from the
+     * compositor, so leave the window processing untouched, so that we do not
+     * end up with the wrong cursor, for example, when processing events once
+     * the pointer enters the X11 surface again.
+     */
+    if (master->button->buttonsDown)
+        return FALSE;
+
     if (xwl_seat->focus_window != NULL &&
         xwl_seat->cursor_confinement_window != NULL &&
         xwl_seat->focus_window != xwl_seat->cursor_confinement_window)
commit 8a77ab083fbd81c450becf23dda4a80e397da575
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Tue May 27 10:35:21 2025 +0200

    Revert "xwayland: Update sprite prior to clearing the focus window"
    
    This breaks regular toplevel enter/leave events when crossing to/from a
    native Wayland window.
    
    A better fix for the original issue follows.
    
    This reverts commit b97b459c060b103aed1a0246ee87a46cc7e51f6c.
    
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2008>

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index f7a8d2165..35905829e 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -616,19 +616,21 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
 {
     struct xwl_seat *xwl_seat = data;
     struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
+    Bool focus_lost = FALSE;
 
     xwl_screen->serial = serial;
 
-    if (xwl_screen->rootless)
-        xwl_seat_leave_ptr(xwl_seat, !!xwl_seat->focus_window);
-
     /* The pointer has left a known xwindow, save it for a possible match
      * in sprite_check_lost_focus()
      */
     if (xwl_seat->focus_window) {
         xwl_seat->last_focus_window = xwl_seat->focus_window;
         xwl_seat->focus_window = NULL;
+        focus_lost = TRUE;
     }
+
+    if (xwl_screen->rootless)
+        xwl_seat_leave_ptr(xwl_seat, focus_lost);
 }
 
 static void


More information about the xorg-commit mailing list