summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-09-27 08:20:20 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-09-27 08:52:51 +0200
commite44c48b90408d2518e2708090796988cfd3cacea (patch)
treecbbead81224eaad20781c44a098c01bea4eec657
parentb93947e20646bce2f78a50abf5a076f1a2ae64fd (diff)
downloadefl-e44c48b90408d2518e2708090796988cfd3cacea.tar.gz
ecore_cocoa: upgrade API to macOS Sierra
Since macOS 10.12, several enumarations have been deprecated in favor of new ones, with more meaningful ones, which are defined in SDK 10.12.
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m70
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_app.m5
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_private.h33
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m10
4 files changed, 76 insertions, 42 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index 2cf1739e0c..0ab07e8ca3 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -95,11 +95,11 @@ _ecore_cocoa_event_modifiers(NSUInteger mod)
{
unsigned int modifiers = 0;
- if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
- if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
- if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
- if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
- if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
+ if (mod & NSEventModifierFlagShift) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
+ if (mod & NSEventModifierFlagShift) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
+ if (mod & NSEventModifierFlagOption) modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
+ if (mod & NSEventModifierFlagOption) modifiers |= ECORE_EVENT_MODIFIER_WIN;
+ if (mod & NSEventModifierFlagNumericPad) modifiers |= ECORE_EVENT_LOCK_NUM;
DBG("key modifiers: 0x%lx, %u", mod, modifiers);
return modifiers;
@@ -126,7 +126,7 @@ _ecore_cocoa_event_key(NSEvent *event,
ev = calloc(1, sizeof (Ecore_Event_Key));
if (!ev) return NULL;
- if (compose && keyType == NSKeyDown)
+ if (compose && (keyType == NSEventTypeKeyDown))
{
[edit interpretKeyEvents:[NSArray arrayWithObject:event]];
compose=EINA_FALSE;
@@ -160,7 +160,7 @@ _ecore_cocoa_event_key(NSEvent *event,
}
}
- if ([keycharRaw length] == 0 && keyType == NSKeyDown)
+ if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown))
{
compose=EINA_TRUE;
edit = [[event window] fieldEditor:YES forObject:nil];
@@ -185,26 +185,26 @@ _ecore_cocoa_feed_events(void *anEvent)
switch ([event type])
{
- case NSMouseMoved:
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
+ case NSEventTypeMouseMoved:
+ case NSEventTypeLeftMouseDragged:
+ case NSEventTypeRightMouseDragged:
+ case NSEventTypeOtherMouseDragged:
+ case NSEventTypeLeftMouseDown:
+ case NSEventTypeRightMouseDown:
+ case NSEventTypeOtherMouseDown:
+ case NSEventTypeLeftMouseUp:
+ case NSEventTypeRightMouseUp:
+ case NSEventTypeOtherMouseUp:
{
//mouse events are managed in EcoreCocoaWindow
return EINA_TRUE;
}
- case NSKeyDown:
+ case NSEventTypeKeyDown:
{
Ecore_Event_Key *ev;
NSUInteger flags = [event modifierFlags];
- if (flags & NSCommandKeyMask)
+ if (flags & NSEventModifierFlagOption)
{
NSString *keychar = [event charactersIgnoringModifiers];
if ([keychar characterAtIndex:0] == 'q')
@@ -215,25 +215,25 @@ _ecore_cocoa_feed_events(void *anEvent)
}
}
- ev = _ecore_cocoa_event_key(event, NSKeyDown, time);
+ ev = _ecore_cocoa_event_key(event, NSEventTypeKeyDown, time);
if (ev == NULL) return EINA_TRUE;
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
break;
}
- case NSKeyUp:
+ case NSEventTypeKeyUp:
{
Ecore_Event_Key *ev;
- ev = _ecore_cocoa_event_key(event, NSKeyUp, time);
+ ev = _ecore_cocoa_event_key(event, NSEventTypeKeyUp, time);
if (ev == NULL) return EINA_TRUE;
ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
break;
}
- case NSFlagsChanged:
+ case NSEventTypeFlagsChanged:
{
NSUInteger flags = [event modifierFlags];
@@ -244,15 +244,15 @@ _ecore_cocoa_feed_events(void *anEvent)
if (!evDown) return pass;
// Turn special key flags on
- if (flags & NSShiftKeyMask)
+ if (flags & NSEventModifierFlagShift)
evDown->key = "Shift_L";
- else if (flags & NSControlKeyMask)
+ else if (flags & NSEventModifierFlagShift)
evDown->key = "Control_L";
- else if (flags & NSAlternateKeyMask)
+ else if (flags & NSEventModifierFlagOption)
evDown->key = "Alt_L";
- else if (flags & NSCommandKeyMask)
+ else if (flags & NSEventModifierFlagOption)
evDown->key = "Super_L";
- else if (flags & NSAlphaShiftKeyMask)
+ else if (flags & NSEventModifierFlagCapsLock)
evDown->key = "Caps_Lock";
if (evDown->key)
@@ -276,15 +276,15 @@ _ecore_cocoa_feed_events(void *anEvent)
NSUInteger changed_flags = flags ^ old_flags;
// Turn special key flags off
- if (changed_flags & NSShiftKeyMask)
+ if (changed_flags & NSEventModifierFlagShift)
evUp->key = "Shift_L";
- else if (changed_flags & NSControlKeyMask)
+ else if (changed_flags & NSEventModifierFlagShift)
evUp->key = "Control_L";
- else if (changed_flags & NSAlternateKeyMask)
+ else if (changed_flags & NSEventModifierFlagOption)
evUp->key = "Alt_L";
- else if (changed_flags & NSCommandKeyMask)
+ else if (changed_flags & NSEventModifierFlagOption)
evUp->key = "Super_L";
- else if (changed_flags & NSAlphaShiftKeyMask)
+ else if (changed_flags & NSEventModifierFlagCapsLock)
evUp->key = "Caps_Lock";
if (evUp->key)
@@ -300,7 +300,7 @@ _ecore_cocoa_feed_events(void *anEvent)
break;
}
- case NSScrollWheel:
+ case NSEventTypeScrollWheel:
{
DBG("Scroll Wheel");
@@ -376,7 +376,7 @@ ecore_cocoa_titlebar_height_get(void)
NSRect frame = NSMakeRect(0, 0, 100, 100);
NSRect contentRect;
contentRect = [NSWindow contentRectForFrameRect:frame
- styleMask:NSTitledWindowMask];
+ styleMask:NSWindowStyleMaskTitled];
height = (frame.size.height - contentRect.size.height);
DBG("Titlebar Heigt : %d", height);
}
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_app.m b/src/lib/ecore_cocoa/ecore_cocoa_app.m
index 066d29f12e..04391f61ff 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_app.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_app.m
@@ -8,7 +8,7 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
@try {
NSEvent *e;
do {
- e = [NSApp nextEventMatchingMask:NSAnyEventMask
+ e = [NSApp nextEventMatchingMask:NSEventMaskAny
untilDate:[NSApp eventExpirationDate]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@@ -19,7 +19,8 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
/* Update (en/disable) the services menu's items */
NSEventType type = [e type];
- if (type != NSPeriodic && type != NSMouseMoved) {
+ if ((type != NSEventTypePeriodic) &&
+ (type != NSEventTypeMouseMoved)) {
[NSApp internalUpdate];
}
}
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_private.h b/src/lib/ecore_cocoa/ecore_cocoa_private.h
index 5a58bf51c3..478cadf57d 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_private.h
+++ b/src/lib/ecore_cocoa/ecore_cocoa_private.h
@@ -28,6 +28,39 @@ extern int _ecore_cocoa_log_domain;
#endif
#define CRI(...) EINA_LOG_DOM_CRIT(_ecore_cocoa_log_domain, __VA_ARGS__)
+/*
+ * macOS Sierra (10.12) deprecated enumeration types in profit to others,
+ * more meaningful ones.
+ */
+#ifndef __MAC_10_12
+# define NSWindowStyleMaskTitled NSTitledWindowMask
+# define NSWindowStyleMaskClosable NSClosableWindowMask
+# define NSWindowStyleMaskResizable NSResizableWindowMask
+# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
+# define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
+# define NSEventModifierFlagShift NSShiftKeyMask
+# define NSEventModifierFlagControl NSControlKeyMask
+# define NSEventModifierFlagOption NSAlternateKeyMask
+# define NSEventModifierFlagCommand NSCommandKeyMask
+# define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
+# define NSEventTypeScrollWheel NSScrollWheel
+# define NSEventMaskAny NSAnyEventMask
+# define NSEventTypePeriodic NSPeriodic
+# define NSEventTypeMouseMoved NSMouseMoved
+# define NSEventTypeRightMouseDown NSRightMouseDown
+# define NSEventTypeLeftMouseDown NSLeftMouseDown
+# define NSEventTypeOtherMouseDown NSOtherMouseDown
+# define NSEventTypeLeftMouseUp NSLeftMouseUp
+# define NSEventTypeRightMouseUp NSRightMouseUp
+# define NSEventTypeOtherMouseUp NSOtherMouseUp
+# define NSEventTypeKeyDown NSKeyDown
+# define NSEventTypeKeyUp NSKeyUp
+# define NSEventTypeFlagsChanged NSFlagsChanged
+# define NSEventTypeLeftMouseDragged NSLeftMouseDragged
+# define NSEventTypeRightMouseDragged NSRightMouseDragged
+# define NSEventTypeOtherMouseDragged NSOtherMouseDragged
+# define NSEventModifierFlagNumericPad NSNumericPadKeyMask
+#endif
struct _Ecore_Cocoa_Window
{
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 79a5f04700..126bf7fcea 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -41,7 +41,7 @@ static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
- (BOOL)isFullScreen
{
- return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
+ return (([self styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen);
}
- (BOOL)acceptsFirstResponder
@@ -331,10 +331,10 @@ ecore_cocoa_window_new(int x,
Ecore_Cocoa_Window *win;
EcoreCocoaWindow *window;
NSUInteger style =
- NSTitledWindowMask |
- NSClosableWindowMask |
- NSResizableWindowMask |
- NSMiniaturizableWindowMask;
+ NSWindowStyleMaskTitled |
+ NSWindowStyleMaskClosable |
+ NSWindowStyleMaskResizable |
+ NSWindowStyleMaskMiniaturizable;
window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, w, h)
styleMask:style