GNOME Bugzilla – Bug 736702
GtkWindow event special logic ignores subclass handlers
Last modified: 2014-12-10 06:34:02 UTC
GtkWindow has a special case to handle certain events before the regular event processing, to deal with GTK+ grabs somewhere else preventing interactions with e.g. popovers or modal dialogs (see commit 36abb4b829). The special case will run GtkWindow's own implementation of the event handlers; this will break the case when a GtkWindow subclass overrides an event handler. To fix the issue, grab the correct event handler from the object class instead.
Created attachment 286240 [details] [review] patch
Note that this applies to 3.12, since the code in master uses gestures (I did not test whether this is still a problem).
Review of attachment 286240 [details] [review]: makes sense
I'm somewhat concerned that you can conceivably get GtkWindow handlers to run twice, one in the special case, and another time after bubbling. But that would involve somewhat misbehaving handlers that neither chain up consistently nor stop event propagation, so it's maybe not a big concern, plus it is somewhat tricky to protect against that. I'm attaching a patch for master that actually exposes the same potential behavior.
Created attachment 286323 [details] [review] gtkwindow: run ::event and specific handlers for EWMH action triggering events This gives an opportunity for implementations to handle these events differently, instead of hardcoding the WM-triggering behavior. gtk_window_event() only forwards events for WM management if the event widget is not the window (ie. caught when bubbling), so is safe to be called here without triggering gtk_window_handle_wm_event() twice. This commit is an adaption to master of https://bugzilla.gnome.org/show_bug.cgi?id=736702#c1 by Cosimo Cecchi.
Comment on attachment 286323 [details] [review] gtkwindow: run ::event and specific handlers for EWMH action triggering events Attachment 286323 [details] pushed as 6b7b55f - gtkwindow: run ::event and specific handlers for EWMH action triggering events
Since the upgrade to 3.14.1 https://git.gnome.org/browse/gtk+/commit/?id=6b7b55f9b2 broke my context menus. They get shown for a split second and disappear again. Removing the "return GDK_EVENT_STOP;" part fixes it.
I was using gtk_widget_event() to forward events to another widget (triggering the menu there). Using gtk_main_do_event() instead seems to fix it.
All the patches here got committed, closing as FIXED. If the problem mentioned by Christoph still applies to master, it should be addressed in another bug.