GNOME Bugzilla – Bug 722815
gdk_window_get_pointer() returns GdkEventMask values instead of GdkModifierType during 'drag-motion' event on OSX
Last modified: 2016-01-13 04:08:55 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.
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.
Created attachment 290185 [details] [review] patch: Deliver GdkModifierType values The attached patch makes it work as expected for me. OK to commit?
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.
Review of attachment 290185 [details] [review]: looks good to me