diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h index 079500a355..f479e3d3c6 100644 --- a/src/lib/ecore_cocoa/Ecore_Cocoa.h +++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h @@ -40,11 +40,11 @@ extern "C" { #endif +#ifndef _ECORE_COCOA_WINDOW_PREDEF /** * @typedef Ecore_Cocoa_Window * Opaque handler to manipulate a Cocoa Window through Ecore */ -#ifndef _ECORE_COCOA_WINDOW_PREDEF typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window; #endif /* ! _ECORE_COCOA_WINDOW_PREDEF */ @@ -66,15 +66,34 @@ typedef void Ecore_Cocoa_Object; */ typedef struct _Ecore_Cocoa_Event_Window_Resize_Request Ecore_Cocoa_Event_Window_Resize_Request; -/** Event triggered when a window receives focus */ +/** + * @typedef Ecore_Cocoa_Event_Window_Focused + * Type of event thrown when a Cocoa window receives focus + */ +typedef struct _Ecore_Cocoa_Event_Window_Focused Ecore_Cocoa_Event_Window_Focused; + +/** + * @typedef Ecore_Cocoa_Event_Window_Unfocused + * Type of event thrown when a Cocoa window loses the focus + */ +typedef struct _Ecore_Cocoa_Event_Window_Unfocused Ecore_Cocoa_Event_Window_Unfocused; + +/** + * @typedef Ecore_Cocoa_Event_Window_Destroy + * Type of event thrown when a Cocoa window gets destoyed + */ +typedef struct _Ecore_Cocoa_Event_Window_Destroy Ecore_Cocoa_Event_Window_Destroy; + +/** Event triggered when a Cocoa window receives focus */ EAPI extern int ECORE_COCOA_EVENT_WINDOW_FOCUSED; -/** Event triggered when a window loses focus */ +/** Event triggered when a Cocoa window loses focus */ EAPI extern int ECORE_COCOA_EVENT_WINDOW_UNFOCUSED; -/** Event triggered when a window is resized */ +/** Event triggered when a Cocoa window is resized */ EAPI extern int ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST; +/** Event triggered when a Cocoa window get destroyed */ EAPI extern int ECORE_COCOA_EVENT_WINDOW_DESTROY; /** @@ -88,8 +107,17 @@ struct _Ecore_Cocoa_Event_Window_Resize_Request Ecore_Cocoa_Object *cocoa_window; /**< Handler of the Cocoa window */ }; -typedef struct _Ecore_Cocoa_Event_Window Ecore_Cocoa_Event_Window; -struct _Ecore_Cocoa_Event_Window +struct _Ecore_Cocoa_Event_Window_Focused +{ + Ecore_Cocoa_Object *cocoa_window; +}; + +struct _Ecore_Cocoa_Event_Window_Unfocused +{ + Ecore_Cocoa_Object *cocoa_window; +}; + +struct _Ecore_Cocoa_Event_Window_Destroy { Ecore_Cocoa_Object *cocoa_window; }; diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m index b57df81448..aef18da06e 100644 --- a/src/lib/ecore_cocoa/ecore_cocoa_window.m +++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m @@ -56,7 +56,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST]; - (void)windowWillClose:(NSNotification *) notification { NSLog(@"window is going to be closed"); - Ecore_Cocoa_Event_Window *event; + Ecore_Cocoa_Event_Window_Destroy *event; event = malloc(sizeof(*event)); if (EINA_UNLIKELY(event == NULL)) @@ -99,7 +99,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST]; - (void)windowDidBecomeKey:(NSNotification *)notification { - Ecore_Cocoa_Event_Window *e; + Ecore_Cocoa_Event_Window_Focused *e; e = malloc(sizeof(*e)); if (EINA_UNLIKELY(e == NULL)) @@ -123,7 +123,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST]; - (void)windowDidResignKey:(NSNotification *)notification { - Ecore_Cocoa_Event_Window *e; + Ecore_Cocoa_Event_Window_Unfocused *e; e = malloc(sizeof(*e)); if (EINA_UNLIKELY(e == NULL)) diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c index 7069079329..2fc1914783 100644 --- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c +++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c @@ -180,8 +180,8 @@ _ecore_evas_cocoa_match(Ecore_Cocoa_Object *cocoa_win) static Eina_Bool _ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Cocoa_Event_Window *e = event; - Ecore_Evas *ee; + Ecore_Cocoa_Event_Window_Focused *e = event; + Ecore_Evas *ee; ee = _ecore_evas_cocoa_match(e->cocoa_window); if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; @@ -196,8 +196,8 @@ _ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, static Eina_Bool _ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Cocoa_Event_Window *e = event; - Ecore_Evas *ee; + Ecore_Cocoa_Event_Window_Unfocused *e = event; + Ecore_Evas *ee; ee = _ecore_evas_cocoa_match(e->cocoa_window); if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; @@ -257,8 +257,8 @@ _ecore_evas_cocoa_event_window_resize(void *data EINA_UNUSED, int type EINA_UNUS static Eina_Bool _ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Cocoa_Event_Window *e = event; - Ecore_Evas *ee; + Ecore_Cocoa_Event_Window_Destroy *e = event; + Ecore_Evas *ee; DBG("");