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 760213 - wayland: gdk_seat_grab() set cursor not resilient
wayland: gdk_seat_grab() set cursor not resilient
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on: 759738
Blocks:
 
 
Reported: 2016-01-06 13:09 UTC by Olivier Fourdan
Modified: 2016-01-08 21:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test to demonstrate the issue (3.08 KB, patch)
2016-01-06 13:09 UTC, Olivier Fourdan
none Details | Review
[PATCH] wayland: gdk_seat_grab() set a resilient cursor (1.54 KB, patch)
2016-01-06 13:16 UTC, Olivier Fourdan
none Details | Review
[PATCH v2] wayland: Update parent of dialogs without transient (1.61 KB, patch)
2016-01-08 12:51 UTC, Olivier Fourdan
none Details | Review
wayland: Force the grab cursor while a grab is active (2.79 KB, patch)
2016-01-08 21:03 UTC, Carlos Garnacho
committed Details | Review

Description Olivier Fourdan 2016-01-06 13:09:29 UTC
Created attachment 318319 [details] [review]
Test to demonstrate the issue

Summary:

When one sets a cursor in gdk_seat_grab() and maps a popup window underneath the cursor, the cursor is shows for a very short time and reverted back to the default value.

Steps to reproduce:

1. Apply attachment 318247 [details] [review] from bug 759738
2. Apply attachment to add the test with a grab tests/testpopupgrab.c
3. Build
4. run tests/testpopupgrab in Wayland
5. Click in the window

Actual result:

The pointer changes to a crosshair for a very short time and then revert to the default cursor

Expected result:

The cursor specified in the gdk_seat_grab() remains

See also: bug 759738
Comment 1 Olivier Fourdan 2016-01-06 13:16:47 UTC
Created attachment 318320 [details] [review]
[PATCH] wayland: gdk_seat_grab() set a resilient cursor

When a cursor is specified in gdk_seat_grab(), the cursor is reverted as soon as the pointer enter or leaves another window.
    
To avoid this issue, keep the cursor unchanged when the wayland device has a pointer grab window.
Comment 2 Matthias Clasen 2016-01-08 03:07:49 UTC
Review of attachment 318320 [details] [review]:

::: gdk/wayland/gdkdevice-wayland.c
@@ +2561,2 @@
       wayland_seat->pointer_grab_window = NULL;
+      _gdk_display_set_window_under_pointer (display, wayland_seat->master_pointer, window);

Calling set_window_under_pointer here seems wrong - the window may not be under the pointer at all at this point. And as Carlos points out, this should already be happening in switch_to_pointer_grab.
Comment 3 Olivier Fourdan 2016-01-08 12:51:45 UTC
Created attachment 318485 [details] [review]
[PATCH v2] wayland: Update parent of dialogs without transient

(In reply to Matthias Clasen from comment #2)
> Review of attachment 318320 [details] [review] [review]:
> 
> ::: gdk/wayland/gdkdevice-wayland.c
> @@ +2561,2 @@
>        wayland_seat->pointer_grab_window = NULL;
> +      _gdk_display_set_window_under_pointer (display,
> wayland_seat->master_pointer, window);
> 
> Calling set_window_under_pointer here seems wrong - the window may not be
> under the pointer at all at this point.

Right, what we want is to update toe cursor to whatever is relevant for the window under the cursor.

> And as Carlos points out,

Not sure I followed here, where did Carlos pointed that out, was it on irc?

> this should already be happening in switch_to_pointer_grab.

Thing is, we "block" the cursor change while we have a grab, so we need to update the cursor again after the grab is released.

Is it better to use gdk_wayland_device_update_window_cursor() for this purpose instead of _gdk_display_set_window_under_pointer() here? (updated patch)
Comment 4 Carlos Garnacho 2016-01-08 21:03:42 UTC
Pushed the fix we agreed on on IRC.

The following fix has been pushed:
ad0fc8a wayland: Force the grab cursor while a grab is active
Comment 5 Carlos Garnacho 2016-01-08 21:03:47 UTC
Created attachment 318548 [details] [review]
wayland: Force the grab cursor while a grab is active

When a cursor is specified in gdk_seat_grab(), the cursor is reverted as
soon as the pointer enters or leaves another window.

To avoid this issue, store the grab cursor separately, so we force-apply
it in ::set_window_cursor(). Also, unset early the seat info from the
window on gdk_seat_ungrab(), so the next time switch_to_pointer_grab()
happens we end up picking the cursor set for the window underneath the
pointer window.

Based on a patch by Olivier Fourdan <ofourdan@redhat.com>.