aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/native/x11/Xmisc.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-03 07:14:55 +0100
committerSven Gothel <[email protected]>2010-11-03 07:14:55 +0100
commit2b24c35472c0cb570674833ea1626df47fb0d721 (patch)
tree8170c476c3568cb9b163ec848af7bdf3d30518ef /src/nativewindow/native/x11/Xmisc.c
parentaf3de7dd59bcebde68f3928868b5dde198978854 (diff)
NativeWindow: Provide 'setX11ErrorHandler(boolean onoff)'
Diffstat (limited to 'src/nativewindow/native/x11/Xmisc.c')
-rw-r--r--src/nativewindow/native/x11/Xmisc.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index 5a17bdb8f..831d94636 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -181,20 +181,25 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons
static JNIEnv * x11ErrorHandlerJNIEnv = NULL;
static XErrorHandler origErrorHandler = NULL ;
+static int errorHandlerBlocked = 0 ;
static int x11ErrorHandler(Display *dpy, XErrorEvent *e)
{
- fprintf(stderr, "Nativewindow X11 Error: Display %p, Code 0x%X, errno %s\n", dpy, e->error_code, strerror(errno));
- _throwNewRuntimeException(NULL, x11ErrorHandlerJNIEnv, "Nativewindow X11 Error: Display %p, Code 0x%X, errno %s",
+ _throwNewRuntimeException(NULL, x11ErrorHandlerJNIEnv, "Info: Nativewindow X11 Error: Display %p, Code 0x%X, errno %s",
dpy, e->error_code, strerror(errno));
+
+#if 0
if(NULL!=origErrorHandler) {
origErrorHandler(dpy, e);
}
+#endif
return 0;
}
static void x11ErrorHandlerEnable(Display *dpy, int onoff, JNIEnv * env) {
+ if(errorHandlerBlocked) return;
+
if(onoff) {
if(NULL==origErrorHandler) {
x11ErrorHandlerJNIEnv = env;
@@ -204,14 +209,22 @@ static void x11ErrorHandlerEnable(Display *dpy, int onoff, JNIEnv * env) {
origErrorHandler = XSetErrorHandler(x11ErrorHandler);
}
} else {
- if(NULL!=dpy) {
- XSync(dpy, False);
+ if(NULL!=origErrorHandler) {
+ if(NULL!=dpy) {
+ XSync(dpy, False);
+ }
+ XSetErrorHandler(origErrorHandler);
+ origErrorHandler = NULL;
}
- XSetErrorHandler(origErrorHandler);
- origErrorHandler = NULL;
}
}
+static void x11ErrorHandlerEnableBlocking(int onoff, JNIEnv * env) {
+ errorHandlerBlocked = 0 ;
+ x11ErrorHandlerEnable(NULL, onoff, env);
+ errorHandlerBlocked = onoff ;
+}
+
static XIOErrorHandler origIOErrorHandler = NULL;
@@ -240,7 +253,7 @@ static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) {
static int _initialized=0;
JNIEXPORT void JNICALL
-Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize(JNIEnv *env, jclass _unused, jboolean firstUIActionOnProcess) {
+Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize0(JNIEnv *env, jclass _unused, jboolean firstUIActionOnProcess) {
if(0==_initialized) {
if( JNI_TRUE == firstUIActionOnProcess ) {
if( 0 == XInitThreads() ) {
@@ -258,6 +271,11 @@ Java_com_jogamp_nativewindow_impl_x11_X11Util_initialize(JNIEnv *env, jclass _un
}
}
+JNIEXPORT void JNICALL
+Java_com_jogamp_nativewindow_impl_x11_X11Util_setX11ErrorHandler0(JNIEnv *env, jclass _unused, jboolean onoff) {
+ x11ErrorHandlerEnableBlocking(( JNI_TRUE == onoff ) ? 1 : 0, env);
+}
+
/* Java->C glue code:
* Java package: com.jogamp.nativewindow.impl.x11.X11Lib
* Java method: XVisualInfo XGetVisualInfo(long arg0, long arg1, XVisualInfo arg2, java.nio.IntBuffer arg3)