summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Perier <romain.perier@openwide.fr>2015-01-15 17:20:16 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 16:38:07 +0100
commitc6945c075ec108509a187d7ee1df735afa4bf0ff (patch)
tree188911a2f773621f6ed40500e879b92a22f70c65
parent382957c2b3d7f3c200072d5b1f00423978fafec2 (diff)
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>
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m26
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m28
2 files changed, 52 insertions, 2 deletions
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)
379 case NSAppKitDefined: 379 case NSAppKitDefined:
380 { 380 {
381 if ([event subtype] == NSApplicationActivatedEventType) 381 if ([event subtype] == NSApplicationActivatedEventType)
382 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, NULL, NULL, NULL); 382 {
383 Ecore_Cocoa_Event_Window *ev;
384
385 ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
386 if (!ev)
387 {
388 pass = EINA_FALSE;
389 break;
390 }
391 ev->wid = [event window];
392 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, ev, NULL, NULL);
393 }
383 else if ([event subtype] == NSApplicationDeactivatedEventType) 394 else if ([event subtype] == NSApplicationDeactivatedEventType)
384 ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, NULL, NULL, NULL); 395 {
396 Ecore_Cocoa_Event_Window *ev;
397
398 ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
399 if (!ev)
400 {
401 pass = EINA_FALSE;
402 break;
403 }
404 ev->wid = [event window];
405 ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, ev, NULL, NULL);
406 }
385 pass = EINA_TRUE; // pass along AppKit events, for window manager 407 pass = EINA_TRUE; // pass along AppKit events, for window manager
386 break; 408 break;
387 } 409 }
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 @@
69 ecore_main_loop_iterate(); 69 ecore_main_loop_iterate();
70} 70}
71 71
72- (void)windowDidBecomeKey:(NSNotification *)notification
73{
74 Ecore_Cocoa_Event_Window *e;
75
76 e = malloc(sizeof(Ecore_Cocoa_Event_Window));
77 if (!e)
78 {
79 printf("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
80 return;
81 }
82 e->wid = [notification object];
83 ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL);
84}
85
86- (void)windowDidResignKey:(NSNotification *)notification
87{
88 Ecore_Cocoa_Event_Window *e;
89
90 e = malloc(sizeof(Ecore_Cocoa_Event_Window));
91 if (!e)
92 {
93 printf("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
94 return;
95 }
96 e->wid = [notification object];
97 ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL);
98}
99
72@end 100@end
73 101
74 102