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 722815 - gdk_window_get_pointer() returns GdkEventMask values instead of GdkModifierType during 'drag-motion' event on OSX
gdk_window_get_pointer() returns GdkEventMask values instead of GdkModifierTy...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
2.24.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-01-23 05:13 UTC by Dustin Spicuzza
Modified: 2016-01-13 04:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch: Deliver GdkModifierType values (1.13 KB, patch)
2014-11-07 15:57 UTC, Hans Breuer
committed Details | Review

Description Dustin Spicuzza 2014-01-23 05:13:14 UTC
Note: I've only looked at the bug using the pygtk bindings on 2.24.11, but I've examined the code in 2.24.22 and the relevant parts are the same, so I assume it has the same issues.

The modifier mask is not being returned correctly during a 'drag-motion' event. After examining the code, it seems pretty clear what's happening.

gdk_window_get_pointer ends up calling some function, which ends up calling gdk_window_quartz_get_pointer_helper() in gdk/quartz/gdkwindow-quartz.c. The GdkModifierType parameter is set to the value of _gdk_quartz_events_get_current_event_mask(), which can be found in gdk/quartz/gdkevents-quartz.c . That function just returns _current_event_mask. The only place _current_event_mask is modified sets it using get_event_mask_from_ns_event(). 

When the event type is NSLeftMouseDragged, the event mask is set to GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON1_MASK . 

When the 'drag_motion' event occurs and I call window.get_pointer(), the modifier mask is GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD2_MASK  | GDK_MOD3_MASK | GDK_BUTTON1_MASK, which have *exactly* the same values as the constants set by NSLeftMouseDragged. Clearly the wrong constants are being set during the drag operation (or the _current_event_mask variable is being misused by the get_pointer code)

The same python code on Linux returns the correct modifier masks (eg, GdkModifierType instead of GdkEventMask) as expected.
Comment 1 Hans Breuer 2014-11-07 15:51:25 UTC
This bug was also found by clang:

gdkwindow-quartz.c:1956:11: warning: implicit conversion from enumeration type 'GdkEventMask' to
      different enumeration type 'GdkModifierType' [-Wenum-conversion]
  *mask = _gdk_quartz_events_get_current_event_mask ();
        ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

The effect in Dia was trouble resizing objects, because GDK_CONTROL_MASK was always set. Thus only the special resizing mode was available.
Comment 2 Hans Breuer 2014-11-07 15:57:09 UTC
Created attachment 290185 [details] [review]
patch: Deliver GdkModifierType values

The attached patch makes it work as expected for me. OK to commit?
Comment 3 Dustin Spicuzza 2015-12-14 04:56:09 UTC
I'm no longer using GTK 2 anymore, so I no longer personally care about this. I haven't checked the behavior on GTK3 yet.. so if it fixes it and the code hasn't changed much, probably a good patch to push in.
Comment 4 Matthias Clasen 2016-01-08 14:16:42 UTC
Review of attachment 290185 [details] [review]:

looks good to me