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 672193 - windows (including menus) shown multiple times don't get enter event if under mouse
windows (including menus) shown multiple times don't get enter event if under...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
unspecified
Other Mac OS
: Normal major
: ---
Assigned To: gtk-quartz maintainers
gtk-bugs
: 674124 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-03-15 21:16 UTC by Paul Davis
Modified: 2012-11-20 09:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Paul's patch, updated as mentioned in comment 4 (4.00 KB, patch)
2012-11-06 19:18 UTC, Michael Natterer
reviewed Details | Review

Description Paul Davis 2012-03-15 21:16:33 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.
Comment 1 Kristian Rietveld 2012-03-16 10:11:15 UTC
Which branch are we talking about?  Latest 2-24?  I do recall fixing issues like this, but will have to look again.
Comment 2 Paul Davis 2012-03-16 12:17:14 UTC
this is not fixed in 2-24. applying the patch makes it so.
Comment 3 Paul Davis 2012-03-16 12:18:27 UTC
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.
Comment 4 Kristian Rietveld 2012-07-29 18:34:43 UTC
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.
Comment 5 Michael Natterer 2012-11-06 18:50:09 UTC
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.
Comment 6 Michael Natterer 2012-11-06 19:18:06 UTC
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.
Comment 7 Kristian Rietveld 2012-11-17 13:29:52 UTC
*** Bug 674124 has been marked as a duplicate of this bug. ***
Comment 8 Kristian Rietveld 2012-11-17 13:33:46 UTC
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?
Comment 9 Kristian Rietveld 2012-11-17 13:39:46 UTC
Mitch: the GDK_NOTIFY_NONLINEAR patch fixes the remaining issues I was seeing in combo boxes.
Comment 10 Michael Natterer 2012-11-17 13:42:11 UTC
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.
Comment 11 Michael Natterer 2012-11-17 13:42:25 UTC
Err, yes, this patch :)
Comment 12 Michael Natterer 2012-11-20 09:47:29 UTC
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.