diff --git a/src/native/linux/display.c b/src/native/linux/display.c index 8619610f..52daa6fd 100644 --- a/src/native/linux/display.c +++ b/src/native/linux/display.c @@ -225,7 +225,7 @@ static bool setXrandrMode(Display *disp, int screen, mode_info *mode) { return true; } -static bool setMode(Display *disp, int screen, int width, int height, int freq/*, bool lock_mode*/) { +static bool setMode(Display *disp, int screen, int width, int height, int freq, bool temporary) { if (current_extension == NONE) return false; int num_modes, i; @@ -256,6 +256,11 @@ static bool setMode(Display *disp, int screen, int width, int height, int freq/* continue; } result = true; + if (!temporary) { + current_width = width; + current_height = height; + current_freq = freq; + } break; } } @@ -368,7 +373,7 @@ void temporaryRestoreMode(int screen) { printfDebug("Could not open display"); return; } - if (!setMode(disp, screen, current_width, current_height, current_freq)) + if (!setMode(disp, screen, current_width, current_height, current_freq, false)) printfDebug("Could not restore mode\n"); setCurrentGamma(disp, screen, NULL); XCloseDisplay(disp); @@ -392,20 +397,16 @@ void switchDisplayMode(JNIEnv * env, jobject mode, int screen) { throwException(env, "Could not open display"); return; } - if (setMode(disp, screen, width, height, freq)) { - current_width = width; - current_height = height; - current_freq = freq; - } else + if (!setMode(disp, screen, width, height, freq, false)) throwException(env, "Could not switch mode."); XCloseDisplay(disp); } -void resetDisplayMode(int screen) { +void resetDisplayMode(int screen, bool temporary) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) return; - if (!setMode(disp, screen, saved_width, saved_height, saved_freq)) { + if (!setMode(disp, screen, saved_width, saved_height, saved_freq, temporary)) { printfDebug("Failed to reset mode"); } if (saved_gamma_ramp_length > 0) { diff --git a/src/native/linux/display.h b/src/native/linux/display.h index cc8e484e..9da45c30 100644 --- a/src/native/linux/display.h +++ b/src/native/linux/display.h @@ -43,6 +43,7 @@ #define _DISPLAY_H #include +#include "common_tools.h" typedef enum {XRANDR, XF86VIDMODE, NONE} extension; @@ -50,7 +51,7 @@ extern int getScreenModeWidth(void); extern int getScreenModeHeight(void); extern jobject initDisplay(JNIEnv *env, int screen); extern void switchDisplayMode(JNIEnv * env, jobject mode, int screen); -extern void resetDisplayMode(int screen); +extern void resetDisplayMode(int screen, bool temporary); extern jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen); extern int getGammaRampLength(int screen); extern void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen); diff --git a/src/native/linux/org_lwjgl_opengl_Display.c b/src/native/linux/org_lwjgl_opengl_Display.c index 3532f41a..6745c2cc 100644 --- a/src/native/linux/org_lwjgl_opengl_Display.c +++ b/src/native/linux/org_lwjgl_opengl_Display.c @@ -207,7 +207,7 @@ bool releaseInput(void) { updateInputGrab(); if (current_window_mode == FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(getCurrentScreen()); + resetDisplayMode(getCurrentScreen(), true); } return true; } @@ -664,7 +664,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSwitchDisplayMode(JNIEnv * } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_resetDisplayMode(JNIEnv *env, jclass clazz) { - resetDisplayMode(getCurrentScreen()); + resetDisplayMode(getCurrentScreen(), false); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Display_getGammaRampLength(JNIEnv *env, jclass clazz) {