xserver: Branch 'xwayland-21.1' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 3 17:39:36 UTC 2021


 hw/xwayland/xwayland-cursor.c |   99 +++++++++++++++++++++++++++++++++++++-----
 hw/xwayland/xwayland-input.h  |    2 
 meson.build                   |    2 
 3 files changed, 92 insertions(+), 11 deletions(-)

New commits:
commit f20dc97947d368d0750ea190f4b4df88d005166a
Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Wed Mar 3 18:03:00 2021 +0100

    Bump version to 21.0.99.902
    
    Xwayland 21.1.0 release candidate 2.

diff --git a/meson.build b/meson.build
index 3fba13f98..882bca936 100644
--- a/meson.build
+++ b/meson.build
@@ -3,7 +3,7 @@ project('xwayland', 'c',
             'buildtype=debugoptimized',
             'c_std=gnu99',
         ],
-        version: '21.0.99.901',
+        version: '21.0.99.902',
         meson_version: '>= 0.46.0',
 )
 add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc'])
commit 15f8b789049eb3cfab0f811d29b9c8d377ae941d
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Mar 3 17:56:55 2021 +0100

    xwayland: Delay cursor visibility update
    
    Xwayland won't emulate XWarpPointer requests if the cursor is visible,
    this is to avoid having the cursor jumping on screen and preventing
    random X11 clients from controlling the pointer in Wayland, while
    allowing games which use that mechanism with a hidden cursor to work in
    Xwayland.
    
    There are, however, games which tend to do it in the wrong order, i.e.
    show the cursor before moving the pointer, and because Xwayland will not
    allow an X11 client to move the pointer while the cursor is visible, the
    requests will fail.
    
    Add a workaround for such X11 clients, when the cursor is being shown,
    keep it invisible until the cursor is actually moved. This way, X11
    clients which show their cursor just before moving it would still have a
    chance to succeed.
    
    v2: Add a timeout to show the cursor for well behaved clients.
    v3: Some cleanup (Michel)
    v4: Do not cancel cursor delay when updating the cursor to avoid
        delaying cursor visibility indefinitely if the client keeps
        settings different cursors (Michel)
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Tested-by: Jaap Buurman jaapbuurman at gmail.com
    Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/734
    (cherry picked from commit 97ed0048e45f4909a0c164b27e768af8c9364068)

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index 91cc18464..fac8840e6 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -41,6 +41,8 @@
 
 #include "tablet-unstable-v2-client-protocol.h"
 
+#define DELAYED_X_CURSOR_TIMEOUT 5 /* ms */
+
 static DevPrivateKeyRec xwl_cursor_private_key;
 
 static void
@@ -255,12 +257,69 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
     xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
 }
 
+static void
+xwl_seat_update_cursor(struct xwl_seat *xwl_seat)
+{
+    struct xwl_tablet_tool *xwl_tablet_tool;
+
+    xwl_seat_set_cursor(xwl_seat);
+
+    xorg_list_for_each_entry(xwl_tablet_tool, &xwl_seat->tablet_tools, link) {
+        if (xwl_tablet_tool->proximity_in_serial != 0)
+            xwl_tablet_tool_set_cursor(xwl_tablet_tool);
+    }
+
+    /* Clear delayed cursor if any */
+    xwl_seat->pending_x_cursor = NULL;
+}
+
+static void
+xwl_seat_update_cursor_visibility(struct xwl_seat *xwl_seat)
+{
+    xwl_seat->x_cursor = xwl_seat->pending_x_cursor;
+    xwl_seat_cursor_visibility_changed(xwl_seat);
+    xwl_seat_update_cursor(xwl_seat);
+}
+
+static void
+xwl_set_cursor_free_timer(struct xwl_seat *xwl_seat)
+{
+    if (xwl_seat->x_cursor_timer) {
+        TimerFree(xwl_seat->x_cursor_timer);
+        xwl_seat->x_cursor_timer = NULL;
+    }
+}
+
+static CARD32
+xwl_set_cursor_timer_callback(OsTimerPtr timer, CARD32 time, void *arg)
+{
+    struct xwl_seat *xwl_seat = arg;
+
+    xwl_set_cursor_free_timer(xwl_seat);
+    xwl_seat_update_cursor_visibility(xwl_seat);
+
+    /* Don't re-arm the timer */
+    return 0;
+}
+
+static void
+xwl_set_cursor_delayed(struct xwl_seat *xwl_seat, CursorPtr cursor)
+{
+    xwl_seat->pending_x_cursor = cursor;
+
+    if (xwl_seat->x_cursor_timer == NULL) {
+        xwl_seat->x_cursor_timer = TimerSet(xwl_seat->x_cursor_timer,
+                                            0, DELAYED_X_CURSOR_TIMEOUT,
+                                            &xwl_set_cursor_timer_callback,
+                                            xwl_seat);
+    }
+}
+
 static void
 xwl_set_cursor(DeviceIntPtr device,
                ScreenPtr screen, CursorPtr cursor, int x, int y)
 {
     struct xwl_seat *xwl_seat;
-    struct xwl_tablet_tool *xwl_tablet_tool;
     Bool cursor_visibility_changed;
 
     xwl_seat = device->public.devicePrivate;
@@ -269,22 +328,37 @@ xwl_set_cursor(DeviceIntPtr device,
 
     cursor_visibility_changed = !!xwl_seat->x_cursor ^ !!cursor;
 
-    xwl_seat->x_cursor = cursor;
-
-    if (cursor_visibility_changed)
-        xwl_seat_cursor_visibility_changed(xwl_seat);
-
-    xwl_seat_set_cursor(xwl_seat);
+    if (!cursor_visibility_changed) {
+        /* Cursor remains shown or hidden, apply the change immediately */
+        xwl_set_cursor_free_timer(xwl_seat);
+        xwl_seat->x_cursor = cursor;
+        xwl_seat_update_cursor(xwl_seat);
+        return;
+    }
 
-    xorg_list_for_each_entry(xwl_tablet_tool, &xwl_seat->tablet_tools, link) {
-        if (xwl_tablet_tool->proximity_in_serial != 0)
-            xwl_tablet_tool_set_cursor(xwl_tablet_tool);
+    xwl_seat->pending_x_cursor = cursor;
+    if (cursor) {
+        /* Cursor is being shown, delay the change until moved or timed out */
+        xwl_set_cursor_delayed(xwl_seat, cursor);
+    } else {
+        /* Cursor is being hidden, apply the change immediately */
+        xwl_seat_update_cursor_visibility(xwl_seat);
     }
 }
 
 static void
 xwl_move_cursor(DeviceIntPtr device, ScreenPtr screen, int x, int y)
 {
+    struct xwl_seat *xwl_seat;
+
+    xwl_seat = device->public.devicePrivate;
+    if (xwl_seat == NULL)
+        return;
+
+    xwl_set_cursor_free_timer(xwl_seat);
+
+    if (xwl_seat->pending_x_cursor)
+        xwl_seat_update_cursor_visibility(xwl_seat);
 }
 
 static Bool
@@ -296,6 +370,11 @@ xwl_device_cursor_initialize(DeviceIntPtr device, ScreenPtr screen)
 static void
 xwl_device_cursor_cleanup(DeviceIntPtr device, ScreenPtr screen)
 {
+    struct xwl_seat *xwl_seat;
+
+    xwl_seat = device->public.devicePrivate;
+    if (xwl_seat)
+        xwl_set_cursor_free_timer(xwl_seat);
 }
 
 static miPointerSpriteFuncRec xwl_pointer_sprite_funcs = {
diff --git a/hw/xwayland/xwayland-input.h b/hw/xwayland/xwayland-input.h
index e7e21fcfd..0c6591b5e 100644
--- a/hw/xwayland/xwayland-input.h
+++ b/hw/xwayland/xwayland-input.h
@@ -75,6 +75,8 @@ struct xwl_seat {
     uint32_t pointer_enter_serial;
     struct xorg_list link;
     CursorPtr x_cursor;
+    OsTimerPtr x_cursor_timer;
+    CursorPtr pending_x_cursor;
     struct xwl_cursor cursor;
     WindowPtr last_xwindow;
 


More information about the xorg-commit mailing list