[Bf-blender-cvs] [98306036207] master: GHOST/Wayland: skip cursor surface operations when hiding the cursor

Campbell Barton noreply at git.blender.org
Fri Jun 17 09:36:06 CEST 2022


Commit: 9830603620762b5784983dddc076bc7945dc1e16
Author: Campbell Barton
Date:   Fri Jun 17 17:35:27 2022 +1000
Branches: master
https://developer.blender.org/rB9830603620762b5784983dddc076bc7945dc1e16

GHOST/Wayland: skip cursor surface operations when hiding the cursor

Also set the buffer scale before setting the cursor (matching SDL).

===================================================================

M	intern/ghost/intern/GHOST_SystemWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 4b5fa2bf3fb..2b0abd2cc41 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2476,8 +2476,12 @@ static void set_cursor_buffer(input_t *input, wl_buffer *buffer)
   const int32_t hotspot_x = int32_t(c->wl_image.hotspot_x) / c->scale;
   const int32_t hotspot_y = int32_t(c->wl_image.hotspot_y) / c->scale;
 
-  wl_surface_attach(c->wl_surface, buffer, 0, 0);
-  wl_surface_damage(c->wl_surface, 0, 0, image_size_x, image_size_y);
+  if (buffer) {
+    wl_surface_set_buffer_scale(c->wl_surface, c->scale);
+    wl_surface_attach(c->wl_surface, buffer, 0, 0);
+    wl_surface_damage(c->wl_surface, 0, 0, image_size_x, image_size_y);
+    wl_surface_commit(c->wl_surface);
+  }
 
   wl_pointer_set_cursor(input->wl_pointer,
                         input->pointer_serial,
@@ -2485,25 +2489,25 @@ static void set_cursor_buffer(input_t *input, wl_buffer *buffer)
                         hotspot_x,
                         hotspot_y);
 
-  wl_surface_commit(c->wl_surface);
-
   /* Set the cursor for all tablet tools as well. */
   for (struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : input->tablet_tools) {
     tablet_tool_input_t *tool_input = static_cast<tablet_tool_input_t *>(
         zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
-    /* FIXME: for some reason cursor scale is applied twice (when the scale isn't 1x),
-     * this happens both in gnome-shell & KDE. Setting the surface scale here doesn't help. */
-    // wl_surface_set_buffer_scale(tool_input->cursor_surface, 1);
-    wl_surface_attach(tool_input->cursor_surface, buffer, 0, 0);
-    wl_surface_damage(tool_input->cursor_surface, 0, 0, image_size_x, image_size_y);
+
+    if (buffer) {
+      /* FIXME: for some reason cursor scale is applied twice (when the scale isn't 1x),
+       * this happens both in gnome-shell & KDE. Setting the surface scale here doesn't help. */
+      wl_surface_set_buffer_scale(tool_input->cursor_surface, c->scale);
+      wl_surface_attach(tool_input->cursor_surface, buffer, 0, 0);
+      wl_surface_damage(tool_input->cursor_surface, 0, 0, image_size_x, image_size_y);
+      wl_surface_commit(tool_input->cursor_surface);
+    }
 
     zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2,
                                   input->tablet_serial,
                                   c->visible ? tool_input->cursor_surface : nullptr,
                                   hotspot_x,
                                   hotspot_y);
-
-    wl_surface_commit(tool_input->cursor_surface);
   }
 }



More information about the Bf-blender-cvs mailing list