diff options
Diffstat (limited to 'src/newt')
6 files changed, 66 insertions, 20 deletions
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 99ce16136..61d21026a 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -34,7 +34,6 @@ package com.jogamp.newt; -import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Arrays; @@ -48,6 +47,7 @@ import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.PropertyAccess; +import com.jogamp.common.util.SecurityUtil; import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; @@ -63,7 +63,7 @@ public class NewtFactory { private static String sysPaths = "newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png"; static { - AccessController.doPrivileged(new PrivilegedAction<Object>() { + SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index f6c7ad955..c7e1c0a45 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,7 +34,6 @@ package com.jogamp.newt.opengl; -import java.security.AccessController; import java.security.PrivilegedAction; import java.util.List; @@ -74,6 +73,7 @@ import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.util.SecurityUtil; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.MonitorDevice; @@ -739,7 +739,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind if( animThread == Thread.currentThread() ) { anim.stop(); // on anim thread, non-blocking } else { - AccessController.doPrivileged(new PrivilegedAction<Object>() { + SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { if( anim.isAnimating() && null != animThread ) { diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java index c30576ff4..055e38020 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java @@ -28,7 +28,6 @@ package com.jogamp.newt.util.applet; import java.lang.reflect.Field; -import java.security.AccessController; import java.security.PrivilegedAction; import com.jogamp.nativewindow.NativeWindow; @@ -43,6 +42,7 @@ import com.jogamp.opengl.GLPipelineFactory; import jogamp.newt.Debug; import com.jogamp.common.util.InterruptSource; +import com.jogamp.common.util.SecurityUtil; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; @@ -119,7 +119,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { Object instance = null; try { - final Class<?> clazz = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() { + final Class<?> clazz = SecurityUtil.doPrivileged(new PrivilegedAction<Class<?>>() { @Override public Class<?> run() { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -312,7 +312,8 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(e.getKeyChar()=='r' && 0==e.getModifiers() && null!=parentWin) { e.setConsumed(true); glWindow.invokeOnNewThread(null, false, new Runnable() { - public void run() { + @Override + public void run() { if(null == glWindow.getParent()) { glWindow.reparentWindow(parentWin, -1, -1, 0 /* hints */); } else { diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index a255cb755..60b259214 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -28,10 +28,10 @@ package jogamp.newt; -import java.security.AccessController; import java.security.PrivilegedAction; import com.jogamp.common.util.PropertyAccess; +import com.jogamp.common.util.SecurityUtil; /** Helper routines for logging and debugging. */ @@ -41,7 +41,7 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - AccessController.doPrivileged(new PrivilegedAction<Object>() { + SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { PropertyAccess.addTrustedPrefix("newt."); diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index fde3de222..e2bf86002 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -39,11 +39,11 @@ package jogamp.newt; -import java.security.AccessController; import java.security.PrivilegedAction; import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.SecurityUtil; import com.jogamp.common.util.cache.TempJarCache; public class NEWTJNILibLoader extends JNILibLoaderBase { @@ -52,7 +52,7 @@ public class NEWTJNILibLoader extends JNILibLoaderBase { * i.e. X11 for Unix, GDI for Windows .. and so forth. */ public static boolean loadNEWTHead() { - return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + return SecurityUtil.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { Platform.initSingleton(); @@ -68,7 +68,7 @@ public class NEWTJNILibLoader extends JNILibLoaderBase { * Loads the NEWT native library for the drm/gbm display. */ public static boolean loadNEWTDrmGbm() { - return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + return SecurityUtil.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { Platform.initSingleton(); diff --git a/src/newt/native/MacNewtNSWindow.m b/src/newt/native/MacNewtNSWindow.m index eef3278b9..6ae36af9c 100644 --- a/src/newt/native/MacNewtNSWindow.m +++ b/src/newt/native/MacNewtNSWindow.m @@ -110,6 +110,12 @@ static jint mods2JavaMods(NSUInteger mods) return javaMods; } +#if 0 + +// +// Disabled due to crash on MacOS >= 13, see CKCH_CreateDictionaries() below +// + static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { UInt32 keysDown = 0; UniChar chars[4]; @@ -123,12 +129,14 @@ static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLa return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); } -static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { - CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); +static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(CFDataRef layoutData) { if( NULL == layoutData ) { return NULL; } const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); + if( NULL == keyboardLayout ) { + return NULL; + } CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); if ( NULL != codeToCharDict ) { @@ -152,10 +160,41 @@ static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboa static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; static void CKCH_CreateDictionaries() { - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - if( NULL != currentKeyboard ) { - CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); - CFRelease(currentKeyboard); + bool done = false; + TISInputSourceRef inputSource; + inputSource = TISCopyCurrentKeyboardInputSource(); + if( NULL != inputSource ) { + /** + * Crash on MacOS >= 13 + * + * thread #3, stop reason = ESR_EC_BRK_AARCH64 (fault address: 0x1f287d300) + * frame #0: 0x0000000196e7c924 libdispatch.dylib`_dispatch_assert_queue_fail + 120 + * frame #1: 0x0000000196e7c8ac libdispatch.dylib`dispatch_assert_queue + 196 + * frame #2: 0x00000001a07b66a4 HIToolbox`islGetInputSourceListWithAdditions + 160 + * frame #3: 0x00000001a07b8ccc HIToolbox`isValidateInputSourceRef + 92 + * frame #4: 0x00000001a07b8b8c HIToolbox`TSMGetInputSourceProperty + 44 + * frame #5: 0x000000012c961890 libnewt_head.dylib`CKCH_CreateDictionaries at MacNewtNSWindow.m:166:48 + * frame #6: 0x000000012c95f68c libnewt_head.dylib`+[NewtNSWindow initNatives:forClass:](self=0x000000012c96d600, _cmd="initNatives:forClass:", env=0x000000014b80e2a8 + */ + CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(inputSource, kTISPropertyUnicodeKeyLayoutData); + if( NULL != layoutData ) { + CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(layoutData); + done = true; + } + CFRelease(inputSource); + } + if( !done ) { + // TISGetInputSourceProperty returns null with Japanese keyboard layout. + // Using TISCopyCurrentKeyboardLayoutInputSource to fix NULL return. + inputSource = TISCopyCurrentKeyboardLayoutInputSource(); + if( NULL != inputSource ) { + CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(inputSource, kTISPropertyUnicodeKeyLayoutData); + if( NULL != layoutData ) { + CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(layoutData); + done = true; + } + CFRelease(inputSource); + } } } @@ -174,6 +213,8 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { return rChar; } +#endif + static jmethodID enqueueMouseEventID = NULL; static jmethodID enqueueKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -761,7 +802,9 @@ static jmethodID windowRepaintID = NULL; for (i = 0; i < len; i++) { // Note: the key code in the NSEvent does not map to anything we can use UniChar keyChar = (UniChar) [chars characterAtIndex: i]; - UniChar keySymChar = CKCH_CharForKeyCode(keyCode); + // Disabled due to crash on MacOS >= 13, see CKCH_CreateDictionaries() below + // UniChar keySymChar = CKCH_CharForKeyCode(keyCode); + UniChar keySymChar = 0; DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X, mods 0x%X/0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, (int)mods, (int)javaMods, (int)keySymChar); @@ -848,7 +891,9 @@ NS_ENDHANDLER insetsChangedID && sizeScreenPosInsetsChangedID && screenPositionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) { - CKCH_CreateDictionaries(); + // + // Disabled due to crash on MacOS >= 13, see CKCH_CreateDictionaries() below + // CKCH_CreateDictionaries(); return YES; } return NO; |