xserver: Branch 'master' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 25 13:04:52 UTC 2021


 hw/xwayland/xwayland-cursor.c |   40 +++++++++++++++++++++++++---------------
 hw/xwayland/xwayland-cursor.h |    2 ++
 hw/xwayland/xwayland-input.c  |   18 ++----------------
 3 files changed, 29 insertions(+), 31 deletions(-)

New commits:
commit c93c2e7718bcd4c7c728a76f5a34be3a825f0629
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Oct 20 09:32:34 2021 +0200

    xwayland: Add xwl_cursor_clear_frame_cb()
    
    The code to clear a cursor pending frame callback was duplicated in
    multiple places in the code.
    
    Introduce a new xwl_cursor_clear_frame_cb() function and remove the
    duplicated code.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Simon Ser <contact at emersion.fr>
    Reviewed-by: Carlos Garnacho <carlosg at gnome.org>

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index 27b090442..16c13fb64 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -111,15 +111,6 @@ xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
     return xwl_shm_destroy_pixmap(pixmap);
 }
 
-static void
-clear_cursor_frame_callback(struct xwl_cursor *xwl_cursor)
-{
-   if (xwl_cursor->frame_cb) {
-       wl_callback_destroy (xwl_cursor->frame_cb);
-       xwl_cursor->frame_cb = NULL;
-   }
-}
-
 static void
 frame_callback(void *data,
                struct wl_callback *callback,
@@ -127,7 +118,7 @@ frame_callback(void *data,
 {
     struct xwl_cursor *xwl_cursor = data;
 
-    clear_cursor_frame_callback(xwl_cursor);
+    xwl_cursor_clear_frame_cb(xwl_cursor);
     if (xwl_cursor->needs_update) {
         xwl_cursor->needs_update = FALSE;
         xwl_cursor->update_proc(xwl_cursor);
@@ -187,6 +178,18 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat,
     wl_surface_commit(xwl_cursor->surface);
 }
 
+Bool
+xwl_cursor_clear_frame_cb(struct xwl_cursor *xwl_cursor)
+{
+    if (xwl_cursor->frame_cb) {
+        wl_callback_destroy(xwl_cursor->frame_cb);
+        xwl_cursor->frame_cb = NULL;
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
 void
 xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
 {
@@ -200,7 +203,7 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
     if (!xwl_seat->x_cursor) {
         wl_pointer_set_cursor(xwl_seat->wl_pointer,
                               xwl_seat->pointer_enter_serial, NULL, 0, 0);
-        clear_cursor_frame_callback(xwl_cursor);
+        xwl_cursor_clear_frame_cb(xwl_cursor);
         xwl_cursor->needs_update = FALSE;
         return;
     }
@@ -238,7 +241,7 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
         zwp_tablet_tool_v2_set_cursor(xwl_tablet_tool->tool,
                                       xwl_tablet_tool->proximity_in_serial,
                                       NULL, 0, 0);
-        clear_cursor_frame_callback(xwl_cursor);
+        xwl_cursor_clear_frame_cb(xwl_cursor);
         xwl_cursor->needs_update = FALSE;
         return;
     }
@@ -268,8 +271,7 @@ void
 xwl_cursor_release(struct xwl_cursor *xwl_cursor)
 {
     wl_surface_destroy(xwl_cursor->surface);
-    if (xwl_cursor->frame_cb)
-        wl_callback_destroy(xwl_cursor->frame_cb);
+    xwl_cursor_clear_frame_cb(xwl_cursor);
 }
 
 static void
diff --git a/hw/xwayland/xwayland-cursor.h b/hw/xwayland/xwayland-cursor.h
index a48ef16e4..76b5b49b6 100644
--- a/hw/xwayland/xwayland-cursor.h
+++ b/hw/xwayland/xwayland-cursor.h
@@ -31,6 +31,7 @@
 #include <xwayland-types.h>
 #include <xwayland-input.h>
 
+Bool xwl_cursor_clear_frame_cb(struct xwl_cursor *xwl_cursor);
 void xwl_cursor_release(struct xwl_cursor *xwl_cursor);
 void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *tool);
 void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 3b3378e98..f5c24048f 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -463,11 +463,8 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
      * of our surfaces might not have been shown. In that case we'll
      * have a cursor surface frame callback pending which we need to
      * clear so that we can continue submitting new cursor frames. */
-    if (xwl_seat->cursor.frame_cb) {
-        wl_callback_destroy(xwl_seat->cursor.frame_cb);
-        xwl_seat->cursor.frame_cb = NULL;
+    if (xwl_cursor_clear_frame_cb(&xwl_seat->cursor))
         xwl_seat_set_cursor(xwl_seat);
-    }
 
     if (xwl_seat->pointer_warp_emulator) {
         xwl_pointer_warp_emulator_maybe_lock(xwl_seat->pointer_warp_emulator,
@@ -1672,10 +1669,7 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool,
     /* If there is a cursor surface frame callback pending, we need to clear it
      * so that we can continue submitting new cursor frames.
      */
-    if (xwl_tablet_tool->cursor.frame_cb) {
-        wl_callback_destroy(xwl_tablet_tool->cursor.frame_cb);
-        xwl_tablet_tool->cursor.frame_cb = NULL;
-    }
+    xwl_cursor_clear_frame_cb(&xwl_tablet_tool->cursor);
     xwl_tablet_tool_set_cursor(xwl_tablet_tool);
 }
 
commit 672fe9e2442fce3f99030aa0beb5c417b4d24d99
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Oct 20 09:25:19 2021 +0200

    xwayland: Move xwl_cursor_release() to xwayland-cursor.c
    
    It just make more sense to keep xwl_cursor_release() with the rest of
    the cursor code.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Simon Ser <contact at emersion.fr>
    Reviewed-by: Carlos Garnacho <carlosg at gnome.org>

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index be9fa3b28..27b090442 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -264,6 +264,14 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
     xwl_cursor_attach_pixmap(xwl_seat, xwl_cursor, pixmap);
 }
 
+void
+xwl_cursor_release(struct xwl_cursor *xwl_cursor)
+{
+    wl_surface_destroy(xwl_cursor->surface);
+    if (xwl_cursor->frame_cb)
+        wl_callback_destroy(xwl_cursor->frame_cb);
+}
+
 static void
 xwl_seat_update_all_cursors(struct xwl_seat *xwl_seat)
 {
diff --git a/hw/xwayland/xwayland-cursor.h b/hw/xwayland/xwayland-cursor.h
index 401e814a7..a48ef16e4 100644
--- a/hw/xwayland/xwayland-cursor.h
+++ b/hw/xwayland/xwayland-cursor.h
@@ -31,6 +31,7 @@
 #include <xwayland-types.h>
 #include <xwayland-input.h>
 
+void xwl_cursor_release(struct xwl_cursor *xwl_cursor);
 void xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *tool);
 void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
 Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 80000ea9e..3b3378e98 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -1448,14 +1448,6 @@ xwl_cursor_init(struct xwl_cursor *xwl_cursor, struct xwl_screen *xwl_screen,
     xwl_cursor->needs_update = FALSE;
 }
 
-static void
-xwl_cursor_release(struct xwl_cursor *xwl_cursor)
-{
-    wl_surface_destroy(xwl_cursor->surface);
-    if (xwl_cursor->frame_cb)
-        wl_callback_destroy(xwl_cursor->frame_cb);
-}
-
 static void
 xwl_seat_update_cursor(struct xwl_cursor *xwl_cursor)
 {
commit e6401e602500703d26f00b632b0a75681691f2eb
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Wed Oct 20 09:09:51 2021 +0200

    xwayland: Rename xwl_seat_update_cursor()
    
    Two different functions in xwayland-cursor.c and xwayland-input.c use
    the same name xwl_seat_update_cursor() which is confusing when reading
    the code.
    
    Rename xwl_seat_update_cursor() to xwl_seat_update_all_cursors() in
    xwayland-cursor.c to help with readability of the code.
    
    No functional change.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Reviewed-by: Simon Ser <contact at emersion.fr>
    Reviewed-by: Carlos Garnacho <carlosg at gnome.org>

diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c
index c4457cc2a..be9fa3b28 100644
--- a/hw/xwayland/xwayland-cursor.c
+++ b/hw/xwayland/xwayland-cursor.c
@@ -265,7 +265,7 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
 }
 
 static void
-xwl_seat_update_cursor(struct xwl_seat *xwl_seat)
+xwl_seat_update_all_cursors(struct xwl_seat *xwl_seat)
 {
     struct xwl_tablet_tool *xwl_tablet_tool;
 
@@ -285,7 +285,7 @@ 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);
+    xwl_seat_update_all_cursors(xwl_seat);
 }
 
 static void
@@ -339,7 +339,7 @@ xwl_set_cursor(DeviceIntPtr device,
         /* 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);
+        xwl_seat_update_all_cursors(xwl_seat);
         return;
     }
 


More information about the xorg-commit mailing list