diff options
Diffstat (limited to 'src/nativewindow/native')
-rw-r--r-- | src/nativewindow/native/JVM_Tool.c | 51 | ||||
-rw-r--r-- | src/nativewindow/native/x11/Xmisc.c | 50 |
2 files changed, 36 insertions, 65 deletions
diff --git a/src/nativewindow/native/JVM_Tool.c b/src/nativewindow/native/JVM_Tool.c deleted file mode 100644 index ce827129c..000000000 --- a/src/nativewindow/native/JVM_Tool.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -#include <jni.h> - -JNIEXPORT jboolean JNICALL -Java_com_jogamp_nativewindow_impl_jvm_JVMUtil_initialize(JNIEnv *env, jclass _unused, jobject nioBuffer) { - int res; - void * ptr = NULL; - if (nioBuffer != NULL) { - ptr = (void *) (*env)->GetDirectBufferAddress(env, nioBuffer); - } - return ( NULL==ptr ) ? JNI_FALSE : JNI_TRUE ; -} - diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 4320a8f12..52449ae84 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -128,6 +128,7 @@ static void _FatalError(JNIEnv *env, const char* msg, ...) va_end(ap); fprintf(stderr, buffer); + fprintf(stderr, "\n"); (*env)->FatalError(env, buffer); } @@ -201,32 +202,54 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons (*env)->ThrowNew(env, clazzRuntimeException, buffer); } +static JNIEnv * x11ErrorHandlerJNIEnv = NULL; +static XErrorHandler origErrorHandler = NULL ; + +static int x11ErrorHandler(Display *dpy, XErrorEvent *e) +{ + _throwNewRuntimeException(NULL, x11ErrorHandlerJNIEnv, "Nativewindow X11 Error: Display %p, Code 0x%X", dpy, e->error_code); + + return 0; +} + +static void x11ErrorHandlerEnable(int onoff, JNIEnv * env) { + if(onoff) { + if(NULL==origErrorHandler) { + x11ErrorHandlerJNIEnv = env; + origErrorHandler = XSetErrorHandler(x11ErrorHandler); + } + } else { + XSetErrorHandler(origErrorHandler); + origErrorHandler = NULL; + } +} + + static XIOErrorHandler origIOErrorHandler = NULL; -static JNIEnv * displayIOErrorHandlerJNIEnv = NULL; -static int displayIOErrorHandler(Display *dpy) +static int x11IOErrorHandler(Display *dpy) { - _FatalError(displayIOErrorHandlerJNIEnv, "Nativewindow X11 IOError: Display %p not available", dpy); + _FatalError(x11ErrorHandlerJNIEnv, "Nativewindow X11 IOError: Display %p not available", dpy); origIOErrorHandler(dpy); return 0; } -static void displayIOErrorHandlerEnable(int onoff, JNIEnv * env) { +static void x11IOErrorHandlerEnable(int onoff, JNIEnv * env) { if(onoff) { if(NULL==origIOErrorHandler) { - displayIOErrorHandlerJNIEnv = env; - origIOErrorHandler = XSetIOErrorHandler(displayIOErrorHandler); + x11ErrorHandlerJNIEnv = env; + origIOErrorHandler = XSetIOErrorHandler(x11IOErrorHandler); } } else { XSetIOErrorHandler(origIOErrorHandler); origIOErrorHandler = NULL; - displayIOErrorHandlerJNIEnv = NULL; } } JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Util_installIOErrorHandler(JNIEnv *env, jclass _unused) { - displayIOErrorHandlerEnable(1, env); + x11ErrorHandlerEnable(1, env); + x11IOErrorHandlerEnable(1, env); } JNIEXPORT jlong JNICALL @@ -345,6 +368,7 @@ Java_com_jogamp_nativewindow_impl_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclas * Class: com_jogamp_nativewindow_impl_x11_X11Lib * Method: CreateDummyWindow * Signature: (JIJ)J + */ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummyWindow (JNIEnv *env, jobject obj, jlong display, jint screen_index, jlong visualID) { @@ -370,7 +394,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummy } if(visualID<0) { - _throwNewRuntimeException(NULL, env, "invalid VisualID ..\n"); + _throwNewRuntimeException(NULL, env, "invalid VisualID .."); return 0; } @@ -396,7 +420,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummy if (visual==NULL) { - _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!\n"); + _throwNewRuntimeException(dpy, env, "could not query Visual by given VisualID, bail out!"); return 0; } @@ -440,13 +464,13 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_CreateDummy return (jlong) window; } - */ /* * Class: com_jogamp_nativewindow_impl_x11_X11Lib * Method: DestroyDummyWindow * Signature: (JJ)V + */ JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_DestroyDummyWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { @@ -454,7 +478,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_DestroyDummy Window w = (Window) window; if(NULL==dpy) { - _throwNewRuntimeException(NULL, env, "invalid display connection..\n"); + _throwNewRuntimeException(NULL, env, "invalid display connection.."); return; } XLockDisplay(dpy) ; @@ -467,5 +491,3 @@ JNIEXPORT void JNICALL Java_com_jogamp_nativewindow_impl_x11_X11Lib_DestroyDummy XUnlockDisplay(dpy) ; } - */ - |