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.
This commit is contained in:
Emmanuele Bassi 2012-03-16 23:10:28 +00:00
parent f7735ff1ad
commit b6f5609b2f

View File

@ -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];