From 11a241347699151131b7001470a3bb2245c08dc2 Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Fri, 14 Oct 2016 17:56:45 +0300 Subject: [PATCH] Cocoa: Fix issue with application sandboxing Fixes #816. Closes #882. --- src/cocoa_init.m | 16 +++++----------- src/cocoa_platform.h | 2 -- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 65ea3f7b..ba798637 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -247,9 +247,6 @@ static GLFWbool initializeTIS(void) CFStringRef* kPropertyUnicodeKeyLayoutData = CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, CFSTR("kTISPropertyUnicodeKeyLayoutData")); - CFStringRef* kNotifySelectedKeyboardInputSourceChanged = - CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, - CFSTR("kTISNotifySelectedKeyboardInputSourceChanged")); _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); @@ -261,7 +258,6 @@ static GLFWbool initializeTIS(void) CFSTR("LMGetKbdType")); if (!kPropertyUnicodeKeyLayoutData || - !kNotifySelectedKeyboardInputSourceChanged || !TISCopyCurrentKeyboardLayoutInputSource || !TISGetInputSourceProperty || !LMGetKbdType) @@ -273,8 +269,6 @@ static GLFWbool initializeTIS(void) _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData; - _glfw.ns.tis.kNotifySelectedKeyboardInputSourceChanged = - *kNotifySelectedKeyboardInputSourceChanged; return updateUnicodeDataNS(); } @@ -301,10 +295,10 @@ int _glfwPlatformInit(void) _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init]; _glfw.ns.listener = [[GLFWLayoutListener alloc] init]; - [[NSDistributedNotificationCenter defaultCenter] + [[NSNotificationCenter defaultCenter] addObserver:_glfw.ns.listener selector:@selector(selectedKeyboardInputSourceChanged:) - name:(__bridge NSString*)kTISNotifySelectedKeyboardInputSourceChanged + name:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil]; #if defined(_GLFW_USE_CHDIR) @@ -355,11 +349,11 @@ void _glfwPlatformTerminate(void) if (_glfw.ns.listener) { - [[NSDistributedNotificationCenter defaultCenter] + [[NSNotificationCenter defaultCenter] removeObserver:_glfw.ns.listener - name:(__bridge NSString*)kTISNotifySelectedKeyboardInputSourceChanged + name:NSTextInputContextKeyboardSelectionDidChangeNotification object:nil]; - [[NSDistributedNotificationCenter defaultCenter] + [[NSNotificationCenter defaultCenter] removeObserver:_glfw.ns.listener]; [_glfw.ns.listener release]; _glfw.ns.listener = nil; diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 3422aba7..2a681d50 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -70,7 +70,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacO // HIToolbox.framework pointer typedefs #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData -#define kTISNotifySelectedKeyboardInputSourceChanged _glfw.ns.tis.kNotifySelectedKeyboardInputSourceChanged typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); #define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef); @@ -125,7 +124,6 @@ typedef struct _GLFWlibraryNS PFN_TISGetInputSourceProperty GetInputSourceProperty; PFN_LMGetKbdType GetKbdType; CFStringRef kPropertyUnicodeKeyLayoutData; - CFStringRef kNotifySelectedKeyboardInputSourceChanged; } tis; } _GLFWlibraryNS;