wayland: Store and use the current grab cursor, if any

Only static cursors are supported in gdk_device_grab() so far. Obey the
cursor that gdk_device_grab() specifies, which may be different to
the pointer window one. As soon as the grab is gone, the pointer window
cursor will be restored as usual.

https://bugzilla.gnome.org/show_bug.cgi?id=735831
This commit is contained in:
Carlos Garnacho 2014-09-01 19:11:02 +02:00
parent 2c71b8f599
commit d5dae5b5df

View File

@ -86,6 +86,7 @@ struct _GdkWaylandDeviceData
guint32 repeat_count;
GSettings *keyboard_settings;
GdkCursor *grab_cursor;
guint cursor_timeout_id;
guint cursor_image_index;
@ -180,8 +181,21 @@ gdk_wayland_device_update_window_cursor (GdkWaylandDeviceData *wd)
int x, y, w, h, scale;
guint next_image_index, next_image_delay;
if (wd->grab_cursor)
{
buffer = _gdk_wayland_cursor_get_buffer (wd->grab_cursor, 0,
&x, &y, &w, &h, &scale);
}
else if (wd->cursor)
{
buffer = _gdk_wayland_cursor_get_buffer (wd->cursor, wd->cursor_image_index,
&x, &y, &w, &h, &scale);
}
else
{
wd->cursor_timeout_id = 0;
return TRUE;
}
if (!wd->wl_pointer)
return FALSE;
@ -195,6 +209,13 @@ gdk_wayland_device_update_window_cursor (GdkWaylandDeviceData *wd)
wl_surface_damage (wd->pointer_surface, 0, 0, w, h);
wl_surface_commit (wd->pointer_surface);
if (wd->grab_cursor)
{
/* We admit only static icons during drags so far */
gdk_wayland_device_stop_window_cursor_animation (wd);
return TRUE;
}
next_image_index =
_gdk_wayland_cursor_get_next_image_index (wd->cursor,
wd->cursor_image_index,
@ -356,6 +377,13 @@ gdk_wayland_device_grab (GdkDevice *device,
device,
wayland_device->wl_seat,
time_);
g_clear_object (&wayland_device->grab_cursor);
if (cursor)
wayland_device->grab_cursor = g_object_ref (cursor);
gdk_wayland_device_update_window_cursor (wayland_device);
}
return GDK_GRAB_SUCCESS;
@ -383,6 +411,9 @@ gdk_wayland_device_ungrab (GdkDevice *device,
if (grab)
grab->serial_end = grab->serial_start;
g_clear_object (&wayland_device->grab_cursor);
gdk_wayland_device_update_window_cursor (wayland_device);
if (wayland_device->pointer_grab_window)
_gdk_wayland_window_set_device_grabbed (wayland_device->pointer_grab_window,
NULL,