diff options
author | Sven Gothel <[email protected]> | 2010-11-03 07:14:55 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-03 07:14:55 +0100 |
commit | 2b24c35472c0cb570674833ea1626df47fb0d721 (patch) | |
tree | 8170c476c3568cb9b163ec848af7bdf3d30518ef /src/nativewindow/classes/com | |
parent | af3de7dd59bcebde68f3928868b5dde198978854 (diff) |
NativeWindow: Provide 'setX11ErrorHandler(boolean onoff)'
Diffstat (limited to 'src/nativewindow/classes/com')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java index 524b142ec..c449d8f86 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java @@ -33,8 +33,6 @@ package com.jogamp.nativewindow.impl.x11; -import java.util.HashMap; -import java.util.Map; import com.jogamp.common.util.LongObjectHashMap; import javax.media.nativewindow.*; @@ -58,6 +56,9 @@ public class X11Util { private static boolean isFirstX11ActionOnProcess = false; private static boolean isInit = false; + private static int setX11ErrorHandlerRecCount = 0; + private static Object setX11ErrorHandlerLock = new Object(); + public static synchronized void initSingleton(boolean firstX11ActionOnProcess) { if(!isInit) { NWJNILibLoader.loadNativeWindow("x11"); @@ -65,8 +66,8 @@ public class X11Util { /** * Always issue XInitThreads() since we have independent * off-thread created Display connections able to utilize multithreading, ie NEWT */ - initialize( true ); - // initialize( firstX11ActionOnProcess ); + initialize0( true ); + // initialize0( firstX11ActionOnProcess ); isFirstX11ActionOnProcess = firstX11ActionOnProcess; if(DEBUG) { @@ -76,6 +77,25 @@ public class X11Util { } } + public static void setX11ErrorHandler(boolean onoff) { + synchronized(setX11ErrorHandlerLock) { + if(onoff) { + if(0==setX11ErrorHandlerRecCount) { + setX11ErrorHandler0(true); + } + setX11ErrorHandlerRecCount++; + } else { + if(0 >= setX11ErrorHandlerRecCount) { + throw new InternalError(); + } + setX11ErrorHandlerRecCount--; + if(0==setX11ErrorHandlerRecCount) { + setX11ErrorHandler0(false); + } + } + } + } + public static boolean isFirstX11ActionOnProcess() { return isFirstX11ActionOnProcess; } @@ -574,5 +594,6 @@ public class X11Util { X11Lib.XUnlockDisplay(handle); } - private static native void initialize(boolean firstUIActionOnProcess); + private static native void initialize0(boolean firstUIActionOnProcess); + private static native void setX11ErrorHandler0(boolean onoff); } |