After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735831 - Change current cursor on grabs
Change current cursor on grabs
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
unspecified
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-09-01 17:31 UTC by Carlos Garnacho
Modified: 2014-09-01 18:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland: Keep the last cursor on leave, try to restore it on enter (2.03 KB, patch)
2014-09-01 17:31 UTC, Carlos Garnacho
committed Details | Review
wayland: Store and use the current grab cursor, if any (3.22 KB, patch)
2014-09-01 17:31 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2014-09-01 17:31:04 UTC
gdk_device_grab() has a GdkCursor argument that specifies the cursor that will be shown during the grab operation, this is not honored yet on Wayland though. I'm attaching a couple of patches that makes the wayland backend store the cursor that applies during the current grab operation separately, so the cursor can switch back and forth to the one specified for the GdkWindow after grab/ungrab.
Comment 1 Carlos Garnacho 2014-09-01 17:31:45 UTC
Created attachment 285042 [details] [review]
wayland: Keep the last cursor on leave, try to restore it on enter

On DnD, pointer_handle_leave may be triggered without the pointer actually
leaving the window, and pointer_handle_enter() happening after intra-window
DnD won't actually manage to update the cursor (it does nothing directly,
and to the upper layers the cursor is still the same and consistent, so no
attempt will happen).

To fix this, keep the pointer cursor on leave, and ensure it is updated
on enter. The pointer cursor will be updated to any current new one through
the enter/motion events generated if it needs be.
Comment 2 Carlos Garnacho 2014-09-01 17:31:51 UTC
Created attachment 285043 [details] [review]
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.
Comment 3 Matthias Clasen 2014-09-01 18:13:42 UTC
Review of attachment 285043 [details] [review]:

The problem with allowing animation is that we don't know when to stop the animation ?
Anyway, looks good so far
Comment 4 Matthias Clasen 2014-09-01 18:16:43 UTC
Review of attachment 285042 [details] [review]:

if we can't trust leave to actually mean leave, we have a problem with knowing when to stop the cursor animation, I guess ?
Comment 5 Carlos Garnacho 2014-09-01 18:44:12 UTC
(In reply to comment #3)
> Review of attachment 285043 [details] [review]:
> 
> The problem with allowing animation is that we don't know when to stop the
> animation ?
> Anyway, looks good so far

The GdkWaylandDeviceData also stores a cursor_image_index for the window cursor, so it knows the "frame" it's in, I'd have to replicate that for the grab cursor, which wasn't too clean. I think a better fix would be to store that into GdkWaylandCursor instead, and have a gdk_wayland_cursor_tick() call that bumps the current cursor frame, that way both cursors could be animatable.

(In reply to comment #4)
> Review of attachment 285042 [details] [review]:
> 
> if we can't trust leave to actually mean leave, we have a problem with knowing
> when to stop the cursor animation, I guess ?

I at the moment made it so the animation is stopped inconditionally, you either truly leave the window, or get a different cursor used instead with the other patch. If cursor animation is always made to run dependent on the currently set cursor, and cursors are reset to their first frame when going unused, I think that should make the timer run whenever really necessary, and all cursor animations look consistent.

Anyway, all of this is probably better tackled separately.
Comment 6 Carlos Garnacho 2014-09-01 18:49:13 UTC
Attachment 285042 [details] pushed as 2c71b8f - wayland: Keep the last cursor on leave, try to restore it on enter
Attachment 285043 [details] pushed as d5dae5b - wayland: Store and use the current grab cursor, if any