diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m index ed7f6b02ae..c93a4b00b7 100644 --- a/src/lib/ecore_cocoa/ecore_cocoa.m +++ b/src/lib/ecore_cocoa/ecore_cocoa.m @@ -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; } diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m index 754caa8c0b..9739220b60 100644 --- a/src/lib/ecore_cocoa/ecore_cocoa_window.m +++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m @@ -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