|
From: Elias N. <eli...@us...> - 2005-11-22 13:53:21
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15159/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: More native code refactoring Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- display.h 22 Nov 2005 11:23:37 -0000 1.14 +++ display.h 22 Nov 2005 13:53:13 -0000 1.15 @@ -45,7 +45,7 @@ #include <jni.h> #include "common_tools.h" -extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, jobject saved_mode); -extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, jobject saved_mode); +extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode); +extern void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- display.c 22 Nov 2005 11:23:37 -0000 1.23 +++ display.c 22 Nov 2005 13:53:13 -0000 1.24 @@ -68,11 +68,11 @@ int event_base, error_base; if (!XF86VidModeQueryExtension(disp, &event_base, &error_base)) { - printfDebugJava(env, "XF86VidMode extension not available"); + throwException(env, "XF86VidMode extension not available"); return false; } if (!XF86VidModeQueryVersion(disp, major, minor)) { - printfDebugJava(env, "Could not query XF86VidMode version"); + throwException(env, "Could not query XF86VidMode version"); return false; } printfDebugJava(env, "XF86VidMode extension version %i.%i", *major, *minor); @@ -83,11 +83,11 @@ int event_base, error_base; if (!XRRQueryExtension(disp, &event_base, &error_base)) { - printfDebugJava(env, "Xrandr extension not available"); + throwException(env, "Xrandr extension not available"); return false; } if (!XRRQueryVersion(disp, major, minor)) { - printfDebugJava(env, "Could not query Xrandr version"); + throwException(env, "Could not query Xrandr version"); return false; } printfDebugJava(env, "Xrandr extension version %i.%i", *major, *minor); @@ -108,12 +108,12 @@ return major_ver >= 2; } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXrandrSupported(JNIEnv *env, jclass unused) { +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported(JNIEnv *env, jclass unused) { jboolean result = isXrandrSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE; return result; } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXF86VidModeSupported(JNIEnv *env, jclass unused) { +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported(JNIEnv *env, jclass unused) { jboolean result = isXF86VidModeSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE; return result; } @@ -262,7 +262,7 @@ static int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { int ramp_size; if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) { - printfDebugJava(env, "XF86VidModeGetGammaRampSize call failed"); + throwException(env, "XF86VidModeGetGammaRampSize call failed"); return 0; } return ramp_size; @@ -304,6 +304,8 @@ } static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer) { + if (ramp_buffer == NULL) + return; unsigned short *ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer); jlong capacity = (*env)->GetDirectBufferCapacity(env, ramp_buffer); int size = capacity/(sizeof(unsigned short)*3); @@ -314,7 +316,7 @@ } } -static void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer) { +void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer) { Display * disp = XOpenDisplay(NULL); if (disp == NULL) { throwException(env, "Could not open display"); @@ -324,7 +326,7 @@ XCloseDisplay(disp); } -static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) { +bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) { if (mode == NULL) { throwException(env, "mode must be non-null"); return false; @@ -350,18 +352,6 @@ return true; } -void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject current_gamma_ramp, jobject current_mode) { - switchDisplayMode(env, screen, extension, current_mode); - // Don't propagate error to caller - setGammaRamp(env, screen, current_gamma_ramp); -} - -void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject saved_gamma_ramp, jobject saved_mode) { - if (!switchDisplayMode(env, screen, extension, saved_mode)) - return; - setGammaRamp(env, screen, saved_gamma_ramp); -} - static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { int num_modes, i; mode_info *avail_modes; @@ -393,10 +383,6 @@ switchDisplayMode(env, getCurrentScreen(), extension, mode); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp, jobject saved_mode) { - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode); -} - JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { return (jint)getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); } Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- org_lwjgl_opengl_Display.c 22 Nov 2005 11:23:37 -0000 1.40 +++ org_lwjgl_opengl_Display.c 22 Nov 2005 13:53:13 -0000 1.41 @@ -190,7 +190,8 @@ updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode); + switchDisplayMode(env, getCurrentScreen(), extension, saved_mode); + setGammaRamp(env, getCurrentScreen(), gamma_ramp); } return true; } @@ -202,7 +203,8 @@ setRepeatMode(env, AutoRepeatModeOff); updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { - temporaryRestoreMode(env, getCurrentScreen(), extension, gamma_ramp, mode); + switchDisplayMode(env, getCurrentScreen(), extension, mode); + setGammaRamp(env, getCurrentScreen(), gamma_ramp); } } @@ -345,7 +347,7 @@ Atom netwm_supported_atom = XInternAtom(getDisplay(), "_NET_SUPPORTED", False); int result = XGetWindowProperty(getDisplay(), RootWindow(getDisplay(), getCurrentScreen()), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list); if (result != Success) { - printfDebugJava(env, "Unable to query _NET_SUPPORTED window property"); + throwException(env, "Unable to query _NET_SUPPORTED window property"); return false; } Atom fullscreen_atom = XInternAtom(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False); |