[gtk+] wayland: Use the pointer enter serial when setting cursor surface



commit 0d9d808217a04ee965ce5f60f9aff00b2ec4938e
Author: Kristian Høgsberg <krh bitplanet net>
Date:   Wed Mar 20 22:02:42 2013 -0400

    wayland: Use the pointer enter serial when setting cursor surface
    
    wl_pointer.set_cursor is rejected if the serial number doesn't match
    the enter serial number for the wl_pointer.  We passed the right serial
    number when setting the cursor surface in response to the enter event.
    Later set_cursor requests fail, but we can still attach new buffers to
    our cursor surface, which is why the cursor changed, but the hotspot
    didn't update.  Clicking in the decoration results in a leave/enter pair
    which triggers wl_pointer.set_cursor with the right serial. That's why
    clicking the decoration sets the right cursor.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695512

 gdk/wayland/gdkdevice-wayland.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 24176e9..310da09 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -64,6 +64,7 @@ struct _GdkWaylandDeviceData
   struct wl_data_device *data_device;
   double surface_x, surface_y;
   uint32_t time;
+  uint32_t enter_serial;
   GdkWindow *pointer_grab_window;
   uint32_t pointer_grab_time;
   guint32 repeat_timer;
@@ -76,7 +77,6 @@ struct _GdkWaylandDeviceData
   GdkWaylandSelectionOffer *selection_offer_out;
 
   struct wl_surface *pointer_surface;
-  int hotspot_x, hotspot_y;
 };
 
 struct _GdkWaylandDevice
@@ -152,8 +152,6 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
                                       GdkCursor *cursor)
 {
   GdkWaylandDeviceData *wd = GDK_WAYLAND_DEVICE(device)->device;
-  GdkWaylandDisplay *wayland_display =
-    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
   struct wl_buffer *buffer;
   int x, y, w, h;
 
@@ -170,16 +168,13 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
 
   buffer = _gdk_wayland_cursor_get_buffer (cursor, &x, &y, &w, &h);
   wl_pointer_set_cursor (wd->wl_pointer,
-                         _gdk_wayland_display_get_serial (wayland_display),
+                         wd->enter_serial,
                          wd->pointer_surface,
                          x, y);
-  wl_surface_attach (wd->pointer_surface, buffer, wd->hotspot_x - x, wd->hotspot_y - y);
+  wl_surface_attach (wd->pointer_surface, buffer, 0, 0);
   wl_surface_damage (wd->pointer_surface,  0, 0, w, h);
   wl_surface_commit(wd->pointer_surface);
 
-  wd->hotspot_x = x;
-  wd->hotspot_y = y;
-
   g_object_unref (cursor);
 }
 
@@ -579,6 +574,7 @@ pointer_handle_enter (void              *data,
 
   device->surface_x = wl_fixed_to_double (sx);
   device->surface_y = wl_fixed_to_double (sy);
+  device->enter_serial = serial;
 
   _gdk_wayland_display_deliver_event (device->display, event);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]