|
From: Elias N. <eli...@us...> - 2005-11-22 11:23:59
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7412/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: Removed current_* mode cache from display.c Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- display.h 22 Nov 2005 09:32:15 -0000 1.13 +++ display.h 22 Nov 2005 11:23:37 -0000 1.14 @@ -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, bool temporary); -extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp); +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); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- display.c 22 Nov 2005 09:32:15 -0000 1.22 +++ display.c 22 Nov 2005 11:23:37 -0000 1.23 @@ -64,10 +64,6 @@ } mode_data; } mode_info; -static int current_width; -static int current_height; -static int current_freq; - static bool getXF86VidModeVersion(JNIEnv *env, Display *disp, int *major, int *minor) { int event_base, error_base; @@ -226,7 +222,7 @@ return false; } -static bool setMode(JNIEnv *env, Display *disp, int screen, jint extension, int width, int height, int freq, bool temporary) { +static bool setMode(JNIEnv *env, Display *disp, int screen, jint extension, int width, int height, int freq) { int num_modes, i; mode_info *avail_modes = getDisplayModes(disp, screen, extension, &num_modes); if (avail_modes == NULL) { @@ -255,11 +251,6 @@ continue; } result = true; - if (!temporary) { - current_width = width; - current_height = height; - current_freq = freq; - } break; } } @@ -323,7 +314,7 @@ } } -static void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen) { +static void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer) { Display * disp = XOpenDisplay(NULL); if (disp == NULL) { throwException(env, "Could not open display"); @@ -333,20 +324,7 @@ XCloseDisplay(disp); } -void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject saved_gamma_ramp) { - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - printfDebugJava(env, "Could not open display"); - return; - } - if (!setMode(env, disp, screen, extension, current_width, current_height, current_freq, false)) - printfDebugJava(env, "Could not restore mode"); - XCloseDisplay(disp); - // Don't propagate error to caller - setGammaRamp(env, saved_gamma_ramp, screen); -} - -static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode, bool temporary) { +static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) { if (mode == NULL) { throwException(env, "mode must be non-null"); return false; @@ -363,7 +341,7 @@ throwException(env, "Could not open display"); return false; } - if (!setMode(env, disp, screen, extension, width, height, freq, temporary)) { + if (!setMode(env, disp, screen, extension, width, height, freq)) { XCloseDisplay(disp); throwException(env, "Could not switch mode."); return false; @@ -372,10 +350,16 @@ return true; } -void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, jobject saved_mode, bool temporary) { - if (!switchDisplayMode(env, screen, extension, saved_mode, temporary)) +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, gamma_ramp, screen); + setGammaRamp(env, screen, saved_gamma_ramp); } static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { @@ -406,11 +390,11 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { - switchDisplayMode(env, getCurrentScreen(), extension, mode, false); + 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, false); + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { @@ -418,6 +402,6 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { - setGammaRamp(env, gamma_buffer, getCurrentScreen()); + setGammaRamp(env, getCurrentScreen(), gamma_buffer); } 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.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- org_lwjgl_opengl_Display.c 22 Nov 2005 10:32:17 -0000 1.39 +++ org_lwjgl_opengl_Display.c 22 Nov 2005 11:23:37 -0000 1.40 @@ -190,19 +190,19 @@ updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode, true); + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode); } return true; } -static void acquireInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp) { +static void acquireInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp, jobject mode) { if (isLegacyFullscreen(window_mode) || !input_released) return; input_released = false; setRepeatMode(env, AutoRepeatModeOff); updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { - temporaryRestoreMode(env, getCurrentScreen(), extension, gamma_ramp); + temporaryRestoreMode(env, getCurrentScreen(), extension, gamma_ramp, mode); } } @@ -229,12 +229,12 @@ } } -static void checkInput(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) { +static void checkInput(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode, jobject current_mode) { Window win; int revert_mode; XGetInputFocus(getDisplay(), &win, &revert_mode); if (win == current_win) { - acquireInput(env, extension, window_mode, current_gamma); + acquireInput(env, extension, window_mode, current_gamma, current_mode); focused = true; } else { releaseInput(env, extension, window_mode, saved_gamma, saved_mode); @@ -242,7 +242,7 @@ } } -void handleMessages(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) { +void handleMessages(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode, jobject current_mode) { XEvent event; /* Window win; int revert_mode;*/ @@ -293,7 +293,7 @@ break; } } - checkInput(env, extension, window_mode, saved_gamma, current_gamma, saved_mode); + checkInput(env, extension, window_mode, saved_gamma, current_gamma, saved_mode, current_mode); } static void setWindowTitle(const char *title) { @@ -446,9 +446,9 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate - (JNIEnv *env, jclass clazz, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) + (JNIEnv *env, jclass clazz, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode, jobject current_mode) { - handleMessages(env, extension, window_mode, saved_gamma, current_gamma, saved_mode); + handleMessages(env, extension, window_mode, saved_gamma, current_gamma, saved_mode, current_mode); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) { |