diff options
author | Jean Guyomarc'h <jean@guyomarch.bzh> | 2016-09-27 08:20:20 +0200 |
---|---|---|
committer | Jean Guyomarc'h <jean@guyomarch.bzh> | 2016-09-27 08:52:51 +0200 |
commit | e44c48b90408d2518e2708090796988cfd3cacea (patch) | |
tree | cbbead81224eaad20781c44a098c01bea4eec657 | |
parent | b93947e20646bce2f78a50abf5a076f1a2ae64fd (diff) |
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.m | 70 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_app.m | 5 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_private.h | 33 | ||||
-rw-r--r-- | src/lib/ecore_cocoa/ecore_cocoa_window.m | 10 |
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) | |||
95 | { | 95 | { |
96 | unsigned int modifiers = 0; | 96 | unsigned int modifiers = 0; |
97 | 97 | ||
98 | if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT; | 98 | if (mod & NSEventModifierFlagShift) modifiers |= ECORE_EVENT_MODIFIER_SHIFT; |
99 | if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL; | 99 | if (mod & NSEventModifierFlagShift) modifiers |= ECORE_EVENT_MODIFIER_CTRL; |
100 | if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALTGR; | 100 | if (mod & NSEventModifierFlagOption) modifiers |= ECORE_EVENT_MODIFIER_ALTGR; |
101 | if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN; | 101 | if (mod & NSEventModifierFlagOption) modifiers |= ECORE_EVENT_MODIFIER_WIN; |
102 | if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM; | 102 | if (mod & NSEventModifierFlagNumericPad) modifiers |= ECORE_EVENT_LOCK_NUM; |
103 | 103 | ||
104 | DBG("key modifiers: 0x%lx, %u", mod, modifiers); | 104 | DBG("key modifiers: 0x%lx, %u", mod, modifiers); |
105 | return modifiers; | 105 | return modifiers; |
@@ -126,7 +126,7 @@ _ecore_cocoa_event_key(NSEvent *event, | |||
126 | ev = calloc(1, sizeof (Ecore_Event_Key)); | 126 | ev = calloc(1, sizeof (Ecore_Event_Key)); |
127 | if (!ev) return NULL; | 127 | if (!ev) return NULL; |
128 | 128 | ||
129 | if (compose && keyType == NSKeyDown) | 129 | if (compose && (keyType == NSEventTypeKeyDown)) |
130 | { | 130 | { |
131 | [edit interpretKeyEvents:[NSArray arrayWithObject:event]]; | 131 | [edit interpretKeyEvents:[NSArray arrayWithObject:event]]; |
132 | compose=EINA_FALSE; | 132 | compose=EINA_FALSE; |
@@ -160,7 +160,7 @@ _ecore_cocoa_event_key(NSEvent *event, | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | if ([keycharRaw length] == 0 && keyType == NSKeyDown) | 163 | if (([keycharRaw length] == 0) && (keyType == NSEventTypeKeyDown)) |
164 | { | 164 | { |
165 | compose=EINA_TRUE; | 165 | compose=EINA_TRUE; |
166 | edit = [[event window] fieldEditor:YES forObject:nil]; | 166 | edit = [[event window] fieldEditor:YES forObject:nil]; |
@@ -185,26 +185,26 @@ _ecore_cocoa_feed_events(void *anEvent) | |||
185 | 185 | ||
186 | switch ([event type]) | 186 | switch ([event type]) |
187 | { | 187 | { |
188 | case NSMouseMoved: | 188 | case NSEventTypeMouseMoved: |
189 | case NSLeftMouseDragged: | 189 | case NSEventTypeLeftMouseDragged: |
190 | case NSRightMouseDragged: | 190 | case NSEventTypeRightMouseDragged: |
191 | case NSOtherMouseDragged: | 191 | case NSEventTypeOtherMouseDragged: |
192 | case NSLeftMouseDown: | 192 | case NSEventTypeLeftMouseDown: |
193 | case NSRightMouseDown: | 193 | case NSEventTypeRightMouseDown: |
194 | case NSOtherMouseDown: | 194 | case NSEventTypeOtherMouseDown: |
195 | case NSLeftMouseUp: | 195 | case NSEventTypeLeftMouseUp: |
196 | case NSRightMouseUp: | 196 | case NSEventTypeRightMouseUp: |
197 | case NSOtherMouseUp: | 197 | case NSEventTypeOtherMouseUp: |
198 | { | 198 | { |
199 | //mouse events are managed in EcoreCocoaWindow | 199 | //mouse events are managed in EcoreCocoaWindow |
200 | return EINA_TRUE; | 200 | return EINA_TRUE; |
201 | } | 201 | } |
202 | case NSKeyDown: | 202 | case NSEventTypeKeyDown: |
203 | { | 203 | { |
204 | Ecore_Event_Key *ev; | 204 | Ecore_Event_Key *ev; |
205 | NSUInteger flags = [event modifierFlags]; | 205 | NSUInteger flags = [event modifierFlags]; |
206 | 206 | ||
207 | if (flags & NSCommandKeyMask) | 207 | if (flags & NSEventModifierFlagOption) |
208 | { | 208 | { |
209 | NSString *keychar = [event charactersIgnoringModifiers]; | 209 | NSString *keychar = [event charactersIgnoringModifiers]; |
210 | if ([keychar characterAtIndex:0] == 'q') | 210 | if ([keychar characterAtIndex:0] == 'q') |
@@ -215,25 +215,25 @@ _ecore_cocoa_feed_events(void *anEvent) | |||
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | ev = _ecore_cocoa_event_key(event, NSKeyDown, time); | 218 | ev = _ecore_cocoa_event_key(event, NSEventTypeKeyDown, time); |
219 | if (ev == NULL) return EINA_TRUE; | 219 | if (ev == NULL) return EINA_TRUE; |
220 | 220 | ||
221 | ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); | 221 | ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); |
222 | 222 | ||
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | case NSKeyUp: | 225 | case NSEventTypeKeyUp: |
226 | { | 226 | { |
227 | Ecore_Event_Key *ev; | 227 | Ecore_Event_Key *ev; |
228 | 228 | ||
229 | ev = _ecore_cocoa_event_key(event, NSKeyUp, time); | 229 | ev = _ecore_cocoa_event_key(event, NSEventTypeKeyUp, time); |
230 | if (ev == NULL) return EINA_TRUE; | 230 | if (ev == NULL) return EINA_TRUE; |
231 | 231 | ||
232 | ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); | 232 | ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); |
233 | 233 | ||
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | case NSFlagsChanged: | 236 | case NSEventTypeFlagsChanged: |
237 | { | 237 | { |
238 | NSUInteger flags = [event modifierFlags]; | 238 | NSUInteger flags = [event modifierFlags]; |
239 | 239 | ||
@@ -244,15 +244,15 @@ _ecore_cocoa_feed_events(void *anEvent) | |||
244 | if (!evDown) return pass; | 244 | if (!evDown) return pass; |
245 | 245 | ||
246 | // Turn special key flags on | 246 | // Turn special key flags on |
247 | if (flags & NSShiftKeyMask) | 247 | if (flags & NSEventModifierFlagShift) |
248 | evDown->key = "Shift_L"; | 248 | evDown->key = "Shift_L"; |
249 | else if (flags & NSControlKeyMask) | 249 | else if (flags & NSEventModifierFlagShift) |
250 | evDown->key = "Control_L"; | 250 | evDown->key = "Control_L"; |
251 | else if (flags & NSAlternateKeyMask) | 251 | else if (flags & NSEventModifierFlagOption) |
252 | evDown->key = "Alt_L"; | 252 | evDown->key = "Alt_L"; |
253 | else if (flags & NSCommandKeyMask) | 253 | else if (flags & NSEventModifierFlagOption) |
254 | evDown->key = "Super_L"; | 254 | evDown->key = "Super_L"; |
255 | else if (flags & NSAlphaShiftKeyMask) | 255 | else if (flags & NSEventModifierFlagCapsLock) |
256 | evDown->key = "Caps_Lock"; | 256 | evDown->key = "Caps_Lock"; |
257 | 257 | ||
258 | if (evDown->key) | 258 | if (evDown->key) |
@@ -276,15 +276,15 @@ _ecore_cocoa_feed_events(void *anEvent) | |||
276 | NSUInteger changed_flags = flags ^ old_flags; | 276 | NSUInteger changed_flags = flags ^ old_flags; |
277 | 277 | ||
278 | // Turn special key flags off | 278 | // Turn special key flags off |
279 | if (changed_flags & NSShiftKeyMask) | 279 | if (changed_flags & NSEventModifierFlagShift) |
280 | evUp->key = "Shift_L"; | 280 | evUp->key = "Shift_L"; |
281 | else if (changed_flags & NSControlKeyMask) | 281 | else if (changed_flags & NSEventModifierFlagShift) |
282 | evUp->key = "Control_L"; | 282 | evUp->key = "Control_L"; |
283 | else if (changed_flags & NSAlternateKeyMask) | 283 | else if (changed_flags & NSEventModifierFlagOption) |
284 | evUp->key = "Alt_L"; | 284 | evUp->key = "Alt_L"; |
285 | else if (changed_flags & NSCommandKeyMask) | 285 | else if (changed_flags & NSEventModifierFlagOption) |
286 | evUp->key = "Super_L"; | 286 | evUp->key = "Super_L"; |
287 | else if (changed_flags & NSAlphaShiftKeyMask) | 287 | else if (changed_flags & NSEventModifierFlagCapsLock) |
288 | evUp->key = "Caps_Lock"; | 288 | evUp->key = "Caps_Lock"; |
289 | 289 | ||
290 | if (evUp->key) | 290 | if (evUp->key) |
@@ -300,7 +300,7 @@ _ecore_cocoa_feed_events(void *anEvent) | |||
300 | 300 | ||
301 | break; | 301 | break; |
302 | } | 302 | } |
303 | case NSScrollWheel: | 303 | case NSEventTypeScrollWheel: |
304 | { | 304 | { |
305 | DBG("Scroll Wheel"); | 305 | DBG("Scroll Wheel"); |
306 | 306 | ||
@@ -376,7 +376,7 @@ ecore_cocoa_titlebar_height_get(void) | |||
376 | NSRect frame = NSMakeRect(0, 0, 100, 100); | 376 | NSRect frame = NSMakeRect(0, 0, 100, 100); |
377 | NSRect contentRect; | 377 | NSRect contentRect; |
378 | contentRect = [NSWindow contentRectForFrameRect:frame | 378 | contentRect = [NSWindow contentRectForFrameRect:frame |
379 | styleMask:NSTitledWindowMask]; | 379 | styleMask:NSWindowStyleMaskTitled]; |
380 | height = (frame.size.height - contentRect.size.height); | 380 | height = (frame.size.height - contentRect.size.height); |
381 | DBG("Titlebar Heigt : %d", height); | 381 | DBG("Titlebar Heigt : %d", height); |
382 | } | 382 | } |
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) | |||
8 | @try { | 8 | @try { |
9 | NSEvent *e; | 9 | NSEvent *e; |
10 | do { | 10 | do { |
11 | e = [NSApp nextEventMatchingMask:NSAnyEventMask | 11 | e = [NSApp nextEventMatchingMask:NSEventMaskAny |
12 | untilDate:[NSApp eventExpirationDate] | 12 | untilDate:[NSApp eventExpirationDate] |
13 | inMode:NSDefaultRunLoopMode | 13 | inMode:NSDefaultRunLoopMode |
14 | dequeue:YES]; | 14 | dequeue:YES]; |
@@ -19,7 +19,8 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED) | |||
19 | 19 | ||
20 | /* Update (en/disable) the services menu's items */ | 20 | /* Update (en/disable) the services menu's items */ |
21 | NSEventType type = [e type]; | 21 | NSEventType type = [e type]; |
22 | if (type != NSPeriodic && type != NSMouseMoved) { | 22 | if ((type != NSEventTypePeriodic) && |
23 | (type != NSEventTypeMouseMoved)) { | ||
23 | [NSApp internalUpdate]; | 24 | [NSApp internalUpdate]; |
24 | } | 25 | } |
25 | } | 26 | } |
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; | |||
28 | #endif | 28 | #endif |
29 | #define CRI(...) EINA_LOG_DOM_CRIT(_ecore_cocoa_log_domain, __VA_ARGS__) | 29 | #define CRI(...) EINA_LOG_DOM_CRIT(_ecore_cocoa_log_domain, __VA_ARGS__) |
30 | 30 | ||
31 | /* | ||
32 | * macOS Sierra (10.12) deprecated enumeration types in profit to others, | ||
33 | * more meaningful ones. | ||
34 | */ | ||
35 | #ifndef __MAC_10_12 | ||
36 | # define NSWindowStyleMaskTitled NSTitledWindowMask | ||
37 | # define NSWindowStyleMaskClosable NSClosableWindowMask | ||
38 | # define NSWindowStyleMaskResizable NSResizableWindowMask | ||
39 | # define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask | ||
40 | # define NSWindowStyleMaskFullScreen NSFullScreenWindowMask | ||
41 | # define NSEventModifierFlagShift NSShiftKeyMask | ||
42 | # define NSEventModifierFlagControl NSControlKeyMask | ||
43 | # define NSEventModifierFlagOption NSAlternateKeyMask | ||
44 | # define NSEventModifierFlagCommand NSCommandKeyMask | ||
45 | # define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask | ||
46 | # define NSEventTypeScrollWheel NSScrollWheel | ||
47 | # define NSEventMaskAny NSAnyEventMask | ||
48 | # define NSEventTypePeriodic NSPeriodic | ||
49 | # define NSEventTypeMouseMoved NSMouseMoved | ||
50 | # define NSEventTypeRightMouseDown NSRightMouseDown | ||
51 | # define NSEventTypeLeftMouseDown NSLeftMouseDown | ||
52 | # define NSEventTypeOtherMouseDown NSOtherMouseDown | ||
53 | # define NSEventTypeLeftMouseUp NSLeftMouseUp | ||
54 | # define NSEventTypeRightMouseUp NSRightMouseUp | ||
55 | # define NSEventTypeOtherMouseUp NSOtherMouseUp | ||
56 | # define NSEventTypeKeyDown NSKeyDown | ||
57 | # define NSEventTypeKeyUp NSKeyUp | ||
58 | # define NSEventTypeFlagsChanged NSFlagsChanged | ||
59 | # define NSEventTypeLeftMouseDragged NSLeftMouseDragged | ||
60 | # define NSEventTypeRightMouseDragged NSRightMouseDragged | ||
61 | # define NSEventTypeOtherMouseDragged NSOtherMouseDragged | ||
62 | # define NSEventModifierFlagNumericPad NSNumericPadKeyMask | ||
63 | #endif | ||
31 | 64 | ||
32 | struct _Ecore_Cocoa_Window | 65 | struct _Ecore_Cocoa_Window |
33 | { | 66 | { |
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]; | |||
41 | 41 | ||
42 | - (BOOL)isFullScreen | 42 | - (BOOL)isFullScreen |
43 | { | 43 | { |
44 | return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask); | 44 | return (([self styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen); |
45 | } | 45 | } |
46 | 46 | ||
47 | - (BOOL)acceptsFirstResponder | 47 | - (BOOL)acceptsFirstResponder |
@@ -331,10 +331,10 @@ ecore_cocoa_window_new(int x, | |||
331 | Ecore_Cocoa_Window *win; | 331 | Ecore_Cocoa_Window *win; |
332 | EcoreCocoaWindow *window; | 332 | EcoreCocoaWindow *window; |
333 | NSUInteger style = | 333 | NSUInteger style = |
334 | NSTitledWindowMask | | 334 | NSWindowStyleMaskTitled | |
335 | NSClosableWindowMask | | 335 | NSWindowStyleMaskClosable | |
336 | NSResizableWindowMask | | 336 | NSWindowStyleMaskResizable | |
337 | NSMiniaturizableWindowMask; | 337 | NSWindowStyleMaskMiniaturizable; |
338 | 338 | ||
339 | window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, w, h) | 339 | window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, w, h) |
340 | styleMask:style | 340 | styleMask:style |