Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
cocoa_init.m
Go to the documentation of this file.
1//========================================================================
2// GLFW 3.4 macOS - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26// It is fine to use C99 in this file because it will not be built with VS
27//========================================================================
28
29#include "internal.h"
30#include <sys/param.h> // For MAXPATHLEN
31
32// Needed for _NSGetProgname
33#include <crt_externs.h>
34
35// Change to our application bundle's resources directory, if present
36//
37static void changeToResourcesDirectory(void)
38{
39 char resourcesPath[MAXPATHLEN];
40
41 CFBundleRef bundle = CFBundleGetMainBundle();
42 if (!bundle)
43 return;
44
45 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
46
47 CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
48 if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
49 {
50 CFRelease(last);
51 CFRelease(resourcesURL);
52 return;
53 }
54
55 CFRelease(last);
56
57 if (!CFURLGetFileSystemRepresentation(resourcesURL,
58 true,
59 (UInt8*) resourcesPath,
60 MAXPATHLEN))
61 {
62 CFRelease(resourcesURL);
63 return;
64 }
65
66 CFRelease(resourcesURL);
67
68 chdir(resourcesPath);
69}
70
71// Set up the menu bar (manually)
72// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
73// could go away at any moment, lots of stuff that really should be
74// localize(d|able), etc. Add a nib to save us this horror.
75//
76static void createMenuBar(void)
77{
78 size_t i;
79 NSString* appName = nil;
80 NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
81 NSString* nameKeys[] =
82 {
83 @"CFBundleDisplayName",
84 @"CFBundleName",
85 @"CFBundleExecutable",
86 };
87
88 // Try to figure out what the calling application is called
89
90 for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
91 {
92 id name = bundleInfo[nameKeys[i]];
93 if (name &&
94 [name isKindOfClass:[NSString class]] &&
95 ![name isEqualToString:@""])
96 {
97 appName = name;
98 break;
99 }
100 }
101
102 if (!appName)
103 {
104 char** progname = _NSGetProgname();
105 if (progname && *progname)
106 appName = @(*progname);
107 else
108 appName = @"GLFW Application";
109 }
110
111 NSMenu* bar = [[NSMenu alloc] init];
112 [NSApp setMainMenu:bar];
113
114 NSMenuItem* appMenuItem =
115 [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
116 NSMenu* appMenu = [[NSMenu alloc] init];
117 [appMenuItem setSubmenu:appMenu];
118
119 [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
120 action:@selector(orderFrontStandardAboutPanel:)
121 keyEquivalent:@""];
122 [appMenu addItem:[NSMenuItem separatorItem]];
123 NSMenu* servicesMenu = [[NSMenu alloc] init];
124 [NSApp setServicesMenu:servicesMenu];
125 [[appMenu addItemWithTitle:@"Services"
126 action:NULL
127 keyEquivalent:@""] setSubmenu:servicesMenu];
128 [servicesMenu release];
129 [appMenu addItem:[NSMenuItem separatorItem]];
130 [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
131 action:@selector(hide:)
132 keyEquivalent:@"h"];
133 [[appMenu addItemWithTitle:@"Hide Others"
134 action:@selector(hideOtherApplications:)
135 keyEquivalent:@"h"]
136 setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
137 [appMenu addItemWithTitle:@"Show All"
138 action:@selector(unhideAllApplications:)
139 keyEquivalent:@""];
140 [appMenu addItem:[NSMenuItem separatorItem]];
141 [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
142 action:@selector(terminate:)
143 keyEquivalent:@"q"];
144
145 NSMenuItem* windowMenuItem =
146 [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
147 [bar release];
148 NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
149 [NSApp setWindowsMenu:windowMenu];
150 [windowMenuItem setSubmenu:windowMenu];
151
152 [windowMenu addItemWithTitle:@"Minimize"
153 action:@selector(performMiniaturize:)
154 keyEquivalent:@"m"];
155 [windowMenu addItemWithTitle:@"Zoom"
156 action:@selector(performZoom:)
157 keyEquivalent:@""];
158 [windowMenu addItem:[NSMenuItem separatorItem]];
159 [windowMenu addItemWithTitle:@"Bring All to Front"
160 action:@selector(arrangeInFront:)
161 keyEquivalent:@""];
162
163 // TODO: Make this appear at the bottom of the menu (for consistency)
164 [windowMenu addItem:[NSMenuItem separatorItem]];
165 [[windowMenu addItemWithTitle:@"Enter Full Screen"
166 action:@selector(toggleFullScreen:)
167 keyEquivalent:@"f"]
168 setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
169
170 // Prior to Snow Leopard, we need to use this oddly-named semi-private API
171 // to get the application menu working properly.
172 SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
173 [NSApp performSelector:setAppleMenuSelector withObject:appMenu];
174}
175
176// Create key code translation tables
177//
178static void createKeyTables(void)
179{
180 int scancode;
181
182 memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
183 memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
184
185 _glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
186 _glfw.ns.keycodes[0x12] = GLFW_KEY_1;
187 _glfw.ns.keycodes[0x13] = GLFW_KEY_2;
188 _glfw.ns.keycodes[0x14] = GLFW_KEY_3;
189 _glfw.ns.keycodes[0x15] = GLFW_KEY_4;
190 _glfw.ns.keycodes[0x17] = GLFW_KEY_5;
191 _glfw.ns.keycodes[0x16] = GLFW_KEY_6;
192 _glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
193 _glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
194 _glfw.ns.keycodes[0x19] = GLFW_KEY_9;
195 _glfw.ns.keycodes[0x00] = GLFW_KEY_A;
196 _glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
197 _glfw.ns.keycodes[0x08] = GLFW_KEY_C;
198 _glfw.ns.keycodes[0x02] = GLFW_KEY_D;
199 _glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
200 _glfw.ns.keycodes[0x03] = GLFW_KEY_F;
201 _glfw.ns.keycodes[0x05] = GLFW_KEY_G;
202 _glfw.ns.keycodes[0x04] = GLFW_KEY_H;
203 _glfw.ns.keycodes[0x22] = GLFW_KEY_I;
204 _glfw.ns.keycodes[0x26] = GLFW_KEY_J;
205 _glfw.ns.keycodes[0x28] = GLFW_KEY_K;
206 _glfw.ns.keycodes[0x25] = GLFW_KEY_L;
207 _glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
208 _glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
209 _glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
210 _glfw.ns.keycodes[0x23] = GLFW_KEY_P;
211 _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
212 _glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
213 _glfw.ns.keycodes[0x01] = GLFW_KEY_S;
214 _glfw.ns.keycodes[0x11] = GLFW_KEY_T;
215 _glfw.ns.keycodes[0x20] = GLFW_KEY_U;
216 _glfw.ns.keycodes[0x09] = GLFW_KEY_V;
217 _glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
218 _glfw.ns.keycodes[0x07] = GLFW_KEY_X;
219 _glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
220 _glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
221
222 _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
223 _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
224 _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
225 _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
226 _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
227 _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
228 _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
229 _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
230 _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
231 _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
232 _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
233 _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
234
235 _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
236 _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
237 _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
238 _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
239 _glfw.ns.keycodes[0x77] = GLFW_KEY_END;
240 _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
241 _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
242 _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
243 _glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
244 _glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
245 _glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
246 _glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
247 _glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
248 _glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
249 _glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
250 _glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
251 _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
252 _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
253 _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
254 _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN;
255 _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
256 _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
257 _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
258 _glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
259 _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
260 _glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
261 _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
262 _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
263 _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
264 _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
265 _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
266 _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
267 _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
268 _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
269 _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
270 _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
271 _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
272 _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
273 _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
274 _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
275 _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
276 _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
277 _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
278 _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
279 _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
280 _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
281
282 _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
283 _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
284 _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
285 _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
286 _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
287 _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
288 _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
289 _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
290 _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
291 _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
292 _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
293 _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
294 _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
295 _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
296 _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
297 _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
298 _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
299
300 for (scancode = 0; scancode < 256; scancode++)
301 {
302 // Store the reverse translation for faster key name lookup
303 if (_glfw.ns.keycodes[scancode] >= 0)
304 _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
305 }
306}
307
308// Retrieve Unicode data for the current keyboard layout
309//
310static GLFWbool updateUnicodeDataNS(void)
311{
312 if (_glfw.ns.inputSource)
313 {
314 CFRelease(_glfw.ns.inputSource);
315 _glfw.ns.inputSource = NULL;
316 _glfw.ns.unicodeData = nil;
317 }
318
320 if (!_glfw.ns.inputSource)
321 {
323 "Cocoa: Failed to retrieve keyboard layout input source");
324 return GLFW_FALSE;
325 }
326
327 _glfw.ns.unicodeData =
328 TISGetInputSourceProperty(_glfw.ns.inputSource,
330 if (!_glfw.ns.unicodeData)
331 {
333 "Cocoa: Failed to retrieve keyboard layout Unicode data");
334 return GLFW_FALSE;
335 }
336
337 return GLFW_TRUE;
338}
339
340// Load HIToolbox.framework and the TIS symbols we need from it
341//
342static GLFWbool initializeTIS(void)
343{
344 // This works only because Cocoa has already loaded it properly
345 _glfw.ns.tis.bundle =
346 CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
347 if (!_glfw.ns.tis.bundle)
348 {
350 "Cocoa: Failed to load HIToolbox.framework");
351 return GLFW_FALSE;
352 }
353
354 CFStringRef* kPropertyUnicodeKeyLayoutData =
355 CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
356 CFSTR("kTISPropertyUnicodeKeyLayoutData"));
357 _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
358 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
359 CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
360 _glfw.ns.tis.GetInputSourceProperty =
361 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
362 CFSTR("TISGetInputSourceProperty"));
363 _glfw.ns.tis.GetKbdType =
364 CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
365 CFSTR("LMGetKbdType"));
366
367 if (!kPropertyUnicodeKeyLayoutData ||
371 {
373 "Cocoa: Failed to load TIS API symbols");
374 return GLFW_FALSE;
375 }
376
377 _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
378 *kPropertyUnicodeKeyLayoutData;
379
380 return updateUnicodeDataNS();
381}
382
383@interface GLFWHelper : NSObject
384@end
385
386@implementation GLFWHelper
387
388- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
389{
390 updateUnicodeDataNS();
391}
392
393- (void)doNothing:(id)object
394{
395}
396
397@end // GLFWHelper
398
399@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
400@end
401
402@implementation GLFWApplicationDelegate
403
404- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
405{
406 _GLFWwindow* window;
407
408 for (window = _glfw.windowListHead; window; window = window->next)
410
411 return NSTerminateCancel;
412}
413
414- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
415{
416 _GLFWwindow* window;
417
418 for (window = _glfw.windowListHead; window; window = window->next)
419 {
420 if (window->context.client != GLFW_NO_API)
421 [window->context.nsgl.object update];
422 }
423
425}
426
427- (void)applicationWillFinishLaunching:(NSNotification *)notification
428{
430 {
431 // Menu bar setup must go between sharedApplication and finishLaunching
432 // in order to properly emulate the behavior of NSApplicationMain
433
434 if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
435 {
436 [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
437 owner:NSApp
438 topLevelObjects:&_glfw.ns.nibObjects];
439 }
440 else
441 createMenuBar();
442 }
443}
444
445- (void)applicationDidFinishLaunching:(NSNotification *)notification
446{
448 [NSApp stop:nil];
449}
450
451- (void)applicationDidHide:(NSNotification *)notification
452{
453 int i;
454
455 for (i = 0; i < _glfw.monitorCount; i++)
457}
458
459@end // GLFWApplicationDelegate
460
461
465
467{
468 CFBundleRef bundle = CFBundleGetMainBundle();
469 if (!bundle)
470 return NULL;
471
472 CFURLRef url =
473 CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib"));
474 if (!url)
475 return NULL;
476
477 char path[PATH_MAX];
478 void* handle = NULL;
479
480 if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
481 handle = _glfw_dlopen(path);
482
483 CFRelease(url);
484 return handle;
485}
486
487
491
493{
494 @autoreleasepool {
495
496 _glfw.ns.helper = [[GLFWHelper alloc] init];
497
498 [NSThread detachNewThreadSelector:@selector(doNothing:)
499 toTarget:_glfw.ns.helper
500 withObject:nil];
501
502 [NSApplication sharedApplication];
503
504 _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
505 if (_glfw.ns.delegate == nil)
506 {
508 "Cocoa: Failed to create application delegate");
509 return GLFW_FALSE;
510 }
511
512 [NSApp setDelegate:_glfw.ns.delegate];
513
514 NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
515 {
516 if ([event modifierFlags] & NSEventModifierFlagCommand)
517 [[NSApp keyWindow] sendEvent:event];
518
519 return event;
520 };
521
522 _glfw.ns.keyUpMonitor =
523 [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
524 handler:block];
525
526 if (_glfw.hints.init.ns.chdir)
527 changeToResourcesDirectory();
528
529 // Press and Hold prevents some keys from emitting repeated characters
530 NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
531 [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
532
533 [[NSNotificationCenter defaultCenter]
534 addObserver:_glfw.ns.helper
535 selector:@selector(selectedKeyboardInputSourceChanged:)
536 name:NSTextInputContextKeyboardSelectionDidChangeNotification
537 object:nil];
538
539 createKeyTables();
540
541 _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
542 if (!_glfw.ns.eventSource)
543 return GLFW_FALSE;
544
545 CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
546
547 if (!initializeTIS())
548 return GLFW_FALSE;
549
551
553
554 if (![[NSRunningApplication currentApplication] isFinishedLaunching])
555 [NSApp run];
556
557 // In case we are unbundled, make us a proper UI application
559 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
560
561 return GLFW_TRUE;
562
563 } // autoreleasepool
564}
565
567{
568 @autoreleasepool {
569
570 if (_glfw.ns.inputSource)
571 {
572 CFRelease(_glfw.ns.inputSource);
573 _glfw.ns.inputSource = NULL;
574 _glfw.ns.unicodeData = nil;
575 }
576
577 if (_glfw.ns.eventSource)
578 {
579 CFRelease(_glfw.ns.eventSource);
580 _glfw.ns.eventSource = NULL;
581 }
582
583 if (_glfw.ns.delegate)
584 {
585 [NSApp setDelegate:nil];
586 [_glfw.ns.delegate release];
587 _glfw.ns.delegate = nil;
588 }
589
590 if (_glfw.ns.helper)
591 {
592 [[NSNotificationCenter defaultCenter]
593 removeObserver:_glfw.ns.helper
594 name:NSTextInputContextKeyboardSelectionDidChangeNotification
595 object:nil];
596 [[NSNotificationCenter defaultCenter]
597 removeObserver:_glfw.ns.helper];
598 [_glfw.ns.helper release];
599 _glfw.ns.helper = nil;
600 }
601
602 if (_glfw.ns.keyUpMonitor)
603 [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
604
605 free(_glfw.ns.clipboardString);
606
608
609 } // autoreleasepool
610}
611
613{
614 return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
615#if defined(_GLFW_BUILD_DLL)
616 " dynamic"
617#endif
618 ;
619}
620
void * _glfwLoadLocalVulkanLoaderNS(void)
Definition: cocoa_init.m:466
const char * _glfwPlatformGetVersionString(void)
Definition: cocoa_init.m:612
void _glfwPlatformTerminate(void)
Definition: cocoa_init.m:566
int _glfwPlatformInit(void)
Definition: cocoa_init.m:492
void _glfwRestoreVideoModeNS(_GLFWmonitor *monitor)
void _glfwPollMonitorsNS(void)
void _glfwInitTimerNS(void)
Definition: cocoa_time.c:40
#define NSEventModifierFlagCommand
#define TISCopyCurrentKeyboardLayoutInputSource
#define LMGetKbdType
#define _glfw_dlopen(name)
#define kTISPropertyUnicodeKeyLayoutData
#define TISGetInputSourceProperty
void _glfwPlatformPostEmptyEvent(void)
#define GLFW_NO_API
Definition: glfw3.h:1086
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:758
#define GLFW_TRUE
One.
Definition: glfw3.h:310
#define GLFW_FALSE
Zero.
Definition: glfw3.h:319
#define GLFW_KEY_C
Definition: glfw3.h:412
#define GLFW_KEY_D
Definition: glfw3.h:413
#define GLFW_KEY_A
Definition: glfw3.h:410
#define GLFW_KEY_1
Definition: glfw3.h:399
#define GLFW_KEY_RIGHT
Definition: glfw3.h:450
#define GLFW_KEY_F2
Definition: glfw3.h:464
#define GLFW_KEY_F11
Definition: glfw3.h:473
#define GLFW_KEY_KP_0
Definition: glfw3.h:488
#define GLFW_KEY_S
Definition: glfw3.h:428
#define GLFW_KEY_V
Definition: glfw3.h:431
#define GLFW_KEY_I
Definition: glfw3.h:418
#define GLFW_KEY_9
Definition: glfw3.h:407
#define GLFW_KEY_UP
Definition: glfw3.h:453
#define GLFW_KEY_INSERT
Definition: glfw3.h:448
#define GLFW_KEY_PERIOD
Definition: glfw3.h:396
#define GLFW_KEY_NUM_LOCK
Definition: glfw3.h:460
#define GLFW_KEY_PAGE_UP
Definition: glfw3.h:454
#define GLFW_KEY_HOME
Definition: glfw3.h:456
#define GLFW_KEY_K
Definition: glfw3.h:420
#define GLFW_KEY_R
Definition: glfw3.h:427
#define GLFW_KEY_5
Definition: glfw3.h:403
#define GLFW_KEY_M
Definition: glfw3.h:422
#define GLFW_KEY_KP_DECIMAL
Definition: glfw3.h:498
#define GLFW_KEY_KP_ENTER
Definition: glfw3.h:503
#define GLFW_KEY_0
Definition: glfw3.h:398
#define GLFW_KEY_F
Definition: glfw3.h:415
#define GLFW_KEY_APOSTROPHE
Definition: glfw3.h:393
#define GLFW_KEY_J
Definition: glfw3.h:419
#define GLFW_KEY_RIGHT_ALT
Definition: glfw3.h:511
#define GLFW_KEY_TAB
Definition: glfw3.h:446
#define GLFW_KEY_BACKSPACE
Definition: glfw3.h:447
#define GLFW_KEY_F6
Definition: glfw3.h:468
#define GLFW_KEY_F10
Definition: glfw3.h:472
#define GLFW_KEY_GRAVE_ACCENT
Definition: glfw3.h:439
#define GLFW_KEY_KP_3
Definition: glfw3.h:491
#define GLFW_KEY_LEFT_ALT
Definition: glfw3.h:507
#define GLFW_KEY_F15
Definition: glfw3.h:477
#define GLFW_KEY_3
Definition: glfw3.h:401
#define GLFW_KEY_F20
Definition: glfw3.h:482
#define GLFW_KEY_SEMICOLON
Definition: glfw3.h:408
#define GLFW_KEY_END
Definition: glfw3.h:457
#define GLFW_KEY_RIGHT_BRACKET
Definition: glfw3.h:438
#define GLFW_KEY_KP_7
Definition: glfw3.h:495
#define GLFW_KEY_LEFT_SHIFT
Definition: glfw3.h:505
#define GLFW_KEY_B
Definition: glfw3.h:411
#define GLFW_KEY_P
Definition: glfw3.h:425
#define GLFW_KEY_T
Definition: glfw3.h:429
#define GLFW_KEY_CAPS_LOCK
Definition: glfw3.h:458
#define GLFW_KEY_ENTER
Definition: glfw3.h:445
#define GLFW_KEY_F17
Definition: glfw3.h:479
#define GLFW_KEY_MENU
Definition: glfw3.h:513
#define GLFW_KEY_KP_5
Definition: glfw3.h:493
#define GLFW_KEY_KP_MULTIPLY
Definition: glfw3.h:500
#define GLFW_KEY_F4
Definition: glfw3.h:466
#define GLFW_KEY_4
Definition: glfw3.h:402
#define GLFW_KEY_6
Definition: glfw3.h:404
#define GLFW_KEY_LEFT_CONTROL
Definition: glfw3.h:506
#define GLFW_KEY_W
Definition: glfw3.h:432
#define GLFW_KEY_KP_SUBTRACT
Definition: glfw3.h:501
#define GLFW_KEY_F16
Definition: glfw3.h:478
#define GLFW_KEY_L
Definition: glfw3.h:421
#define GLFW_KEY_ESCAPE
Definition: glfw3.h:444
#define GLFW_KEY_KP_8
Definition: glfw3.h:496
#define GLFW_KEY_COMMA
Definition: glfw3.h:394
#define GLFW_KEY_7
Definition: glfw3.h:405
#define GLFW_KEY_BACKSLASH
Definition: glfw3.h:437
#define GLFW_KEY_KP_DIVIDE
Definition: glfw3.h:499
#define GLFW_KEY_E
Definition: glfw3.h:414
#define GLFW_KEY_X
Definition: glfw3.h:433
#define GLFW_KEY_Z
Definition: glfw3.h:435
#define GLFW_KEY_MINUS
Definition: glfw3.h:395
#define GLFW_KEY_F8
Definition: glfw3.h:470
#define GLFW_KEY_U
Definition: glfw3.h:430
#define GLFW_KEY_F7
Definition: glfw3.h:469
#define GLFW_KEY_KP_ADD
Definition: glfw3.h:502
#define GLFW_KEY_LEFT_BRACKET
Definition: glfw3.h:436
#define GLFW_KEY_RIGHT_CONTROL
Definition: glfw3.h:510
#define GLFW_KEY_RIGHT_SUPER
Definition: glfw3.h:512
#define GLFW_KEY_H
Definition: glfw3.h:417
#define GLFW_KEY_KP_4
Definition: glfw3.h:492
#define GLFW_KEY_DELETE
Definition: glfw3.h:449
#define GLFW_KEY_WORLD_1
Definition: glfw3.h:440
#define GLFW_KEY_2
Definition: glfw3.h:400
#define GLFW_KEY_SPACE
Definition: glfw3.h:392
#define GLFW_KEY_8
Definition: glfw3.h:406
#define GLFW_KEY_SLASH
Definition: glfw3.h:397
#define GLFW_KEY_N
Definition: glfw3.h:423
#define GLFW_KEY_LEFT
Definition: glfw3.h:451
#define GLFW_KEY_EQUAL
Definition: glfw3.h:409
#define GLFW_KEY_DOWN
Definition: glfw3.h:452
#define GLFW_KEY_F9
Definition: glfw3.h:471
#define GLFW_KEY_G
Definition: glfw3.h:416
#define GLFW_KEY_KP_EQUAL
Definition: glfw3.h:504
#define GLFW_KEY_F18
Definition: glfw3.h:480
#define GLFW_KEY_F19
Definition: glfw3.h:481
#define GLFW_KEY_O
Definition: glfw3.h:424
#define GLFW_KEY_F3
Definition: glfw3.h:465
#define GLFW_KEY_PAGE_DOWN
Definition: glfw3.h:455
#define GLFW_KEY_F14
Definition: glfw3.h:476
#define GLFW_KEY_F5
Definition: glfw3.h:467
#define GLFW_KEY_KP_1
Definition: glfw3.h:489
#define GLFW_KEY_F12
Definition: glfw3.h:474
#define GLFW_KEY_KP_2
Definition: glfw3.h:490
#define GLFW_KEY_PRINT_SCREEN
Definition: glfw3.h:461
#define GLFW_KEY_LEFT_SUPER
Definition: glfw3.h:508
#define GLFW_KEY_KP_9
Definition: glfw3.h:497
#define GLFW_KEY_F1
Definition: glfw3.h:463
#define GLFW_KEY_KP_6
Definition: glfw3.h:494
#define GLFW_KEY_Y
Definition: glfw3.h:434
#define GLFW_KEY_Q
Definition: glfw3.h:426
#define GLFW_KEY_RIGHT_SHIFT
Definition: glfw3.h:509
_GLFWlibrary _glfw
Definition: init.c:46
void _glfwInputError(int code, const char *format,...)
Definition: init.c:160
#define _GLFW_VERSION_NUMBER
Definition: internal.h:203
int GLFWbool
Definition: internal.h:61
void _glfwInputWindowCloseRequest(_GLFWwindow *window)
Definition: window.c:133
#define NULL
Definition: miniaudio.h:3718
void _glfwTerminateNSGL(void)
Definition: nsgl_context.m:152
struct _GLFWinitconfig::@16 ns
GLFWbool chdir
Definition: internal.h:249
GLFWbool menubar
Definition: internal.h:248
_GLFWwindow * windowListHead
Definition: internal.h:541
_GLFWinitconfig init
Definition: internal.h:532
struct _GLFWlibrary::@23 hints
_GLFWmonitor ** monitors
Definition: internal.h:543
int monitorCount
Definition: internal.h:544
struct _GLFWwindow * next
Definition: internal.h:379
_GLFWcontext context
Definition: internal.h:409