forked from enlightenment/efl
ecore_cocoa: use the right Cocoa notification handlers for focus events
Don't use NSAppKitDefined events subtype for focus events, which contain NULL window object most of the time. Use the NSWindowDelegate method designed for that purpose instead. It fixes random focus issues in windows which was caused by incorrect window identifier not found in ecore_evas_cocoa. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
382957c2b3
commit
c6945c075e
|
@ -379,9 +379,31 @@ ecore_cocoa_feed_events(void *anEvent)
|
|||
case NSAppKitDefined:
|
||||
{
|
||||
if ([event subtype] == NSApplicationActivatedEventType)
|
||||
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, NULL, NULL, NULL);
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *ev;
|
||||
|
||||
ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!ev)
|
||||
{
|
||||
pass = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
ev->wid = [event window];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, ev, NULL, NULL);
|
||||
}
|
||||
else if ([event subtype] == NSApplicationDeactivatedEventType)
|
||||
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, NULL, NULL, NULL);
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *ev;
|
||||
|
||||
ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!ev)
|
||||
{
|
||||
pass = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
ev->wid = [event window];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, ev, NULL, NULL);
|
||||
}
|
||||
pass = EINA_TRUE; // pass along AppKit events, for window manager
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,34 @@
|
|||
ecore_main_loop_iterate();
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *e;
|
||||
|
||||
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!e)
|
||||
{
|
||||
printf("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
|
||||
return;
|
||||
}
|
||||
e->wid = [notification object];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL);
|
||||
}
|
||||
|
||||
- (void)windowDidResignKey:(NSNotification *)notification
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *e;
|
||||
|
||||
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!e)
|
||||
{
|
||||
printf("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
|
||||
return;
|
||||
}
|
||||
e->wid = [notification object];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue