ecore_cocoa: create a log domain and use Eina_Log.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Nicolas Aguirre 2015-01-29 17:08:23 +01:00 committed by Cedric BAIL
parent 61fbb2ffd9
commit 72baccaf44
3 changed files with 52 additions and 9 deletions

View File

@ -25,6 +25,8 @@ static int _ecore_cocoa_init_count = 0;
static int old_flags;
static int _ecore_cocoa_log_domain = -1;
EAPI int
ecore_cocoa_init(void)
{
@ -37,6 +39,13 @@ ecore_cocoa_init(void)
if (!ecore_event_init())
return --_ecore_cocoa_init_count;
_ecore_cocoa_log_domain = eina_log_domain_register("ecore_cocoa", ECORE_DEFAULT_LOG_COLOR);
if(_ecore_cocoa_log_domain < 0)
{
EINA_LOG_ERR("Unable to create a log domain for ecore_cocoa.");
return 0;
}
ECORE_COCOA_EVENT_GOT_FOCUS = ecore_event_type_new();
ECORE_COCOA_EVENT_LOST_FOCUS = ecore_event_type_new();
ECORE_COCOA_EVENT_RESIZE = ecore_event_type_new();
@ -64,6 +73,7 @@ ecore_cocoa_shutdown(void)
if (--_ecore_cocoa_init_count != 0)
return _ecore_cocoa_init_count;
eina_log_domain_unregister(_ecore_cocoa_log_domain);
ecore_event_shutdown();
return _ecore_cocoa_init_count;
@ -80,7 +90,7 @@ _ecore_cocoa_event_modifiers(unsigned int mod)
if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
printf("key modifiers: %d, %d\n", mod, modifiers);
DBG("key modifiers: %d, %d\n", mod, modifiers);
return modifiers;
}
@ -286,7 +296,7 @@ ecore_cocoa_feed_events(void *anEvent)
{
if (keystable[i].code == [keychar characterAtIndex:0])
{
printf("Key pressed : %s\n", keystable[i].name);
DBG("Key pressed : %s\n", keystable[i].name);
ev->keyname = keystable[i].name;
ev->key = keystable[i].name;
ev->string = keystable[i].compose;
@ -311,7 +321,7 @@ ecore_cocoa_feed_events(void *anEvent)
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
NSString *keychar = [event characters];
printf("Key Up\n");
DBG("Key Up\n");
ev = calloc(1, sizeof (Ecore_Event_Key));
if (!ev) return pass;
@ -432,7 +442,7 @@ ecore_cocoa_feed_events(void *anEvent)
}
case NSScrollWheel:
{
printf("Scroll Wheel\n");
DBG("Scroll Wheel\n");
break;
}
default:

View File

@ -1,6 +1,36 @@
#ifndef _ECORE_COCOA_PRIVATE_H
#define _ECORE_COCOA_PRIVATE_H
#include "ecore_cocoa_window.h"
extern int _ecore_cocoa_log_domain;
#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_ecore_cocoa_log_domain, __VA_ARGS__)
#ifdef DBG
# undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_ecore_cocoa_log_domain, __VA_ARGS__)
#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_ecore_cocoa_log_domain, __VA_ARGS__)
#ifdef WRN
# undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_ecore_cocoa_log_domain, __VA_ARGS__)
#ifdef CRI
# undef CRI
#endif
#define CRI(...) EINA_LOG_DOM_CRIT(_ecore_cocoa_log_domain, __VA_ARGS__)
struct _Ecore_Cocoa_Window
{
EcoreCocoaWindow *window;

View File

@ -4,6 +4,7 @@
#include <Ecore.h>
#include <Ecore_Cocoa.h>
#include "ecore_cocoa_private.h"
#import "ecore_cocoa_window.h"
@implementation EcoreCocoaWindow
@ -58,8 +59,7 @@
event = malloc(sizeof(Ecore_Cocoa_Event_Video_Resize));
if (event == NULL)
{
// FIXME Use Eina_Log
printf("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n");
DBG("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n");
return;
}
event->w = size.width;
@ -77,7 +77,7 @@
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!e)
{
printf("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
DBG("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
return;
}
e->wid = [notification object];
@ -91,7 +91,7 @@
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!e)
{
printf("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
DBG("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
return;
}
e->wid = [notification object];
@ -222,7 +222,7 @@ ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
{
if (!window || [window->window isVisible])
{
printf("Window(%p) is not visible\n", window->window);
DBG("Window(%p) is not visible\n", window->window);
return;
}
@ -276,5 +276,8 @@ Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *windo
{
if (!window)
return 0;
DBG("Return : %p", window->window);
return window->window;
}