summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-07-05 14:32:00 +0200
committerSven Gothel <[email protected]>2012-07-05 14:32:00 +0200
commitfd06292d4a208cbd613f4bdce7cae12e075e70ec (patch)
tree75bf50a19e631c22f575f516248c5681dab3eda9 /src/nativewindow/classes/jogamp
parent9b35c57425b0a5f6b789b9b43a62a8b64be51d86 (diff)
NativeWindow/Newt X11ErrorHandler enhancement / unification - don't throw exceptions. Handles also XAWT BadMatch X_SetInputFocus.
X11ErrorHandler code now dumps proper information about the opcode and error message and the running Java thread. Having propery "nativewindow.debug.X11Util.XErrorStackDump" or "nativewindow.debug=all' set, a stack trace is dumped. Since the X11ErrorHandler may catch an XAWT error: BadMatch X_SetInputFocus, we cannot throw an exception and better keep running.
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
index 3c197062a..fcc374751 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -81,9 +81,10 @@ public class X11Util {
/** Value is <code>true</code>, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */
public static final boolean HAS_XLOCKDISPLAY_BUG = true;
- private static final boolean DEBUG = Debug.debug("X11Util");
- private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true);
-
+ public static final boolean DEBUG = Debug.debug("X11Util");
+ public static final boolean XSYNC_ENABLED = Debug.isPropertyDefined("nativewindow.debug.X11Util.XSync", true);
+ public static final boolean XERROR_STACKDUMP = DEBUG || Debug.isPropertyDefined("nativewindow.debug.X11Util.XErrorStackDump", true);
+ private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.isPropertyDefined("nativewindow.debug.X11Util.TraceDisplayLifecycle", true);
private static String nullDisplayName = null;
private static boolean isX11LockAvailable = false;
private static boolean requiresX11Lock = true;
@@ -105,11 +106,14 @@ public class X11Util {
}
final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess;
- final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess );
+ final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess, XERROR_STACKDUMP);
isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ;
final long dpy = X11Lib.XOpenDisplay(null);
if(0 != dpy) {
+ if(XSYNC_ENABLED) {
+ X11Lib.XSynchronize(dpy, true);
+ }
try {
nullDisplayName = X11Lib.XDisplayString(dpy);
} finally {
@@ -124,7 +128,8 @@ public class X11Util {
", requiresX11Lock "+requiresX11Lock+
", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+
", isX11LockAvailable "+isX11LockAvailable+
- ", X11 Display(NULL) <"+nullDisplayName+">");
+ ", X11 Display(NULL) <"+nullDisplayName+">"+
+ ", XSynchronize Enabled: "+XSYNC_ENABLED);
// Thread.dumpStack();
}
}
@@ -455,6 +460,9 @@ public class X11Util {
NativeWindowFactory.getDefaultToolkitLock().lock();
try {
long handle = X11Lib.XOpenDisplay(arg0);
+ if(XSYNC_ENABLED && 0 != handle) {
+ X11Lib.XSynchronize(handle, true);
+ }
if(TRACE_DISPLAY_LIFECYCLE) {
System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle));
// Thread.dumpStack();
@@ -520,7 +528,10 @@ public class X11Util {
return false;
}
- private static native boolean initialize0(boolean firstUIActionOnProcess);
+ private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI
+ private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI
+
+ private static native boolean initialize0(boolean firstUIActionOnProcess, boolean debug);
private static native void shutdown0();
private static native void setX11ErrorHandler0(boolean onoff, boolean quiet);
}