2010-03-27 11:28:50 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2014-06-08 12:50:42 -07:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "ecore_cocoa_window.h"
|
2014-09-03 11:34:52 -07:00
|
|
|
#import "ecore_cocoa_app.h"
|
2010-03-27 11:28:50 -07:00
|
|
|
|
|
|
|
#include <Eina.h>
|
|
|
|
|
|
|
|
#include <Ecore.h>
|
|
|
|
#include <Ecore_Input.h>
|
|
|
|
|
|
|
|
#include "Ecore_Cocoa.h"
|
2015-10-15 02:45:41 -07:00
|
|
|
|
|
|
|
#define _ECORE_COCOA_KEYS_MANUAL_GUARD_
|
|
|
|
#include "ecore_cocoa_keys.h"
|
|
|
|
#undef _ECORE_COCOA_KEYS_MANUAL_GUARD_
|
|
|
|
|
ecore_cocoa,ethumb: fix compiling after EAPI policy changes
Summary:
I went through a lot of undefined symbols while compiling ecore_evas_cocoa
module and ethumb-related binaries. E.g.:
Undefined symbols for architecture x86_64:
"_ECORE_COCOA_EVENT_EXPOSE", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ECORE_COCOA_EVENT_GOT_FOCUS", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ECORE_COCOA_EVENT_LOST_FOCUS", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ECORE_COCOA_EVENT_RESIZE", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ECORE_COCOA_EVENT_WINDOW_DESTROY", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ecore_cocoa_init", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ecore_cocoa_screen_size_get", referenced from:
__ecore_evas_screen_geometry_get in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
"_ecore_cocoa_shutdown", referenced from:
_ecore_evas_cocoa_new_internal in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
__ecore_evas_cocoa_free in modules_ecore_evas_engines_cocoa_module_la-ecore_evas_cocoa.o
Undefined symbols for architecture x86_64:
"_ethumb_calculate_aspect_from_ratio", referenced from:
__resize_movie in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_calculate_fill_from_ratio", referenced from:
__resize_movie in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_ecore_evas_get", referenced from:
__frame_decode_cb in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_evas_get", referenced from:
__thumb_generate in modules_ethumb_emotion_module_la-emotion.o
__finish_thumb_generation in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_finished_callback_call", referenced from:
__thumb_generate in modules_ethumb_emotion_module_la-emotion.o
__frame_decode_cb in modules_ethumb_emotion_module_la-emotion.o
__finish_thumb_generation in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_image_save", referenced from:
__frame_decode_cb in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_plugin_image_resize", referenced from:
__resize_movie in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_plugin_register", referenced from:
__module_init in modules_ethumb_emotion_module_la-emotion.o
"_ethumb_plugin_unregister", referenced from:
__module_shutdown in modules_ethumb_emotion_module_la-emotion.o
EAPI was not well re-defined in both cases. It has been handled in
ecore_cocoa_private.h and ethumb_private.h. These files must be included
after a main library header (because EAPI is undef there).
Reviewers: cedric
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2483
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2015-05-10 13:58:11 -07:00
|
|
|
#include "ecore_cocoa_private.h"
|
2011-11-02 12:20:09 -07:00
|
|
|
|
2016-01-06 12:56:09 -08:00
|
|
|
EAPI int ECORE_COCOA_EVENT_WINDOW_UNFOCUSED = 0;
|
|
|
|
EAPI int ECORE_COCOA_EVENT_WINDOW_FOCUSED = 0;
|
|
|
|
EAPI int ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST = 0;
|
2015-01-30 08:15:55 -08:00
|
|
|
EAPI int ECORE_COCOA_EVENT_WINDOW_DESTROY = 0;
|
2010-03-27 11:28:50 -07:00
|
|
|
|
|
|
|
static int _ecore_cocoa_init_count = 0;
|
|
|
|
|
|
|
|
static int old_flags;
|
|
|
|
|
2015-02-20 02:26:24 -08:00
|
|
|
int _ecore_cocoa_log_domain = -1;
|
2015-01-29 08:08:23 -08:00
|
|
|
|
2010-03-27 11:28:50 -07:00
|
|
|
EAPI int
|
2011-11-02 12:20:09 -07:00
|
|
|
ecore_cocoa_init(void)
|
2010-03-27 11:28:50 -07:00
|
|
|
{
|
|
|
|
if (++_ecore_cocoa_init_count != 1)
|
|
|
|
return _ecore_cocoa_init_count;
|
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
if (!ecore_init())
|
2010-03-27 11:28:50 -07:00
|
|
|
return --_ecore_cocoa_init_count;
|
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
if (!ecore_event_init())
|
|
|
|
return --_ecore_cocoa_init_count;
|
2011-11-02 12:20:09 -07:00
|
|
|
|
2015-02-20 05:53:00 -08:00
|
|
|
_ecore_cocoa_log_domain = eina_log_domain_register("ecore_cocoa", EINA_COLOR_BLUE);
|
2015-01-29 08:08:23 -08:00
|
|
|
if(_ecore_cocoa_log_domain < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Unable to create a log domain for ecore_cocoa.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-06 10:06:34 -07:00
|
|
|
DBG("");
|
2015-10-09 08:18:03 -07:00
|
|
|
|
2016-01-06 12:56:09 -08:00
|
|
|
ECORE_COCOA_EVENT_WINDOW_UNFOCUSED = ecore_event_type_new();
|
|
|
|
ECORE_COCOA_EVENT_WINDOW_FOCUSED = ecore_event_type_new();
|
|
|
|
ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST = ecore_event_type_new();
|
2015-01-30 08:15:55 -08:00
|
|
|
ECORE_COCOA_EVENT_WINDOW_DESTROY = ecore_event_type_new();
|
2015-10-09 08:18:03 -07:00
|
|
|
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
/* Init the Application handler */
|
|
|
|
[Ecore_Cocoa_Application sharedApplication];
|
|
|
|
[NSApp setDelegate:[Ecore_Cocoa_AppDelegate appDelegate]];
|
|
|
|
|
|
|
|
/* Start events monitoring */
|
|
|
|
[NSApp run];
|
|
|
|
|
2015-10-08 02:58:46 -07:00
|
|
|
if (!_ecore_cocoa_window_init())
|
|
|
|
return --_ecore_cocoa_init_count;
|
|
|
|
|
2010-03-27 11:28:50 -07:00
|
|
|
return _ecore_cocoa_init_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shuts down the Ecore_Cocoa library.
|
|
|
|
* @return @c The number of times the system has been initialised without
|
|
|
|
* being shut down.
|
|
|
|
* @ingroup Ecore_Cocoa_Library_Group
|
|
|
|
*/
|
|
|
|
EAPI int
|
|
|
|
ecore_cocoa_shutdown(void)
|
|
|
|
{
|
|
|
|
if (--_ecore_cocoa_init_count != 0)
|
|
|
|
return _ecore_cocoa_init_count;
|
|
|
|
|
2015-08-06 09:52:37 -07:00
|
|
|
DBG("Ecore Cocoa shutdown");
|
|
|
|
|
2017-03-09 16:10:22 -08:00
|
|
|
ecore_event_type_flush(ECORE_COCOA_EVENT_WINDOW_UNFOCUSED,
|
|
|
|
ECORE_COCOA_EVENT_WINDOW_FOCUSED,
|
|
|
|
ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST,
|
|
|
|
ECORE_COCOA_EVENT_WINDOW_DESTROY);
|
|
|
|
|
2015-01-29 08:08:23 -08:00
|
|
|
eina_log_domain_unregister(_ecore_cocoa_log_domain);
|
2010-03-27 11:28:50 -07:00
|
|
|
ecore_event_shutdown();
|
|
|
|
|
|
|
|
return _ecore_cocoa_init_count;
|
|
|
|
}
|
|
|
|
|
2016-10-08 13:29:08 -07:00
|
|
|
unsigned int
|
|
|
|
ecore_cocoa_event_modifiers(NSUInteger mod)
|
2014-06-08 12:50:42 -07:00
|
|
|
{
|
|
|
|
unsigned int modifiers = 0;
|
|
|
|
|
2016-09-26 23:20:20 -07:00
|
|
|
if (mod & NSEventModifierFlagShift) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
|
2016-10-08 13:20:28 -07:00
|
|
|
if (mod & NSEventModifierFlagControl) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
|
2016-09-26 23:20:20 -07:00
|
|
|
if (mod & NSEventModifierFlagOption) modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
|
2016-10-08 13:20:28 -07:00
|
|
|
if (mod & NSEventModifierFlagCommand) modifiers |= ECORE_EVENT_MODIFIER_WIN;
|
2016-09-26 23:20:20 -07:00
|
|
|
if (mod & NSEventModifierFlagNumericPad) modifiers |= ECORE_EVENT_LOCK_NUM;
|
2016-10-08 13:20:28 -07:00
|
|
|
if (mod & NSEventModifierFlagCapsLock) modifiers |= ECORE_EVENT_LOCK_CAPS;
|
2014-06-08 12:50:42 -07:00
|
|
|
|
2015-10-13 06:20:27 -07:00
|
|
|
DBG("key modifiers: 0x%lx, %u", mod, modifiers);
|
2014-06-08 12:50:42 -07:00
|
|
|
return modifiers;
|
|
|
|
}
|
|
|
|
|
2015-02-19 07:34:33 -08:00
|
|
|
|
2015-10-12 09:49:46 -07:00
|
|
|
static Ecore_Event_Key*
|
2015-10-13 06:20:27 -07:00
|
|
|
_ecore_cocoa_event_key(NSEvent *event,
|
2015-10-15 02:13:53 -07:00
|
|
|
NSEventType keyType,
|
|
|
|
unsigned int time)
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
|
|
|
static Eina_Bool compose = EINA_FALSE;
|
|
|
|
static NSText *edit;
|
|
|
|
unsigned int i;
|
2016-10-30 08:35:56 -07:00
|
|
|
int kchar = -1;
|
2015-02-19 07:34:33 -08:00
|
|
|
|
|
|
|
Ecore_Event_Key *ev;
|
|
|
|
|
|
|
|
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
|
|
|
|
NSString *keychar = [event charactersIgnoringModifiers];
|
|
|
|
NSString *keycharRaw = [event characters];
|
|
|
|
|
2015-10-13 06:20:27 -07:00
|
|
|
DBG("Event Key, keyType : %lu", keyType);
|
2015-08-06 09:52:37 -07:00
|
|
|
|
2016-10-30 08:34:35 -07:00
|
|
|
ev = calloc(1, sizeof(*ev));
|
|
|
|
if (EINA_UNLIKELY(!ev)) return NULL;
|
2015-02-19 07:34:33 -08:00
|
|
|
|
2016-09-26 23:20:20 -07:00
|
|
|
if (compose && (keyType == NSEventTypeKeyDown))
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
|
|
|
[edit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
2016-10-30 08:34:35 -07:00
|
|
|
compose = EINA_FALSE;
|
2015-02-19 07:34:33 -08:00
|
|
|
}
|
|
|
|
|
2015-10-15 02:13:53 -07:00
|
|
|
ev->timestamp = time;
|
2016-10-08 13:29:08 -07:00
|
|
|
ev->modifiers = ecore_cocoa_event_modifiers([event modifierFlags]);
|
2015-02-19 07:34:33 -08:00
|
|
|
|
|
|
|
ev->keycode = event.keyCode;
|
|
|
|
ev->string = [keycharRaw cStringUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
ev->compose = ev->string;
|
|
|
|
|
|
|
|
ev->window = (Ecore_Window)window.ecore_window_data;
|
|
|
|
ev->event_window = ev->window;
|
|
|
|
|
2016-10-30 08:35:56 -07:00
|
|
|
/*
|
|
|
|
* Try to look for the keychar data if available.
|
|
|
|
* If not, try the raw keychar.
|
|
|
|
*/
|
2015-02-19 07:34:33 -08:00
|
|
|
if ([keychar length] > 0)
|
2016-10-30 08:35:56 -07:00
|
|
|
kchar = [keychar characterAtIndex: 0];
|
|
|
|
if ((kchar < 0) && ([keycharRaw length] > 0))
|
|
|
|
kchar = [keycharRaw characterAtIndex: 0];
|
|
|
|
|
|
|
|
if (kchar >= 0)
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
2016-10-30 08:34:35 -07:00
|
|
|
for (i = 0; i < EINA_C_ARRAY_LENGTH(keystable); ++i)
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
2016-10-30 08:35:56 -07:00
|
|
|
if (keystable[i].code == kchar)
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
|
|
|
ev->keyname = keystable[i].name;
|
|
|
|
ev->key = ev->keyname;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-10-30 08:35:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fallback */
|
|
|
|
if (!ev->keyname)
|
|
|
|
{
|
|
|
|
ev->keyname = "";
|
|
|
|
ev->key = "";
|
2015-02-19 07:34:33 -08:00
|
|
|
}
|
|
|
|
|
2016-10-30 08:34:35 -07:00
|
|
|
if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))
|
2015-02-19 07:34:33 -08:00
|
|
|
{
|
2016-10-30 08:34:35 -07:00
|
|
|
compose = EINA_TRUE;
|
|
|
|
edit = [[event window] fieldEditor:YES forObject:nil];
|
2015-02-19 07:34:33 -08:00
|
|
|
[edit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
|
|
|
free(ev);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ev;
|
|
|
|
}
|
|
|
|
|
2015-10-15 05:06:13 -07:00
|
|
|
Eina_Bool
|
|
|
|
_ecore_cocoa_feed_events(void *anEvent)
|
2010-03-27 11:28:50 -07:00
|
|
|
{
|
2014-09-03 11:34:52 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(anEvent, EINA_FALSE);
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
NSEvent *event = anEvent;
|
2010-03-27 11:28:50 -07:00
|
|
|
unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
|
2014-09-03 11:34:52 -07:00
|
|
|
Eina_Bool pass = EINA_FALSE;
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2016-10-30 08:34:35 -07:00
|
|
|
DBG("Feed events, event type ; %lx", [event type]);
|
2015-08-06 09:52:37 -07:00
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
switch ([event type])
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
2016-09-26 23:20:20 -07:00
|
|
|
case NSEventTypeMouseMoved:
|
|
|
|
case NSEventTypeLeftMouseDragged:
|
|
|
|
case NSEventTypeRightMouseDragged:
|
|
|
|
case NSEventTypeOtherMouseDragged:
|
|
|
|
case NSEventTypeLeftMouseDown:
|
|
|
|
case NSEventTypeRightMouseDown:
|
|
|
|
case NSEventTypeOtherMouseDown:
|
|
|
|
case NSEventTypeLeftMouseUp:
|
|
|
|
case NSEventTypeRightMouseUp:
|
|
|
|
case NSEventTypeOtherMouseUp:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
|
|
|
//mouse events are managed in EcoreCocoaWindow
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2016-09-26 23:20:20 -07:00
|
|
|
case NSEventTypeKeyDown:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
|
|
|
Ecore_Event_Key *ev;
|
2016-09-23 01:49:34 -07:00
|
|
|
NSUInteger flags = [event modifierFlags];
|
|
|
|
|
2016-10-30 08:18:41 -07:00
|
|
|
if (flags & NSEventModifierFlagCommand)
|
2016-09-23 01:49:34 -07:00
|
|
|
{
|
|
|
|
NSString *keychar = [event charactersIgnoringModifiers];
|
|
|
|
if ([keychar characterAtIndex:0] == 'q')
|
|
|
|
{
|
|
|
|
[NSApp performSelector:@selector(terminate:)
|
|
|
|
withObject:nil afterDelay:0.0];
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2016-09-26 23:20:20 -07:00
|
|
|
ev = _ecore_cocoa_event_key(event, NSEventTypeKeyDown, time);
|
2015-08-06 09:52:37 -07:00
|
|
|
if (ev == NULL) return EINA_TRUE;
|
2015-01-22 02:24:42 -08:00
|
|
|
|
2015-08-06 09:52:37 -07:00
|
|
|
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2015-08-06 09:52:37 -07:00
|
|
|
break;
|
|
|
|
}
|
2016-09-26 23:20:20 -07:00
|
|
|
case NSEventTypeKeyUp:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
|
|
|
Ecore_Event_Key *ev;
|
2013-12-10 15:13:59 -08:00
|
|
|
|
2016-09-26 23:20:20 -07:00
|
|
|
ev = _ecore_cocoa_event_key(event, NSEventTypeKeyUp, time);
|
2015-08-06 09:52:37 -07:00
|
|
|
if (ev == NULL) return EINA_TRUE;
|
2014-06-08 12:50:42 -07:00
|
|
|
|
2015-08-06 09:52:37 -07:00
|
|
|
ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2015-08-06 09:52:37 -07:00
|
|
|
break;
|
|
|
|
}
|
2016-09-26 23:20:20 -07:00
|
|
|
case NSEventTypeFlagsChanged:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
2015-10-14 04:39:39 -07:00
|
|
|
NSUInteger flags = [event modifierFlags];
|
2015-08-06 09:52:37 -07:00
|
|
|
|
|
|
|
Ecore_Event_Key *evDown = NULL;
|
|
|
|
Ecore_Event_Key *evUp = NULL;
|
|
|
|
|
|
|
|
evDown = calloc(1, sizeof (Ecore_Event_Key));
|
|
|
|
if (!evDown) return pass;
|
|
|
|
|
|
|
|
// Turn special key flags on
|
2016-09-26 23:20:20 -07:00
|
|
|
if (flags & NSEventModifierFlagShift)
|
2015-08-06 09:52:37 -07:00
|
|
|
evDown->key = "Shift_L";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (flags & NSEventModifierFlagControl)
|
2015-08-06 09:52:37 -07:00
|
|
|
evDown->key = "Control_L";
|
2016-09-26 23:20:20 -07:00
|
|
|
else if (flags & NSEventModifierFlagOption)
|
2015-08-06 09:52:37 -07:00
|
|
|
evDown->key = "Alt_L";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (flags & NSEventModifierFlagCommand)
|
2015-08-06 09:52:37 -07:00
|
|
|
evDown->key = "Super_L";
|
2016-09-26 23:20:20 -07:00
|
|
|
else if (flags & NSEventModifierFlagCapsLock)
|
2015-08-06 09:52:37 -07:00
|
|
|
evDown->key = "Caps_Lock";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (flags & NSEventModifierFlagNumericPad)
|
|
|
|
evDown->key = "Num_Lock";
|
2015-08-06 09:52:37 -07:00
|
|
|
|
|
|
|
if (evDown->key)
|
|
|
|
{
|
|
|
|
evDown->keyname = evDown->key;
|
|
|
|
evDown->timestamp = time;
|
|
|
|
evDown->string = NULL;
|
|
|
|
ecore_event_add(ECORE_EVENT_KEY_DOWN, evDown, NULL, NULL);
|
|
|
|
old_flags = flags;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(evDown);
|
|
|
|
|
|
|
|
evUp = calloc(1, sizeof (Ecore_Event_Key));
|
|
|
|
if (!evUp)
|
|
|
|
{
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
2015-10-14 04:39:39 -07:00
|
|
|
NSUInteger changed_flags = flags ^ old_flags;
|
2015-08-06 09:52:37 -07:00
|
|
|
|
|
|
|
// Turn special key flags off
|
2016-09-26 23:20:20 -07:00
|
|
|
if (changed_flags & NSEventModifierFlagShift)
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->key = "Shift_L";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (changed_flags & NSEventModifierFlagControl)
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->key = "Control_L";
|
2016-09-26 23:20:20 -07:00
|
|
|
else if (changed_flags & NSEventModifierFlagOption)
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->key = "Alt_L";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (changed_flags & NSEventModifierFlagCommand)
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->key = "Super_L";
|
2016-09-26 23:20:20 -07:00
|
|
|
else if (changed_flags & NSEventModifierFlagCapsLock)
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->key = "Caps_Lock";
|
2016-10-08 13:20:28 -07:00
|
|
|
else if (changed_flags & NSEventModifierFlagNumericPad)
|
|
|
|
evUp->key = "Num_Lock";
|
2015-08-06 09:52:37 -07:00
|
|
|
|
|
|
|
if (evUp->key)
|
|
|
|
{
|
2016-08-30 07:12:47 -07:00
|
|
|
evUp->keyname = evUp->key;
|
2015-08-06 09:52:37 -07:00
|
|
|
evUp->timestamp = time;
|
|
|
|
evUp->string = NULL;
|
|
|
|
ecore_event_add(ECORE_EVENT_KEY_UP, evUp, NULL, NULL);
|
|
|
|
old_flags = flags;
|
|
|
|
break;
|
|
|
|
}
|
2016-08-26 07:13:18 -07:00
|
|
|
free(evUp);
|
2015-08-06 09:52:37 -07:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-09-26 23:20:20 -07:00
|
|
|
case NSEventTypeScrollWheel:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
|
|
|
DBG("Scroll Wheel");
|
|
|
|
|
|
|
|
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
|
|
|
|
Ecore_Event_Mouse_Wheel *ev;
|
|
|
|
float dx, dy = 0;
|
|
|
|
|
2016-04-20 05:33:20 -07:00
|
|
|
ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
|
2015-08-06 09:52:37 -07:00
|
|
|
if (!ev) return pass;
|
|
|
|
|
|
|
|
if ([event hasPreciseScrollingDeltas])
|
|
|
|
{
|
|
|
|
dx = -[event scrollingDeltaX];
|
|
|
|
dy = -[event scrollingDeltaY];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dx = -[event deltaX];
|
|
|
|
dy = -[event deltaY];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ev->window = (Ecore_Window)window.ecore_window_data;
|
|
|
|
ev->event_window = ev->window;
|
2016-10-08 13:29:08 -07:00
|
|
|
ev->modifiers = ecore_cocoa_event_modifiers([event modifierFlags]);
|
2015-08-06 09:52:37 -07:00
|
|
|
ev->timestamp = time;
|
|
|
|
if (dy != 0)
|
|
|
|
{
|
|
|
|
ev->z = (dy > 0) ? 1 : -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ev->z = (dx > 0) ? 1 : -1;
|
|
|
|
}
|
|
|
|
ev->direction = (dy != 0) ? 0 : 1;
|
|
|
|
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2010-03-27 11:28:50 -07:00
|
|
|
default:
|
2015-08-06 09:52:37 -07:00
|
|
|
{
|
|
|
|
pass = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-03-27 11:28:50 -07:00
|
|
|
|
2014-09-03 11:34:52 -07:00
|
|
|
return pass;
|
2010-03-27 11:28:50 -07:00
|
|
|
}
|
2014-06-08 12:50:42 -07:00
|
|
|
|
|
|
|
EAPI void
|
2015-08-06 10:06:34 -07:00
|
|
|
ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen EINA_UNUSED, int *w, int *h)
|
2014-06-08 12:50:42 -07:00
|
|
|
{
|
|
|
|
NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size;
|
|
|
|
|
|
|
|
if (w) *w = (int)pt.width;
|
|
|
|
if (h) *h = (int)pt.height;
|
2016-06-04 06:58:27 -07:00
|
|
|
|
2015-08-06 10:06:34 -07:00
|
|
|
DBG("Screen size get : %dx%d", (int)pt.width, (int)pt.height);
|
2014-06-08 12:50:42 -07:00
|
|
|
}
|
2014-07-10 11:04:24 -07:00
|
|
|
|
|
|
|
EAPI int
|
|
|
|
ecore_cocoa_titlebar_height_get(void)
|
|
|
|
{
|
|
|
|
static int height = -1;
|
|
|
|
|
|
|
|
if (height == -1)
|
|
|
|
{
|
|
|
|
NSRect frame = NSMakeRect(0, 0, 100, 100);
|
|
|
|
NSRect contentRect;
|
|
|
|
contentRect = [NSWindow contentRectForFrameRect:frame
|
2016-09-26 23:20:20 -07:00
|
|
|
styleMask:NSWindowStyleMaskTitled];
|
2014-07-10 11:04:24 -07:00
|
|
|
height = (frame.size.height - contentRect.size.height);
|
2015-08-06 09:52:37 -07:00
|
|
|
DBG("Titlebar Heigt : %d", height);
|
2014-07-10 11:04:24 -07:00
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
2016-10-02 05:22:53 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_cocoa_terminate_cb_set(Ecore_Cocoa_Terminate_Cb cb)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(cb);
|
|
|
|
[NSApp setTerminateCb: cb];
|
|
|
|
}
|