GNOME Bugzilla – Bug 672193
windows (including menus) shown multiple times don't get enter event if under mouse
Last modified: 2012-11-20 09:47:29 UTC
quartz does not deliver an NSMouseEntered event to an NSWindow or NSView when it is shown directly under the mouse. there is a hack in GdkQuartzView that synthesizes an enter event when a view is first shown/added to a window. repeated hide/show pairings will result in a window that has the mouse inside it, but is not responsive to mouse motion because of the missing initial enter event. a patch for this problem can be found here: http://git.dronelabs.com/gtk+/patch/?id=a2b9d813967352bd2070e7c3a17834f1733921ac i've tested it and it appears certain to cure the problem.
Which branch are we talking about? Latest 2-24? I do recall fixing issues like this, but will have to look again.
this is not fixed in 2-24. applying the patch makes it so.
kristian - your fixes applied to the *first* show of the NSView - you added the hacks to GdkQuartzView that synthesize an enter event at that time. your fixes don't work if the window is hidden and then reshown, since none of the code path in GdkQuartzView that leads to updateTrackingRect is invoked then.
I plan to commit a patch that: - Resets InitialPositionKnown to NO on Hide, - also calls checkSendEnterNotify from showAndMakeKey which thus effectively also sends an enter notify on show after hide, after I have figured what is causing bug 674124.
Paul's patch seems to fix all menu and combo box misbehavior, and I haven't found any side effect so far. Also, it seems right to inject the enter event as low as possible, in order to avoid taking other code paths, the event coming in as if Quartz had sent it ensures that.
Created attachment 228303 [details] [review] Paul's patch, updated as mentioned in comment 4 Attached patch uses Paul's method of injecting the enter event directly into the Quartz event stream, instead of trying to synthesize it in GDK. This seems to magically fix all combo box popup weirdness, I guess some code is relying on a specfic order of events, or any other state imposed by the "proper" code path of events coming in the usual way. The patch also removes _gdk_quartz_events_send_enter_notify_event() which is now obsolete.
*** Bug 674124 has been marked as a duplicate of this bug. ***
Review of attachment 228303 [details] [review]: Okay, I agree that it seems better to insert the enter notify through Cocoa. This way, bug 674124 is fixed. The situation with combo box is definitely improved, but I can still trigger the broken behavior where the menu pops down instantly. ::: gdk/quartz/GdkQuartzWindow.c @@ +162,3 @@ + + event = [NSEvent enterExitEventWithType: NSMouseEntered + location: NSMakePoint(0, 0) Shouldn't we be passing in the correct coordinates? @@ +169,3 @@ + eventNumber: 0 + trackingNumber: [impl->view trackingRect] + userData: nil]; For the objective-C call, I prefer to drop the spaces after colons. All other calls are also formatted like this (for instance see the call below). ::: gdk/quartz/gdkevents-quartz.c @@ +554,3 @@ event->any.type = GDK_MOTION_NOTIFY; event->motion.window = window; + event->motion.time = get_time_from_ns_event ([NSApp currentEvent]); Is this related to this patch? If not, should we commit this separately?
Mitch: the GDK_NOTIFY_NONLINEAR patch fixes the remaining issues I was seeing in combo boxes.
I was actually about to add the space to all objc calls, because it gets much more readable. Only if you don't object of course :) I agree with your other comments. Combo boxes are totally fixed by the other patch I forgot to attach, we need to synthesize crossing events so they appear to be coming from another toplevel, not from the desktop. It makes absolutely no difference, except in the utterly ugly GtkMenu code which checks for this detail. We can't tell where the mouse is coming from anyway.
Err, yes, this patch :)
Fixed in master, gtk-3-6 and gtk-2-24, with kris' comments applied. The patches for gtk3 needed quite some editing, and combo boxes are not 100% fixed in gtk3, we probably lack some earlier commit that is in gtk-2-24: commit 35a9322e45bb403d34c9e4da036d9d8d559419fb Author: Michael Natterer <mitch@gimp.org> Date: Fri Nov 9 17:12:30 2012 +0100 quartz: always send GDK_NOTIFY_NONLINEAR crossing events so GtkMenu works properly. This is not right, but not more wrong than always sending GDK_NOTIFY_ANCESTOR either. commit 979e5061a040f8896f505ffbd230f52af2d61ded Author: Michael Natterer <mitch@lanedo.com> Date: Thu Nov 8 15:11:55 2012 +0100 Bug 672193 - windows (including menus) shown multiple times don't... Based on a patch from Paul Davis, inject synthetic enter events directly into the Quartz event stream, instead of trying to synthesize them in GDK. This seems to magically fix most combo box popup weirdness, I guess some code is relying on a specfic order of events, or any other state imposed by the "proper" code path of events coming in the usual way. The patch also removes _gdk_quartz_events_send_enter_notify_event() which is now obsolete.