From b6f5609b2f3cc582e499e6d24ed05fe08807592d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 16 Mar 2012 23:10:28 +0000 Subject: [PATCH] osx/stage: Synthesize an enter event on show If the pointer is inside the window frame when it's shown then we need to synthesize and emit a NSMouseEnterEvent ourselves, as Quartz won't do it for us. This is a bit of a blind commit - but it's taken from an equivalent patch that has been verified to work in GDK. --- clutter/osx/clutter-stage-osx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index 8363ea3ec..259226d2c 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -368,6 +368,7 @@ clutter_stage_osx_show (ClutterStageWindow *stage_window, { ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window); BOOL isViewHidden; + NSPoint nspoint; CLUTTER_OSX_POOL_ALLOC(); @@ -390,6 +391,28 @@ clutter_stage_osx_show (ClutterStageWindow *stage_window, else [self->window orderFront: nil]; + /* If the window is placed directly under the mouse pointer, Quartz will + * not send a NSMouseEntered event; we can easily synthesize one ourselves + * though. + */ + nspoint = [self->window mouseLocationOutsideOfEventStream]; + if ([self->window mouse:nspoint inRect:[self->view frame]]) + { + NSEvent *event; + + event = [NSEvent enterExitEventWithType: NSMouseEntered + location: NSMakePoint(0, 0) + modifierFlags: 0 + timestamp: 0 + windowNumber: [self->window windowNumber] + context: NULL + eventNumber: 0 + trackingNumber: [self->view trackingRect] + userData: nil]; + + [NSApp postEvent:event atStart:NO]; + } + [self->view setHidden:isViewHidden]; [self->window setExcludedFromWindowsMenu:NO];