xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 31 06:07:26 UTC 2024


 hw/xwayland/xwayland-xtest.c |   53 ++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 16 deletions(-)

New commits:
commit 0525b9a5b9c40ec4dd384b8878cda85ef7401b94
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Jul 29 17:43:45 2024 +0200

    xwayland/ei: Dequeue events when all caps are available
    
    Currently, we would start dequeuing events as soon as a device is
    resumed, regardless of its capabilities.
    
    If the capabilities are not available, we would just fallback to the
    regular XTEST code path and not use input emulation.
    
    As a result, it is very likely that we shall lose the first events until
    the compositor resumes first a device with the requested capabilities.
    
    To avoid that issue, start emulating only once we have the requested
    capabilities, if they match the seat capabilities.
    
    Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1732
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1631>

diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index c90f3e9b8..d8b0e018c 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -743,6 +743,20 @@ xwl_ei_update_caps(struct xwl_ei_client *xwl_ei_client,
     }
 }
 
+static bool
+xwl_ei_devices_are_ready(struct xwl_ei_client *xwl_ei_client)
+{
+    if ((xwl_ei_client->accept_keyboard ||
+         !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_KEYBOARD)) &&
+        (xwl_ei_client->accept_pointer ||
+         !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER)) &&
+        (xwl_ei_client->accept_abs ||
+         !ei_seat_has_capability(xwl_ei_client->ei_seat, EI_DEVICE_CAP_POINTER_ABSOLUTE)))
+        return true;
+
+    return false;
+}
+
 static void
 xwl_handle_ei_event(int fd, int ready, void *data)
 {
@@ -852,8 +866,10 @@ xwl_handle_ei_event(int fd, int ready, void *data)
                 /* Server has accepted our device (or resumed them),
                  * we can now start sending events */
                 /* FIXME: Maybe add a timestamp and discard old events? */
-                xwl_ei_start_emulating(xwl_ei_client);
-                xwl_dequeue_emulated_events(xwl_ei_client);
+                if (xwl_ei_devices_are_ready(xwl_ei_client)) {
+                    xwl_ei_start_emulating(xwl_ei_client);
+                    xwl_dequeue_emulated_events(xwl_ei_client);
+                }
                 if (!xwl_ei_client->client &&
                     xorg_list_is_empty(&xwl_ei_client->pending_emulated_events))
                     /* All events dequeued and client has disconnected in the meantime */
commit 68ec297ee9821d4ce86f7824a37496569f2343d6
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Jul 29 17:41:42 2024 +0200

    xwayland/ei: Move code to helper function
    
    This is a small code refactoring to help with clarity, simply move the
    code from the switch case for device resume to a dedicated function.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1631>

diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c
index 0a6493953..c90f3e9b8 100644
--- a/hw/xwayland/xwayland-xtest.c
+++ b/hw/xwayland/xwayland-xtest.c
@@ -725,6 +725,24 @@ xwl_dequeue_emulated_events(struct xwl_ei_client *xwl_ei_client)
     return true;
 }
 
+static void
+xwl_ei_update_caps(struct xwl_ei_client *xwl_ei_client,
+                   struct ei_device *ei_device)
+{
+    struct xwl_abs_device *abs;
+
+    if (ei_device == xwl_ei_client->ei_pointer)
+        xwl_ei_client->accept_pointer = true;
+
+    if (ei_device == xwl_ei_client->ei_keyboard)
+        xwl_ei_client->accept_keyboard = true;
+
+    xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices, link) {
+        if (ei_device == abs->device)
+            xwl_ei_client->accept_abs = true;
+    }
+}
+
 static void
 xwl_handle_ei_event(int fd, int ready, void *data)
 {
@@ -830,20 +848,7 @@ xwl_handle_ei_event(int fd, int ready, void *data)
                 break;
             case EI_EVENT_DEVICE_RESUMED:
                 debug_ei("Device resumed\n");
-                if (ei_device == xwl_ei_client->ei_pointer)
-                    xwl_ei_client->accept_pointer = true;
-                if (ei_device == xwl_ei_client->ei_keyboard)
-                    xwl_ei_client->accept_keyboard = true;
-                {
-                    struct xwl_abs_device *abs;
-
-                    xorg_list_for_each_entry(abs, &xwl_ei_client->abs_devices,
-                        link) {
-                        if (ei_device == abs->device)
-                            xwl_ei_client->accept_abs = true;
-                    }
-                }
-
+                xwl_ei_update_caps(xwl_ei_client, ei_device);
                 /* Server has accepted our device (or resumed them),
                  * we can now start sending events */
                 /* FIXME: Maybe add a timestamp and discard old events? */


More information about the xorg-commit mailing list