Linux: Fixed problem with updating screen dimension globals

This commit is contained in:
Elias Naur 2004-09-22 19:56:02 +00:00
parent 8b691bbe78
commit 9cb5176ce7
3 changed files with 14 additions and 12 deletions

View File

@ -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) {

View File

@ -43,6 +43,7 @@
#define _DISPLAY_H
#include <jni.h>
#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);

View File

@ -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) {