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" {
#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;
};

View File

@ -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))

View File

@ -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("");