ecore_cocoa: remove Ecore_Cocoa_Event_Window

Create specific structures for each event:
- Ecore_Cocoa_Event_Window_Focused
- Ecore_Cocoa_Event_Window_Unfocused
- Ecore_Cocoa_Event_Window_Destroy

They are currently hold the same data, but this will allow not to break
the event protocol when future extensions will be needed.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Jean Guyomarc'h 2016-01-06 22:13:42 +01:00 committed by Cedric BAIL
parent e7dc1491a2
commit deb553d55e
3 changed files with 43 additions and 15 deletions

View File

@ -40,11 +40,11 @@
extern "C" { extern "C" {
#endif #endif
#ifndef _ECORE_COCOA_WINDOW_PREDEF
/** /**
* @typedef Ecore_Cocoa_Window * @typedef Ecore_Cocoa_Window
* Opaque handler to manipulate a Cocoa Window through Ecore * Opaque handler to manipulate a Cocoa Window through Ecore
*/ */
#ifndef _ECORE_COCOA_WINDOW_PREDEF
typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window; typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
#endif /* ! _ECORE_COCOA_WINDOW_PREDEF */ #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; 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; 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; 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; 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; 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 */ 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_Focused
struct _Ecore_Cocoa_Event_Window {
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; Ecore_Cocoa_Object *cocoa_window;
}; };

View File

@ -56,7 +56,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
- (void)windowWillClose:(NSNotification *) notification - (void)windowWillClose:(NSNotification *) notification
{ {
NSLog(@"window is going to be closed"); NSLog(@"window is going to be closed");
Ecore_Cocoa_Event_Window *event; Ecore_Cocoa_Event_Window_Destroy *event;
event = malloc(sizeof(*event)); event = malloc(sizeof(*event));
if (EINA_UNLIKELY(event == NULL)) if (EINA_UNLIKELY(event == NULL))
@ -99,7 +99,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
- (void)windowDidBecomeKey:(NSNotification *)notification - (void)windowDidBecomeKey:(NSNotification *)notification
{ {
Ecore_Cocoa_Event_Window *e; Ecore_Cocoa_Event_Window_Focused *e;
e = malloc(sizeof(*e)); e = malloc(sizeof(*e));
if (EINA_UNLIKELY(e == NULL)) if (EINA_UNLIKELY(e == NULL))
@ -123,7 +123,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
- (void)windowDidResignKey:(NSNotification *)notification - (void)windowDidResignKey:(NSNotification *)notification
{ {
Ecore_Cocoa_Event_Window *e; Ecore_Cocoa_Event_Window_Unfocused *e;
e = malloc(sizeof(*e)); e = malloc(sizeof(*e));
if (EINA_UNLIKELY(e == NULL)) if (EINA_UNLIKELY(e == NULL))

View File

@ -180,8 +180,8 @@ _ecore_evas_cocoa_match(Ecore_Cocoa_Object *cocoa_win)
static Eina_Bool static Eina_Bool
_ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) _ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{ {
Ecore_Cocoa_Event_Window *e = event; Ecore_Cocoa_Event_Window_Focused *e = event;
Ecore_Evas *ee; Ecore_Evas *ee;
ee = _ecore_evas_cocoa_match(e->cocoa_window); ee = _ecore_evas_cocoa_match(e->cocoa_window);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; 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 static Eina_Bool
_ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) _ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{ {
Ecore_Cocoa_Event_Window *e = event; Ecore_Cocoa_Event_Window_Unfocused *e = event;
Ecore_Evas *ee; Ecore_Evas *ee;
ee = _ecore_evas_cocoa_match(e->cocoa_window); ee = _ecore_evas_cocoa_match(e->cocoa_window);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON; 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 static Eina_Bool
_ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) _ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{ {
Ecore_Cocoa_Event_Window *e = event; Ecore_Cocoa_Event_Window_Destroy *e = event;
Ecore_Evas *ee; Ecore_Evas *ee;
DBG(""); DBG("");