Linux: Moved another Display instance to java

This commit is contained in:
Elias Naur 2006-10-23 14:16:40 +00:00
parent 8c5f601e31
commit 1a83741b89
3 changed files with 16 additions and 17 deletions

View File

@ -485,13 +485,22 @@ final class LinuxDisplay implements DisplayImplementation {
private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException {
lockAWT();
try {
nSetGammaRamp(getScreen(), native_gamma);
setGammaRampOnTmpDisplay(native_gamma);
current_gamma = native_gamma;
} finally {
unlockAWT();
}
}
private static native void nSetGammaRamp(int screen, ByteBuffer gammaRamp) throws LWJGLException;
private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
long tmp_display = openDisplay();
try {
nSetGammaRamp(tmp_display, getScreen(), native_gamma);
} finally {
closeDisplay(tmp_display);
}
}
private static native void nSetGammaRamp(long display, int screen, ByteBuffer gammaRamp) throws LWJGLException;
private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException {
return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining());
@ -696,7 +705,7 @@ final class LinuxDisplay implements DisplayImplementation {
nIconifyWindow(getDisplay(), getWindow(), getScreen());
try {
nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode);
nSetGammaRamp(getScreen(), saved_gamma);
setGammaRampOnTmpDisplay(saved_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage());
}
@ -713,7 +722,7 @@ final class LinuxDisplay implements DisplayImplementation {
if (current_window_mode == FULLSCREEN_NETWM) {
try {
nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode);
nSetGammaRamp(getScreen(), current_gamma);
setGammaRampOnTmpDisplay(current_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore mode: " + e.getMessage());
}

View File

@ -319,16 +319,6 @@ static void setGamma(JNIEnv *env, Display *disp, int screen, jobject 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");
return;
}
setGamma(env, disp, screen, gamma_ramp_buffer);
XCloseDisplay(disp);
}
bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) {
if (mode == NULL) {
throwException(env, "mode must be non-null");
@ -422,7 +412,8 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JN
return (jint)getGammaRampLengthOfDisplay(env, disp, screen);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jint screen, jobject gamma_buffer) {
setGammaRamp(env, screen, gamma_buffer);
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) {
Display *disp = (Display *)(intptr_t)display;
setGamma(env, disp, screen, gamma_buffer);
}

View File

@ -46,6 +46,5 @@
#include "common_tools.h"
extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode);
extern void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer);
#endif