You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
1
|
2
(14) |
3
|
4
(5) |
5
(3) |
|
6
|
7
(1) |
8
|
9
|
10
(3) |
11
|
12
|
|
13
|
14
|
15
(1) |
16
(2) |
17
|
18
|
19
|
|
20
(4) |
21
(18) |
22
(10) |
23
(6) |
24
(3) |
25
|
26
|
|
27
|
28
(4) |
29
|
30
|
|
|
|
|
From: Elias N. <eli...@us...> - 2005-11-21 22:37:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1773/src/native/linux Modified Files: display.c Log Message: Linux: fixed an issue with Xrandr timestamps Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- display.c 21 Nov 2005 22:21:29 -0000 1.20 +++ display.c 21 Nov 2005 22:37:14 -0000 1.21 @@ -206,7 +206,8 @@ Status status; Drawable root_window = RootWindow(disp, screen); XRRScreenConfiguration *screen_configuration = XRRGetScreenInfo(disp, root_window); - XRRConfigTimes(screen_configuration, timestamp); + Time config_time; + *timestamp = XRRConfigTimes(screen_configuration, &config_time); Rotation current_rotation; XRRConfigRotations(screen_configuration, ¤t_rotation); status = XRRSetScreenConfigAndRate(disp, screen_configuration, root_window, mode->mode_data.size_index, current_rotation, mode->freq, *timestamp); @@ -241,7 +242,7 @@ return false; } bool result = false; - for ( i = 0; i < num_modes; ++i ) { + for (i = 0; i < num_modes; ++i) { printfDebugJava(env, "Mode %d: %dx%d @%d", i, avail_modes[i].width, avail_modes[i].height, avail_modes[i].freq); if (avail_modes[i].width == width && avail_modes[i].height == height && avail_modes[i].freq == freq) { switch (extension) { |
|
From: Elias N. <eli...@us...> - 2005-11-21 22:21:43
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30869/src/native/linux Modified Files: display.c Log Message: Linux: let exceptions from display.c propagate to LinuxDisplay.java Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- display.c 21 Nov 2005 21:59:11 -0000 1.19 +++ display.c 21 Nov 2005 22:21:29 -0000 1.20 @@ -319,30 +319,24 @@ return ramp_buffer; } -static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer, bool throw_on_error) { +static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer) { 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); if (size == 0) return; if (XF86VidModeSetGammaRamp(disp, screen, size, ramp_ptr, ramp_ptr + size, ramp_ptr + size*2) == False) { - if (throw_on_error) - throwException(env, "Could not set gamma ramp."); - else - printfDebugJava(env, "Could not set gamma ramp."); + throwException(env, "Could not set gamma ramp."); } } -static void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen, bool throw_on_error) { +static void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen) { Display * disp = XOpenDisplay(NULL); if (disp == NULL) { - if (throw_on_error) - throwException(env, "Could not open display"); - else - printfDebugJava(env, "Could not open display"); + throwException(env, "Could not open display"); return; } - setGamma(env, disp, screen, gamma_ramp_buffer, throw_on_error); + setGamma(env, disp, screen, gamma_ramp_buffer); XCloseDisplay(disp); } @@ -356,15 +350,12 @@ printfDebugJava(env, "Could not restore mode"); XCloseDisplay(disp); // Don't propagate error to caller - setGammaRamp(env, saved_gamma_ramp, screen, false); + setGammaRamp(env, saved_gamma_ramp, screen); } -static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode, bool temporary, bool throw_on_error) { +static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode, bool temporary) { if (mode == NULL) { - if (throw_on_error) - throwException(env, "mode must be non-null"); - else - printfDebugJava(env, "Ignored null mode"); + throwException(env, "mode must be non-null"); return false; } jclass cls_displayMode = (*env)->GetObjectClass(env, mode); @@ -376,18 +367,12 @@ int freq = (*env)->GetIntField(env, mode, fid_freq); Display *disp = XOpenDisplay(NULL); if (disp == NULL) { - if (throw_on_error) - throwException(env, "Could not open display"); - else - printfDebugJava(env, "Could not open display"); + throwException(env, "Could not open display"); return false; } if (!setMode(env, disp, screen, extension, width, height, freq, temporary)) { XCloseDisplay(disp); - if (throw_on_error) - throwException(env, "Could not switch mode."); - else - printfDebugJava(env, "Could not switch mode"); + throwException(env, "Could not switch mode."); return false; } XCloseDisplay(disp); @@ -395,9 +380,9 @@ } void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, jobject saved_mode, bool temporary) { - if (!switchDisplayMode(env, screen, extension, saved_mode, temporary, false)) + if (!switchDisplayMode(env, screen, extension, saved_mode, temporary)) return; - setGammaRamp(env, gamma_ramp, screen, false); + setGammaRamp(env, gamma_ramp, screen); } static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { @@ -428,7 +413,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { - switchDisplayMode(env, getCurrentScreen(), extension, mode, false, true); + switchDisplayMode(env, getCurrentScreen(), extension, mode, false); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp, jobject saved_mode) { @@ -440,6 +425,6 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { - setGammaRamp(env, gamma_buffer, getCurrentScreen(), true); + setGammaRamp(env, gamma_buffer, getCurrentScreen()); } |
|
From: Elias N. <eli...@us...> - 2005-11-21 22:21:42
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30869/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: let exceptions from display.c propagate to LinuxDisplay.java Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- LinuxDisplay.java 21 Nov 2005 21:59:11 -0000 1.34 +++ LinuxDisplay.java 21 Nov 2005 22:21:28 -0000 1.35 @@ -260,11 +260,13 @@ lockAWT(); try { nResetDisplayMode(current_displaymode_extension, saved_gamma, saved_mode); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while resetting mode: " + e); } finally { unlockAWT(); } } - private static native void nResetDisplayMode(int extension, ByteBuffer gamma_ramp, DisplayMode saved_mode); + private static native void nResetDisplayMode(int extension, ByteBuffer gamma_ramp, DisplayMode saved_mode) throws LWJGLException; public int getGammaRampLength() { lockAWT(); @@ -383,10 +385,14 @@ public void update() { lockAWT(); - nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma, saved_mode); + try { + nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma, saved_mode); + } catch (LWJGLException e) { + LWJGLUtil.log("Caught exception while processing messages: " + e); + } unlockAWT(); } - private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma, DisplayMode saved_mode); + private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma, DisplayMode saved_mode) throws LWJGLException; public void reshape(int x, int y, int width, int height) { lockAWT(); |
|
From: Elias N. <eli...@us...> - 2005-11-21 21:59:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24256/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: Moved saved display mode from C to LinuxDisplay.java Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- display.h 21 Nov 2005 18:25:30 -0000 1.11 +++ display.h 21 Nov 2005 21:59:11 -0000 1.12 @@ -47,7 +47,7 @@ extern int getScreenModeWidth(void); extern int getScreenModeHeight(void); -extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary); +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); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- display.c 21 Nov 2005 18:25:30 -0000 1.18 +++ display.c 21 Nov 2005 21:59:11 -0000 1.19 @@ -64,9 +64,6 @@ } mode_data; } mode_info; -static int saved_width; -static int saved_height; -static int saved_freq; static int current_width; static int current_height; static int current_freq; @@ -208,7 +205,7 @@ static Status trySetXrandrMode(Display *disp, int screen, mode_info *mode, Time *timestamp) { Status status; Drawable root_window = RootWindow(disp, screen); - XRRScreenConfiguration *screen_configuration = XRRGetScreenInfo (disp, root_window); + XRRScreenConfiguration *screen_configuration = XRRGetScreenInfo(disp, root_window); XRRConfigTimes(screen_configuration, timestamp); Rotation current_rotation; XRRConfigRotations(screen_configuration, ¤t_rotation); @@ -228,8 +225,9 @@ status = trySetXrandrMode(disp, screen, mode, &new_timestamp); if (status == 0) return true; // Success - if (new_timestamp == timestamp) + if (new_timestamp == timestamp) { return false; // Failure, and the stamps are equal meaning that the failure is not merely transient + } timestamp = new_timestamp; } return false; @@ -277,7 +275,7 @@ return result; } -int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { +static int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { int ramp_size; if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) { printfDebugJava(env, "XF86VidModeGetGammaRampSize call failed"); @@ -305,36 +303,6 @@ return native_ramp; } -jobject initDisplay(JNIEnv *env, int screen, jint extension) { - int num_modes; - mode_info *avail_modes; - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return NULL; - } - - avail_modes = getDisplayModes(disp, screen, extension, &num_modes); - if (avail_modes == NULL || num_modes == 0) { - throwException(env, "Could not get display modes"); - XCloseDisplay(disp); - return NULL; - } - saved_width = current_width = avail_modes[0].width; - saved_height = current_height = avail_modes[0].height; - saved_freq = current_freq = avail_modes[0].freq; - int bpp = XDefaultDepth(disp, screen); - printfDebugJava(env, "Original display dimensions: width %d, height %d freq %d", saved_width, saved_height, saved_freq); - jclass jclass_DisplayMode = (*env)->FindClass(env, "org/lwjgl/opengl/DisplayMode"); - jmethodID ctor = (*env)->GetMethodID(env, jclass_DisplayMode, "<init>", "(IIII)V"); - jobject newMode = (*env)->NewObject(env, jclass_DisplayMode, ctor, saved_width, saved_height, bpp, saved_freq); - - free(avail_modes); - - XCloseDisplay(disp); - return newMode; -} - JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused) { int ramp_size = getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); jobject ramp_buffer = newJavaManagedByteBuffer(env, sizeof(unsigned short)*3*ramp_size); @@ -365,6 +333,19 @@ } } +static void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen, bool throw_on_error) { + Display * disp = XOpenDisplay(NULL); + if (disp == NULL) { + if (throw_on_error) + throwException(env, "Could not open display"); + else + printfDebugJava(env, "Could not open display"); + return; + } + setGamma(env, disp, screen, gamma_ramp_buffer, throw_on_error); + XCloseDisplay(disp); +} + void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject saved_gamma_ramp) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { @@ -373,15 +354,18 @@ } if (!setMode(env, disp, screen, extension, current_width, current_height, current_freq, false)) printfDebugJava(env, "Could not restore mode"); - // Don't propagate error to caller - setGamma(env, disp, screen, saved_gamma_ramp, false); XCloseDisplay(disp); + // Don't propagate error to caller + setGammaRamp(env, saved_gamma_ramp, screen, false); } -void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension) { +static bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode, bool temporary, bool throw_on_error) { if (mode == NULL) { - throwException(env, "mode must be non-null"); - return; + if (throw_on_error) + throwException(env, "mode must be non-null"); + else + printfDebugJava(env, "Ignored null mode"); + return false; } jclass cls_displayMode = (*env)->GetObjectClass(env, mode); jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); @@ -392,28 +376,31 @@ int freq = (*env)->GetIntField(env, mode, fid_freq); Display *disp = XOpenDisplay(NULL); if (disp == NULL) { - throwException(env, "Could not open display"); - return; + if (throw_on_error) + throwException(env, "Could not open display"); + else + printfDebugJava(env, "Could not open display"); + return false; + } + if (!setMode(env, disp, screen, extension, width, height, freq, temporary)) { + XCloseDisplay(disp); + if (throw_on_error) + throwException(env, "Could not switch mode."); + else + printfDebugJava(env, "Could not switch mode"); + return false; } - if (!setMode(env, disp, screen, extension, width, height, freq, false)) - throwException(env, "Could not switch mode."); XCloseDisplay(disp); + return true; } -void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary) { - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - printfDebugJava(env, "Failed to contact X Server"); +void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, jobject saved_mode, bool temporary) { + if (!switchDisplayMode(env, screen, extension, saved_mode, temporary, false)) return; - } - if (!setMode(env, disp, screen, extension, saved_width, saved_height, saved_freq, temporary)) { - printfDebugJava(env, "Failed to reset mode"); - } - setGamma(env, disp, screen, gamma_ramp, false); - XCloseDisplay(disp); + setGammaRamp(env, gamma_ramp, screen, false); } -jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { +static jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { int num_modes, i; mode_info *avail_modes; int bpp = XDefaultDepth(disp, screen); @@ -436,26 +423,16 @@ return ret; } -void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen) { - Display * disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return; - } - setGamma(env, disp, screen, gamma_ramp_buffer, true); - XCloseDisplay(disp); -} - JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { return getAvailableDisplayModes(env, getDisplay(), getCurrentScreen(), extension); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { - switchDisplayMode(env, mode, getCurrentScreen(), extension); + switchDisplayMode(env, getCurrentScreen(), extension, mode, false, true); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp) { - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, false); +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); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { @@ -463,10 +440,6 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { - setGammaRamp(env, gamma_buffer, getCurrentScreen()); -} - -JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jclass clazz, jint extension) { - return initDisplay(env, getCurrentScreen(), extension); + setGammaRamp(env, gamma_buffer, getCurrentScreen(), true); } 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.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- org_lwjgl_opengl_Display.c 21 Nov 2005 18:25:30 -0000 1.37 +++ org_lwjgl_opengl_Display.c 21 Nov 2005 21:59:11 -0000 1.38 @@ -182,7 +182,7 @@ XChangeProperty (getDisplay(), getCurrentWindow(), motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long)); } -static bool releaseInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp) { +static bool releaseInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp, jobject saved_mode) { if (isLegacyFullscreen(window_mode) || input_released) return false; input_released = true; @@ -190,7 +190,7 @@ updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, true); + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, saved_mode, true); } return true; } @@ -229,7 +229,7 @@ } } -static void checkInput(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma) { +static void checkInput(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) { Window win; int revert_mode; XGetInputFocus(getDisplay(), &win, &revert_mode); @@ -237,12 +237,12 @@ acquireInput(env, extension, window_mode, current_gamma); focused = true; } else { - releaseInput(env, extension, window_mode, saved_gamma); + releaseInput(env, extension, window_mode, saved_gamma, saved_mode); focused = false; } } -void handleMessages(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma) { +void handleMessages(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) { XEvent event; /* Window win; int revert_mode;*/ @@ -293,7 +293,7 @@ break; } } - checkInput(env, extension, window_mode, saved_gamma, current_gamma); + checkInput(env, extension, window_mode, saved_gamma, current_gamma, saved_mode); } static void setWindowTitle(const char *title) { @@ -454,9 +454,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) + (JNIEnv *env, jclass clazz, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode) { - handleMessages(env, extension, window_mode, saved_gamma, current_gamma); + handleMessages(env, extension, window_mode, saved_gamma, current_gamma, saved_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) { |
|
From: Elias N. <eli...@us...> - 2005-11-21 21:59:18
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24256/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: Moved saved display mode from C to LinuxDisplay.java Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- LinuxDisplay.java 21 Nov 2005 16:50:11 -0000 1.33 +++ LinuxDisplay.java 21 Nov 2005 21:59:11 -0000 1.34 @@ -83,6 +83,9 @@ private static ByteBuffer saved_gamma; private static ByteBuffer current_gamma; + /** Saved mode to restore with */ + private static DisplayMode saved_mode; + private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { lockAWT(); try { @@ -256,12 +259,12 @@ public void resetDisplayMode() { lockAWT(); try { - nResetDisplayMode(current_displaymode_extension, saved_gamma); + nResetDisplayMode(current_displaymode_extension, saved_gamma, saved_mode); } finally { unlockAWT(); } } - private static native void nResetDisplayMode(int extension, ByteBuffer gamma_ramp); + private static native void nResetDisplayMode(int extension, ByteBuffer gamma_ramp, DisplayMode saved_mode); public int getGammaRampLength() { lockAWT(); @@ -320,10 +323,13 @@ current_displaymode_extension = getBestDisplayModeExtension(); if (current_displaymode_extension == NONE) throw new LWJGLException("No display mode extension is available"); - DisplayMode mode = nInit(current_displaymode_extension); + DisplayMode[] modes = getAvailableDisplayModes(); + if (modes == null || modes.length == 0) + throw new LWJGLException("No modes available"); + saved_mode = modes[0]; saved_gamma = getCurrentGammaRamp(); current_gamma = saved_gamma; - return mode; + return saved_mode; } finally { unlockAWT(); } @@ -377,10 +383,10 @@ public void update() { lockAWT(); - nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma); + nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma, saved_mode); unlockAWT(); } - private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma); + private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma, DisplayMode saved_mode); public void reshape(int x, int y, int width, int height) { lockAWT(); |
|
From: Elias N. <eli...@us...> - 2005-11-21 18:25:38
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv954/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: Moved some JNI functions Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- display.h 21 Nov 2005 16:50:11 -0000 1.10 +++ display.h 21 Nov 2005 18:25:30 -0000 1.11 @@ -47,12 +47,7 @@ extern int getScreenModeWidth(void); extern int getScreenModeHeight(void); -extern jobject initDisplay(JNIEnv *env, int screen, jint extension); -extern void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension); extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary); -extern jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension); -extern int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen); -extern void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen); extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- display.c 21 Nov 2005 16:50:11 -0000 1.17 +++ display.c 21 Nov 2005 18:25:30 -0000 1.18 @@ -445,3 +445,28 @@ setGamma(env, disp, screen, gamma_ramp_buffer, true); XCloseDisplay(disp); } + +JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { + return getAvailableDisplayModes(env, getDisplay(), getCurrentScreen(), extension); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { + switchDisplayMode(env, mode, getCurrentScreen(), extension); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp) { + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, false); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { + return (jint)getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { + setGammaRamp(env, gamma_buffer, getCurrentScreen()); +} + +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jclass clazz, jint extension) { + return initDisplay(env, getCurrentScreen(), extension); +} + 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.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- org_lwjgl_opengl_Display.c 21 Nov 2005 16:50:11 -0000 1.36 +++ org_lwjgl_opengl_Display.c 21 Nov 2005 18:25:30 -0000 1.37 @@ -459,30 +459,6 @@ handleMessages(env, extension, window_mode, saved_gamma, current_gamma); } -JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { - return getAvailableDisplayModes(env, getDisplay(), getCurrentScreen(), extension); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { - switchDisplayMode(env, mode, getCurrentScreen(), extension); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp) { - resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, false); -} - -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { - return (jint)getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { - setGammaRamp(env, gamma_buffer, getCurrentScreen()); -} - -JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jclass clazz, jint extension) { - return initDisplay(env, getCurrentScreen(), extension); -} - 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) { X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); GLXFBConfig *fb_config = NULL; |
|
From: Elias N. <eli...@us...> - 2005-11-21 16:50:22
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3375/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: Moved a display connection to java Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- LinuxDisplay.java 21 Nov 2005 16:32:34 -0000 1.32 +++ LinuxDisplay.java 21 Nov 2005 16:50:11 -0000 1.33 @@ -392,8 +392,13 @@ public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { lockAWT(); try { - DisplayMode[] modes = nGetAvailableDisplayModes(current_displaymode_extension); - return modes; + incDisplay(); + try { + DisplayMode[] modes = nGetAvailableDisplayModes(current_displaymode_extension); + return modes; + } finally { + decDisplay(); + } } finally { unlockAWT(); } |
|
From: Elias N. <eli...@us...> - 2005-11-21 16:50:19
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3375/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: Moved a display connection to java Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- display.h 21 Nov 2005 16:32:34 -0000 1.9 +++ display.h 21 Nov 2005 16:50:11 -0000 1.10 @@ -50,7 +50,7 @@ extern jobject initDisplay(JNIEnv *env, int screen, jint extension); extern void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension); extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary); -extern jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen, jint extension); +extern jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension); extern int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen); extern void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen); extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp); Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- display.c 21 Nov 2005 16:32:34 -0000 1.16 +++ display.c 21 Nov 2005 16:50:11 -0000 1.17 @@ -413,15 +413,9 @@ XCloseDisplay(disp); } -jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen, jint extension) { +jobjectArray getAvailableDisplayModes(JNIEnv * env, Display *disp, int screen, jint extension) { int num_modes, i; mode_info *avail_modes; - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return NULL; - } - int bpp = XDefaultDepth(disp, screen); avail_modes = getDisplayModes(disp, screen, extension, &num_modes); if (avail_modes == NULL) { @@ -439,7 +433,6 @@ (*env)->SetObjectArrayElement(env, ret, i, displayMode); } free(avail_modes); - XCloseDisplay(disp); return ret; } 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.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- org_lwjgl_opengl_Display.c 21 Nov 2005 16:32:34 -0000 1.35 +++ org_lwjgl_opengl_Display.c 21 Nov 2005 16:50:11 -0000 1.36 @@ -460,7 +460,7 @@ } JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { - return getAvailableDisplayModes(env, getCurrentScreen(), extension); + return getAvailableDisplayModes(env, getDisplay(), getCurrentScreen(), extension); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { |
|
From: Elias N. <eli...@us...> - 2005-11-21 16:32:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31869/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: Move gamma ramps to java code Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- LinuxDisplay.java 21 Nov 2005 13:32:52 -0000 1.31 +++ LinuxDisplay.java 21 Nov 2005 16:32:34 -0000 1.32 @@ -44,6 +44,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; +import org.lwjgl.BufferUtils; import org.lwjgl.input.Keyboard; final class LinuxDisplay implements DisplayImplementation { @@ -78,6 +79,28 @@ private static PeerInfo peer_info; + /** Saved gamma used to restore display settings */ + private static ByteBuffer saved_gamma; + private static ByteBuffer current_gamma; + + private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { + lockAWT(); + try { + incDisplay(); + try { + if (isXF86VidModeSupported()) + return nGetCurrentGammaRamp(); + else + return BufferUtils.createByteBuffer(0); + } finally { + decDisplay(); + } + } finally { + unlockAWT(); + } + } + private static native ByteBuffer nGetCurrentGammaRamp() throws LWJGLException; + private static int getBestDisplayModeExtension() throws LWJGLException { lockAWT(); try { @@ -233,30 +256,55 @@ public void resetDisplayMode() { lockAWT(); try { - nResetDisplayMode(current_displaymode_extension); + nResetDisplayMode(current_displaymode_extension, saved_gamma); } finally { unlockAWT(); } } - private static native void nResetDisplayMode(int extension); + private static native void nResetDisplayMode(int extension, ByteBuffer gamma_ramp); public int getGammaRampLength() { lockAWT(); - int length = nGetGammaRampLength(); - unlockAWT(); - return length; + try { + try { + incDisplay(); + int length; + if (isXF86VidModeSupported()) { + length = nGetGammaRampLength(); + } else + length = 0; + decDisplay(); + return length; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to get gamma ramp length: " + e); + return 0; + } + } finally { + unlockAWT(); + } } private static native int nGetGammaRampLength(); public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { lockAWT(); try { - nSetGammaRamp(gammaRamp); + incDisplay(); + boolean xf86_support = isXF86VidModeSupported(); + decDisplay(); + if (!xf86_support) + throw new LWJGLException("No gamma ramp support (Missing XF86VM extension)"); + current_gamma = convertToNativeRamp(gammaRamp); + nSetGammaRamp(current_gamma); } finally { unlockAWT(); } } - private static native void nSetGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; + private static native void nSetGammaRamp(ByteBuffer gammaRamp) throws LWJGLException; + + private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException { + return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining()); + } + private static native ByteBuffer nConvertToNativeRamp(FloatBuffer ramp, int offset, int length) throws LWJGLException; public String getAdapter() { return null; @@ -273,6 +321,8 @@ if (current_displaymode_extension == NONE) throw new LWJGLException("No display mode extension is available"); DisplayMode mode = nInit(current_displaymode_extension); + saved_gamma = getCurrentGammaRamp(); + current_gamma = saved_gamma; return mode; } finally { unlockAWT(); @@ -327,10 +377,10 @@ public void update() { lockAWT(); - nUpdate(current_displaymode_extension, current_window_mode); + nUpdate(current_displaymode_extension, current_window_mode, saved_gamma, current_gamma); unlockAWT(); } - private static native void nUpdate(int extension, int current_window_mode); + private static native void nUpdate(int extension, int current_window_mode, ByteBuffer saved_gamma, ByteBuffer current_gamma); public void reshape(int x, int y, int width, int height) { lockAWT(); |
|
From: Elias N. <eli...@us...> - 2005-11-21 16:32:42
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31869/src/native/linux Modified Files: display.c display.h org_lwjgl_opengl_Display.c Log Message: Linux: Move gamma ramps to java code Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- display.h 21 Nov 2005 13:22:52 -0000 1.8 +++ display.h 21 Nov 2005 16:32:34 -0000 1.9 @@ -49,10 +49,10 @@ extern int getScreenModeHeight(void); extern jobject initDisplay(JNIEnv *env, int screen, jint extension); extern void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension); -extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, bool temporary); +extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary); extern jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen, jint extension); -extern int getGammaRampLength(JNIEnv *env, int screen); +extern int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen); extern void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen); -extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension); +extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- display.c 21 Nov 2005 13:43:49 -0000 1.15 +++ display.c 21 Nov 2005 16:32:34 -0000 1.16 @@ -70,10 +70,6 @@ static int current_width; static int current_height; static int current_freq; -static int saved_gamma_ramp_length = 0; -static unsigned short *saved_ramp = NULL; -static unsigned short *current_ramp = NULL; -static int current_gamma_ramp_length = 0; int getScreenModeWidth(void) { return current_width; @@ -281,18 +277,8 @@ return result; } -static void freeSavedGammaRamps() { - free(saved_ramp); - saved_ramp = NULL; - saved_gamma_ramp_length = 0; -} - -static int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { +int getGammaRampLengthOfDisplay(JNIEnv *env, Display *disp, int screen) { int ramp_size; - if (!isXF86VidModeSupported(env, disp)) { - printfDebugJava(env, "XF86VidMode extension version >= 2 not found"); - return 0; - } if (XF86VidModeGetGammaRampSize(disp, screen, &ramp_size) == False) { printfDebugJava(env, "XF86VidModeGetGammaRampSize call failed"); return 0; @@ -300,15 +286,23 @@ return ramp_size; } -int getGammaRampLength(JNIEnv *env, int screen) { - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - printfDebugJava(env, "Could not open display"); - return 0; +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nConvertToNativeRamp(JNIEnv *env, jclass unused, jobject ramp_buffer, jint buffer_offset, jint length) { + const jfloat *ramp_ptr = (const jfloat *)(*env)->GetDirectBufferAddress(env, ramp_buffer) + buffer_offset; + jobject native_ramp = newJavaManagedByteBuffer(env, length*3*sizeof(unsigned short)); + if (native_ramp == NULL) { + throwException(env, "Failed to allocate gamma ramp buffer"); + return NULL; } - int length = getGammaRampLengthOfDisplay(env, disp, screen); - XCloseDisplay(disp); - return length; + unsigned short *native_ramp_ptr = (unsigned short *)(*env)->GetDirectBufferAddress(env, native_ramp); + int i; + for (i = 0; i < length; i++) { + float scaled_gamma = ramp_ptr[i]*0xffff; + short scaled_gamma_short = (unsigned short)round(scaled_gamma); + native_ramp_ptr[i] = scaled_gamma_short; + native_ramp_ptr[i + length] = scaled_gamma_short; + native_ramp_ptr[i + length*2] = scaled_gamma_short; + } + return native_ramp; } jobject initDisplay(JNIEnv *env, int screen, jint extension) { @@ -337,38 +331,41 @@ free(avail_modes); - /* Fetch the current gamma ramp */ - saved_gamma_ramp_length = getGammaRampLengthOfDisplay(env, disp, screen); - if (saved_gamma_ramp_length > 0) { - saved_ramp = (unsigned short *)malloc(sizeof(unsigned short)*3*saved_gamma_ramp_length); - if (!XF86VidModeGetGammaRamp(disp, screen, saved_gamma_ramp_length, saved_ramp, - saved_ramp + saved_gamma_ramp_length, saved_ramp + saved_gamma_ramp_length*2)) - freeSavedGammaRamps(); - } XCloseDisplay(disp); return newMode; } -static void freeCurrentGamma(void) { - if (current_ramp != NULL) { - free(current_ramp); - current_ramp = NULL; - current_gamma_ramp_length = 0; +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused) { + int ramp_size = getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); + jobject ramp_buffer = newJavaManagedByteBuffer(env, sizeof(unsigned short)*3*ramp_size); + if (ramp_buffer == NULL) { + throwException(env, "Could not allocate gamma ramp buffer"); + return NULL; + } + unsigned short *ramp = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer); + if (!XF86VidModeGetGammaRamp(getDisplay(), getCurrentScreen(), ramp_size, ramp, + ramp + ramp_size, ramp + ramp_size*2)) { + throwException(env, "Could not get the current gamma ramp"); + return NULL; } + return ramp_buffer; } -static void setCurrentGamma(Display *disp, int screen, JNIEnv *env) { - if (current_gamma_ramp_length == 0) +static void setGamma(JNIEnv *env, Display *disp, int screen, jobject ramp_buffer, bool throw_on_error) { + 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); + if (size == 0) return; - if (XF86VidModeSetGammaRamp(disp, screen, current_gamma_ramp_length, current_ramp, current_ramp, current_ramp) == False) { - if (env != NULL) + if (XF86VidModeSetGammaRamp(disp, screen, size, ramp_ptr, ramp_ptr + size, ramp_ptr + size*2) == False) { + if (throw_on_error) throwException(env, "Could not set gamma ramp."); else - printfDebugJava(env, "Could not set gamma ramp"); + printfDebugJava(env, "Could not set gamma ramp."); } } -void temporaryRestoreMode(JNIEnv *env, int screen, jint extension) { +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"); @@ -376,9 +373,9 @@ } if (!setMode(env, disp, screen, extension, current_width, current_height, current_freq, false)) printfDebugJava(env, "Could not restore mode"); - setCurrentGamma(disp, screen, NULL); - XCloseDisplay(disp); // Don't propagate error to caller + setGamma(env, disp, screen, saved_gamma_ramp, false); + XCloseDisplay(disp); } void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension) { @@ -403,7 +400,7 @@ XCloseDisplay(disp); } -void resetDisplayMode(JNIEnv *env, int screen, jint extension, bool temporary) { +void resetDisplayMode(JNIEnv *env, int screen, jint extension, jobject gamma_ramp, bool temporary) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { printfDebugJava(env, "Failed to contact X Server"); @@ -412,11 +409,7 @@ if (!setMode(env, disp, screen, extension, saved_width, saved_height, saved_freq, temporary)) { printfDebugJava(env, "Failed to reset mode"); } - if (saved_gamma_ramp_length > 0) { - XF86VidModeSetGammaRamp(disp, screen, saved_gamma_ramp_length, saved_ramp, saved_ramp + - saved_gamma_ramp_length, saved_ramp + saved_gamma_ramp_length*2); - } -// decDisplay(); + setGamma(env, disp, screen, gamma_ramp, false); XCloseDisplay(disp); } @@ -456,19 +449,6 @@ throwException(env, "Could not open display"); return; } - freeCurrentGamma(); - current_gamma_ramp_length = getGammaRampLengthOfDisplay(env, disp, screen); - if (current_gamma_ramp_length == 0) { - throwException(env, "Gamma ramp not supported"); - return; - } - const float *gamma_ramp = (const float *)(*env)->GetDirectBufferAddress(env, gamma_ramp_buffer); - current_ramp = (unsigned short *)malloc(sizeof(unsigned short)*current_gamma_ramp_length); - int i; - for (i = 0; i < current_gamma_ramp_length; i++) { - float scaled_gamma = gamma_ramp[i]*0xffff; - current_ramp[i] = (unsigned short)round(scaled_gamma); - } - setCurrentGamma(disp, screen, env); + setGamma(env, disp, screen, gamma_ramp_buffer, true); XCloseDisplay(disp); } 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.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- org_lwjgl_opengl_Display.c 21 Nov 2005 13:22:52 -0000 1.34 +++ org_lwjgl_opengl_Display.c 21 Nov 2005 16:32:34 -0000 1.35 @@ -182,7 +182,7 @@ XChangeProperty (getDisplay(), getCurrentWindow(), motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long)); } -static bool releaseInput(JNIEnv *env, jint extension, jint window_mode) { +static bool releaseInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp) { if (isLegacyFullscreen(window_mode) || input_released) return false; input_released = true; @@ -190,19 +190,19 @@ updateInputGrab(window_mode); if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(env, getCurrentScreen(), extension, true); + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, true); } return true; } -static void acquireInput(JNIEnv *env, jint extension, jint window_mode) { +static void acquireInput(JNIEnv *env, jint extension, jint window_mode, jobject gamma_ramp) { 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); + temporaryRestoreMode(env, getCurrentScreen(), extension, gamma_ramp); } } @@ -229,20 +229,20 @@ } } -static void checkInput(JNIEnv *env, jint extension, jint window_mode) { +static void checkInput(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma) { Window win; int revert_mode; XGetInputFocus(getDisplay(), &win, &revert_mode); if (win == current_win) { - acquireInput(env, extension, window_mode); + acquireInput(env, extension, window_mode, current_gamma); focused = true; } else { - releaseInput(env, extension, window_mode); + releaseInput(env, extension, window_mode, saved_gamma); focused = false; } } -void handleMessages(JNIEnv *env, jint extension, jint window_mode) { +void handleMessages(JNIEnv *env, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma) { XEvent event; /* Window win; int revert_mode;*/ @@ -293,7 +293,7 @@ break; } } - checkInput(env, extension, window_mode); + checkInput(env, extension, window_mode, saved_gamma, current_gamma); } static void setWindowTitle(const char *title) { @@ -454,9 +454,9 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate - (JNIEnv *env, jclass clazz, jint extension, jint window_mode) + (JNIEnv *env, jclass clazz, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma) { - handleMessages(env, extension, window_mode); + handleMessages(env, extension, window_mode, saved_gamma, current_gamma); } JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { @@ -467,12 +467,12 @@ switchDisplayMode(env, mode, getCurrentScreen(), extension); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension) { - resetDisplayMode(env, getCurrentScreen(), extension, false); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject gamma_ramp) { + resetDisplayMode(env, getCurrentScreen(), extension, gamma_ramp, false); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { - return (jint)getGammaRampLength(env, getCurrentScreen()); + return (jint)getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen()); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_buffer) { |
|
From: Elias N. <eli...@us...> - 2005-11-21 13:44:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24697/src/native/linux Modified Files: display.c Log Message: Linux: Folded three ramp arrays into one, to avoid multiple allocations Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- display.c 21 Nov 2005 13:32:52 -0000 1.14 +++ display.c 21 Nov 2005 13:43:49 -0000 1.15 @@ -71,9 +71,7 @@ static int current_height; static int current_freq; static int saved_gamma_ramp_length = 0; -static unsigned short *r_ramp = NULL; -static unsigned short *g_ramp = NULL; -static unsigned short *b_ramp = NULL; +static unsigned short *saved_ramp = NULL; static unsigned short *current_ramp = NULL; static int current_gamma_ramp_length = 0; @@ -284,12 +282,8 @@ } static void freeSavedGammaRamps() { - free(r_ramp); - free(g_ramp); - free(b_ramp); - r_ramp = NULL; - g_ramp = NULL; - b_ramp = NULL; + free(saved_ramp); + saved_ramp = NULL; saved_gamma_ramp_length = 0; } @@ -346,10 +340,9 @@ /* Fetch the current gamma ramp */ saved_gamma_ramp_length = getGammaRampLengthOfDisplay(env, disp, screen); if (saved_gamma_ramp_length > 0) { - r_ramp = (unsigned short *)malloc(sizeof(unsigned short)*saved_gamma_ramp_length); - g_ramp = (unsigned short *)malloc(sizeof(unsigned short)*saved_gamma_ramp_length); - b_ramp = (unsigned short *)malloc(sizeof(unsigned short)*saved_gamma_ramp_length); - if (!XF86VidModeGetGammaRamp(disp, screen, saved_gamma_ramp_length, r_ramp, g_ramp, b_ramp)) + saved_ramp = (unsigned short *)malloc(sizeof(unsigned short)*3*saved_gamma_ramp_length); + if (!XF86VidModeGetGammaRamp(disp, screen, saved_gamma_ramp_length, saved_ramp, + saved_ramp + saved_gamma_ramp_length, saved_ramp + saved_gamma_ramp_length*2)) freeSavedGammaRamps(); } XCloseDisplay(disp); @@ -420,7 +413,8 @@ printfDebugJava(env, "Failed to reset mode"); } if (saved_gamma_ramp_length > 0) { - XF86VidModeSetGammaRamp(disp, screen, saved_gamma_ramp_length, r_ramp, g_ramp, b_ramp); + XF86VidModeSetGammaRamp(disp, screen, saved_gamma_ramp_length, saved_ramp, saved_ramp + + saved_gamma_ramp_length, saved_ramp + saved_gamma_ramp_length*2); } // decDisplay(); XCloseDisplay(disp); |
|
From: Elias N. <eli...@us...> - 2005-11-21 13:33:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21543/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: Moved a display connection creation to java Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- LinuxDisplay.java 21 Nov 2005 13:22:52 -0000 1.30 +++ LinuxDisplay.java 21 Nov 2005 13:32:52 -0000 1.31 @@ -79,20 +79,28 @@ private static PeerInfo peer_info; private static int getBestDisplayModeExtension() throws LWJGLException { - if (System.getenv("LWJGL_DISABLE_XRANDR") == null && isXrandrSupported()) { - LWJGLUtil.log("Using Xrandr for display mode switching"); - return XRANDR; - } else if (isXF86VidModeSupported()) { - LWJGLUtil.log("Using XF86VidMode for display mode switching"); - return XF86VIDMODE; - } else { - LWJGLUtil.log("No display mode extensions available"); - return NONE; + lockAWT(); + try { + incDisplay(); + int result; + if (System.getenv("LWJGL_DISABLE_XRANDR") == null && isXrandrSupported()) { + LWJGLUtil.log("Using Xrandr for display mode switching"); + result = XRANDR; + } else if (isXF86VidModeSupported()) { + LWJGLUtil.log("Using XF86VidMode for display mode switching"); + result = XF86VIDMODE; + } else { + LWJGLUtil.log("No display mode extensions available"); + result = NONE; + } + decDisplay(); + return result; + } finally { + unlockAWT(); } - } - private static native boolean isXrandrSupported() throws LWJGLException; - private static native boolean isXF86VidModeSupported() throws LWJGLException; + private static native boolean isXrandrSupported(); + private static native boolean isXF86VidModeSupported(); private static boolean isNetWMFullscreenSupported() throws LWJGLException { if (System.getenv("LWJGL_DISABLE_NETWM") != null) |
|
From: Elias N. <eli...@us...> - 2005-11-21 13:32:59
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21543/src/native/linux Modified Files: display.c Log Message: Linux: Moved a display connection creation to java Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- display.c 21 Nov 2005 13:22:52 -0000 1.13 +++ display.c 21 Nov 2005 13:32:52 -0000 1.14 @@ -130,26 +130,12 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXrandrSupported(JNIEnv *env, jclass unused) { - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return JNI_FALSE; - } - - jboolean result = isXrandrSupported(env, disp) ? JNI_TRUE : JNI_FALSE; - XCloseDisplay(disp); + jboolean result = isXrandrSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE; return result; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXF86VidModeSupported(JNIEnv *env, jclass unused) { - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return JNI_FALSE; - } - - jboolean result = isXF86VidModeSupported(env, disp) ? JNI_TRUE : JNI_FALSE; - XCloseDisplay(disp); + jboolean result = isXF86VidModeSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE; return result; } |
|
From: Elias N. <eli...@us...> - 2005-11-21 13:23:13
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java Log Message: Linux: Moved display mode extension and window state handling up into java code Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- LinuxDisplay.java 23 Oct 2005 19:41:08 -0000 1.29 +++ LinuxDisplay.java 21 Nov 2005 13:22:52 -0000 1.30 @@ -47,6 +47,22 @@ import org.lwjgl.input.Keyboard; final class LinuxDisplay implements DisplayImplementation { + /** Window mode enum */ + private static final int FULLSCREEN_LEGACY = 1; + private static final int FULLSCREEN_NETWM = 2; + private static final int WINDOWED = 3; + + /** Current window mode */ + private static int current_window_mode = WINDOWED; + + /** Display mode switching API */ + private static final int XRANDR = 10; + private static final int XF86VIDMODE = 11; + private static final int NONE = 12; + + /** Current mode swithcing API */ + private static int current_displaymode_extension = NONE; + private static final int NUM_BUTTONS = 3; /** Keep track on the current awt lock owner to avoid @@ -62,6 +78,37 @@ private static PeerInfo peer_info; + private static int getBestDisplayModeExtension() throws LWJGLException { + if (System.getenv("LWJGL_DISABLE_XRANDR") == null && isXrandrSupported()) { + LWJGLUtil.log("Using Xrandr for display mode switching"); + return XRANDR; + } else if (isXF86VidModeSupported()) { + LWJGLUtil.log("Using XF86VidMode for display mode switching"); + return XF86VIDMODE; + } else { + LWJGLUtil.log("No display mode extensions available"); + return NONE; + } + + } + private static native boolean isXrandrSupported() throws LWJGLException; + private static native boolean isXF86VidModeSupported() throws LWJGLException; + + private static boolean isNetWMFullscreenSupported() throws LWJGLException { + if (System.getenv("LWJGL_DISABLE_NETWM") != null) + return false; + lockAWT(); + try { + incDisplay(); + boolean supported = nIsNetWMFullscreenSupported(); + decDisplay(); + return supported; + } finally { + unlockAWT(); + } + } + private static native boolean nIsNetWMFullscreenSupported(); + /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to * do just that. @@ -129,12 +176,26 @@ private static native void openDisplay() throws LWJGLException; private static native void closeDisplay(); + private static int getWindowMode(boolean fullscreen) throws LWJGLException { + if (fullscreen) { + if (current_displaymode_extension == XRANDR && isNetWMFullscreenSupported()) { + LWJGLUtil.log("Using NetWM for fullscreen window"); + return FULLSCREEN_NETWM; + } else { + LWJGLUtil.log("Using legacy mode for fullscreen window"); + return FULLSCREEN_LEGACY; + } + } else + return WINDOWED; + } + public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { lockAWT(); try { ByteBuffer handle = peer_info.lockAndGetHandle(); try { - nCreateWindow(handle, mode, fullscreen, x, y); + current_window_mode = getWindowMode(fullscreen); + nCreateWindow(handle, mode, current_window_mode, x, y); } finally { peer_info.unlock(); } @@ -142,7 +203,7 @@ unlockAWT(); } } - private static native void nCreateWindow(ByteBuffer peer_info_handle, DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException; + private static native void nCreateWindow(ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException; public void destroyWindow() { lockAWT(); @@ -154,22 +215,22 @@ public void switchDisplayMode(DisplayMode mode) throws LWJGLException { lockAWT(); try { - nSwitchDisplayMode(mode); + nSwitchDisplayMode(current_displaymode_extension, mode); } finally { unlockAWT(); } } - private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException; + private static native void nSwitchDisplayMode(int extension, DisplayMode mode) throws LWJGLException; public void resetDisplayMode() { lockAWT(); try { - nResetDisplayMode(); + nResetDisplayMode(current_displaymode_extension); } finally { unlockAWT(); } } - private static native void nResetDisplayMode(); + private static native void nResetDisplayMode(int extension); public int getGammaRampLength() { lockAWT(); @@ -200,13 +261,17 @@ public DisplayMode init() throws LWJGLException { lockAWT(); try { - DisplayMode mode = nInit(); + current_displaymode_extension = getBestDisplayModeExtension(); + if (current_displaymode_extension == NONE) + throw new LWJGLException("No display mode extension is available"); + DisplayMode mode = nInit(current_displaymode_extension); return mode; } finally { unlockAWT(); } } - private static native DisplayMode nInit() throws LWJGLException; + /** Assumes extension != NONE */ + private static native DisplayMode nInit(int extension) throws LWJGLException; public void setTitle(String title) { lockAWT(); @@ -233,11 +298,11 @@ public boolean isActive() { lockAWT(); - boolean result = nIsActive(); + boolean result = nIsActive(current_window_mode); unlockAWT(); return result; } - private static native boolean nIsActive(); + private static native boolean nIsActive(int window_mode); public boolean isDirty() { lockAWT(); @@ -254,10 +319,10 @@ public void update() { lockAWT(); - nUpdate(); + nUpdate(current_displaymode_extension, current_window_mode); unlockAWT(); } - private static native void nUpdate(); + private static native void nUpdate(int extension, int current_window_mode); public void reshape(int x, int y, int width, int height) { lockAWT(); @@ -269,13 +334,13 @@ public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { lockAWT(); try { - DisplayMode[] modes = nGetAvailableDisplayModes(); + DisplayMode[] modes = nGetAvailableDisplayModes(current_displaymode_extension); return modes; } finally { unlockAWT(); } } - private static native DisplayMode[] nGetAvailableDisplayModes() throws LWJGLException; + private static native DisplayMode[] nGetAvailableDisplayModes(int extension) throws LWJGLException; /* Mouse */ public boolean hasWheel() { @@ -288,10 +353,11 @@ public void createMouse() { lockAWT(); - nCreateMouse(); + nCreateMouse(current_window_mode); unlockAWT(); } - private static native void nCreateMouse(); + private static native void nCreateMouse(int window_mode); + public void destroyMouse() { lockAWT(); nDestroyMouse(); @@ -300,6 +366,7 @@ private static native void nDestroyMouse(); public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { + update(); lockAWT(); nPollMouse(coord_buffer, buttons); unlockAWT(); @@ -307,6 +374,7 @@ private static native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons); public int readMouse(IntBuffer buffer, int buffer_position) { + update(); lockAWT(); int count = nReadMouse(buffer, buffer_position); unlockAWT(); @@ -323,10 +391,10 @@ public void grabMouse(boolean grab) { lockAWT(); - nGrabMouse(grab); + nGrabMouse(current_window_mode, grab); unlockAWT(); } - private static native void nGrabMouse(boolean grab); + private static native void nGrabMouse(int window_mode, boolean grab); public int getNativeCursorCapabilities() { lockAWT(); @@ -386,12 +454,12 @@ public void createKeyboard() throws LWJGLException { lockAWT(); try { - nCreateKeyboard(); + nCreateKeyboard(current_window_mode); } finally { unlockAWT(); } } - private static native void nCreateKeyboard() throws LWJGLException; + private static native void nCreateKeyboard(int window_mode) throws LWJGLException; public void destroyKeyboard() { lockAWT(); @@ -401,6 +469,7 @@ private static native void nDestroyKeyboard(); public void pollKeyboard(ByteBuffer keyDownBuffer) { + update(); lockAWT(); nPollKeyboard(keyDownBuffer); unlockAWT(); @@ -408,6 +477,7 @@ private static native void nPollKeyboard(ByteBuffer keyDownBuffer); public int readKeyboard(IntBuffer buffer, int buffer_position) { + update(); lockAWT(); int count = nReadKeyboard(buffer, buffer_position); unlockAWT(); |
|
From: Elias N. <eli...@us...> - 2005-11-21 13:23:13
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/src/native/linux Modified Files: Window.h display.c display.h org_lwjgl_input_Keyboard.c org_lwjgl_input_Mouse.c org_lwjgl_opengl_Display.c Log Message: Linux: Moved display mode extension and window state handling up into java code Index: display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- display.h 11 Dec 2004 20:09:04 -0000 1.7 +++ display.h 21 Nov 2005 13:22:52 -0000 1.8 @@ -45,17 +45,14 @@ #include <jni.h> #include "common_tools.h" -typedef enum {XRANDR, XF86VIDMODE, NONE} extension; - 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(JNIEnv *env, int screen, bool temporary); -extern jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen); +extern jobject initDisplay(JNIEnv *env, int screen, jint extension); +extern void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension); +extern void resetDisplayMode(JNIEnv *env, int screen, jint extension, bool temporary); +extern jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen, jint extension); extern int getGammaRampLength(JNIEnv *env, int screen); extern void setGammaRamp(JNIEnv *env, jobject gamma_ramp_buffer, int screen); -extern extension getCurrentDisplayModeExtension(); -extern void temporaryRestoreMode(JNIEnv *env, int screen); +extern void temporaryRestoreMode(JNIEnv *env, int screen, jint extension); #endif Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- display.c 21 Nov 2005 10:55:49 -0000 1.12 +++ display.c 21 Nov 2005 13:22:52 -0000 1.13 @@ -50,6 +50,7 @@ #include "display.h" #include "common_tools.h" #include "Window.h" +#include "org_lwjgl_opengl_LinuxDisplay.h" #define NUM_XRANDR_RETRIES 5 @@ -75,7 +76,6 @@ static unsigned short *b_ramp = NULL; static unsigned short *current_ramp = NULL; static int current_gamma_ramp_length = 0; -static extension current_extension = NONE; int getScreenModeWidth(void) { return current_width; @@ -85,15 +85,6 @@ return current_height; } -extension getCurrentDisplayModeExtension(void) { - return current_extension; -} - -static bool isXrandrForceDisabled() { - char *supported_env = getenv("LWJGL_DISABLE_XRANDR"); - return supported_env != NULL; -} - static bool getXF86VidModeVersion(JNIEnv *env, Display *disp, int *major, int *minor) { int event_base, error_base; @@ -126,8 +117,6 @@ static bool isXrandrSupported(JNIEnv *env, Display *disp) { int major, minor; - if (isXrandrForceDisabled()) - return false; if (!getXrandrVersion(env, disp, &major, &minor)) return false; return major >= 1; @@ -140,17 +129,28 @@ return major_ver >= 2; } -static extension getBestDisplayModeExtension(JNIEnv *env, Display *disp) { - if (isXrandrSupported(env, disp)) { - printfDebugJava(env, "Using Xrandr for display mode switching"); - return XRANDR; - } else if (isXF86VidModeSupported(env, disp)) { - printfDebugJava(env, "Using XF86VidMode for display mode switching"); - return XF86VIDMODE; - } else { - printfDebugJava(env, "No display mode extensions available"); - return NONE; +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXrandrSupported(JNIEnv *env, jclass unused) { + Display *disp = XOpenDisplay(NULL); + if (disp == NULL) { + throwException(env, "Could not open display"); + return JNI_FALSE; } + + jboolean result = isXrandrSupported(env, disp) ? JNI_TRUE : JNI_FALSE; + XCloseDisplay(disp); + return result; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isXF86VidModeSupported(JNIEnv *env, jclass unused) { + Display *disp = XOpenDisplay(NULL); + if (disp == NULL) { + throwException(env, "Could not open display"); + return JNI_FALSE; + } + + jboolean result = isXF86VidModeSupported(env, disp) ? JNI_TRUE : JNI_FALSE; + XCloseDisplay(disp); + return result; } static mode_info *getXrandrDisplayModes(Display *disp, int screen, int *num_modes) { @@ -204,13 +204,13 @@ return avail_modes; } -static mode_info *getDisplayModes(Display *disp, int screen, int *num_modes) { - switch (current_extension) { - case XF86VIDMODE: +static mode_info *getDisplayModes(Display *disp, int screen, jint extension, int *num_modes) { + switch (extension) { + case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE: return getXF86VidModeDisplayModes(disp, screen, num_modes); - case XRANDR: + case org_lwjgl_opengl_LinuxDisplay_XRANDR: return getXrandrDisplayModes(disp, screen, num_modes); - case NONE: + case org_lwjgl_opengl_LinuxDisplay_NONE: // fall through default: return NULL; @@ -255,9 +255,9 @@ return false; } -static bool setMode(JNIEnv *env, Display *disp, int screen, 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, bool temporary) { int num_modes, i; - mode_info *avail_modes = getDisplayModes(disp, screen, &num_modes); + mode_info *avail_modes = getDisplayModes(disp, screen, extension, &num_modes); if (avail_modes == NULL) { printfDebugJava(env, "Could not get display modes"); return false; @@ -266,20 +266,20 @@ for ( i = 0; i < num_modes; ++i ) { printfDebugJava(env, "Mode %d: %dx%d @%d", i, avail_modes[i].width, avail_modes[i].height, avail_modes[i].freq); if (avail_modes[i].width == width && avail_modes[i].height == height && avail_modes[i].freq == freq) { - switch (current_extension) { - case XF86VIDMODE: + switch (extension) { + case org_lwjgl_opengl_LinuxDisplay_XF86VIDMODE: if (!setXF86VidModeMode(disp, screen, &avail_modes[i])) { printfDebugJava(env, "Could not switch mode"); continue; } break; - case XRANDR: + case org_lwjgl_opengl_LinuxDisplay_XRANDR: if (!setXrandrMode(disp, screen, &avail_modes[i])) { printfDebugJava(env, "Could not switch mode"); continue; } break; - case NONE: // Should never happen, since NONE imply no available display modes + case org_lwjgl_opengl_LinuxDisplay_NONE: // Should never happen, since NONE imply no available display modes default: // Should never happen continue; } @@ -331,7 +331,7 @@ return length; } -jobject initDisplay(JNIEnv *env, int screen) { +jobject initDisplay(JNIEnv *env, int screen, jint extension) { int num_modes; mode_info *avail_modes; Display *disp = XOpenDisplay(NULL); @@ -340,13 +340,7 @@ return NULL; } - current_extension = getBestDisplayModeExtension(env, disp); - if (current_extension == NONE) { - throwException(env, "No display mode extension is available"); - XCloseDisplay(disp); - return NULL; - } - avail_modes = getDisplayModes(disp, screen, &num_modes); + avail_modes = getDisplayModes(disp, screen, extension, &num_modes); if (avail_modes == NULL || num_modes == 0) { throwException(env, "Could not get display modes"); XCloseDisplay(disp); @@ -395,20 +389,20 @@ } } -void temporaryRestoreMode(JNIEnv *env, int screen) { +void temporaryRestoreMode(JNIEnv *env, int screen, jint extension) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { printfDebugJava(env, "Could not open display"); return; } - if (!setMode(env, disp, screen, current_width, current_height, current_freq, false)) + if (!setMode(env, disp, screen, extension, current_width, current_height, current_freq, false)) printfDebugJava(env, "Could not restore mode"); setCurrentGamma(disp, screen, NULL); XCloseDisplay(disp); // Don't propagate error to caller } -void switchDisplayMode(JNIEnv * env, jobject mode, int screen) { +void switchDisplayMode(JNIEnv * env, jobject mode, int screen, jint extension) { if (mode == NULL) { throwException(env, "mode must be non-null"); return; @@ -425,18 +419,18 @@ throwException(env, "Could not open display"); return; } - if (!setMode(env, disp, screen, width, height, freq, false)) + if (!setMode(env, disp, screen, extension, width, height, freq, false)) throwException(env, "Could not switch mode."); XCloseDisplay(disp); } -void resetDisplayMode(JNIEnv *env, int screen, bool temporary) { +void resetDisplayMode(JNIEnv *env, int screen, jint extension, bool temporary) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { printfDebugJava(env, "Failed to contact X Server"); return; } - if (!setMode(env, disp, screen, saved_width, saved_height, saved_freq, temporary)) { + if (!setMode(env, disp, screen, extension, saved_width, saved_height, saved_freq, temporary)) { printfDebugJava(env, "Failed to reset mode"); } if (saved_gamma_ramp_length > 0) { @@ -446,7 +440,7 @@ XCloseDisplay(disp); } -jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen) { +jobjectArray getAvailableDisplayModes(JNIEnv * env, int screen, jint extension) { int num_modes, i; mode_info *avail_modes; Display *disp = XOpenDisplay(NULL); @@ -456,7 +450,7 @@ } int bpp = XDefaultDepth(disp, screen); - avail_modes = getDisplayModes(disp, screen, &num_modes); + avail_modes = getDisplayModes(disp, screen, extension, &num_modes); if (avail_modes == NULL) { printfDebugJava(env, "Could not get display modes"); XCloseDisplay(disp); Index: org_lwjgl_input_Mouse.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- org_lwjgl_input_Mouse.c 10 Oct 2005 09:11:24 -0000 1.37 +++ org_lwjgl_input_Mouse.c 21 Nov 2005 13:22:52 -0000 1.38 @@ -135,7 +135,7 @@ XDefineCursor(getDisplay(), getCurrentWindow(), cursor); } -static void grabPointer(void) { +static void grabPointer(jint window_mode) { if (!pointer_grabbed) { int result; int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask; @@ -144,7 +144,7 @@ if (result == GrabSuccess) { pointer_grabbed = true; // make sure we have a centered window - if (isLegacyFullscreen()) { + if (isLegacyFullscreen(window_mode)) { XWindowAttributes win_attribs; XGetWindowAttributes(getDisplay(), getCurrentWindow(), &win_attribs); XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), win_attribs.x, win_attribs.y); @@ -162,11 +162,11 @@ } } -void updatePointerGrab(void) { +void updatePointerGrab(jint window_mode) { if (!created) return; - if (isFullscreen() || shouldGrab()) { - grabPointer(); + if (isFullscreen(window_mode) || shouldGrab()) { + grabPointer(window_mode); } else { ungrabPointer(); } @@ -205,7 +205,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateMouse - (JNIEnv * env, jclass clazz) + (JNIEnv * env, jclass clazz, jint window_mode) { int i; last_y = last_x = accum_dx = accum_dy = accum_dz = 0; @@ -218,7 +218,7 @@ current_cursor = None; created = true; pointer_grabbed = false; - updatePointerGrab(); + updatePointerGrab(window_mode); initEventQueue(&event_queue, EVENT_SIZE); } @@ -314,7 +314,6 @@ int coords_length = (*env)->GetDirectBufferCapacity(env, coord_buffer_obj); unsigned char *buttons_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, button_buffer_obj); int buttons_length = (*env)->GetDirectBufferCapacity(env, button_buffer_obj); - handleMessages(env); if (coords_length < 3) { printfDebugJava(env, "ERROR: Not enough space in coords array: %d < 3", coords_length); return; @@ -339,7 +338,6 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReadMouse(JNIEnv *env, jclass clazz, jobject buffer, jint buffer_position) { jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer); int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position; - handleMessages(env); return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size); } @@ -347,12 +345,12 @@ XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, x, transformY(y)); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabMouse(JNIEnv * env, jclass clazz, jboolean new_grab) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabMouse(JNIEnv * env, jclass clazz, jint window_mode, jboolean new_grab) { Window root_return, child_return; int root_x, root_y, win_x, win_y; unsigned int mask_return; - setGrab(new_grab == JNI_TRUE ? true : false); + setGrab(window_mode, new_grab == JNI_TRUE ? true : false); reset(); XQueryPointer(getDisplay(), getCurrentWindow(), &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return); doHandlePointerMotion(root_x, root_y, win_x, win_y); Index: org_lwjgl_input_Keyboard.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Keyboard.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_input_Keyboard.c 19 Apr 2005 07:18:17 -0000 1.21 +++ org_lwjgl_input_Keyboard.c 21 Nov 2005 13:22:52 -0000 1.22 @@ -87,10 +87,10 @@ } } -void updateKeyboardGrab(void) { +void updateKeyboardGrab(jint window_mode) { if (!created) return; - if (isLegacyFullscreen()/* || shouldGrab()*/) { + if (isLegacyFullscreen(window_mode)) { grabKeyboard(); } else { ungrabKeyboard(); @@ -123,13 +123,13 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateKeyboard - (JNIEnv * env, jclass clazz) + (JNIEnv * env, jclass clazz, jint window_mode) { memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char)); created = true; keyboard_grabbed = false; initEventQueue(&event_queue, 3); - updateKeyboardGrab(); + updateKeyboardGrab(window_mode); XModifierKeymap *modifier_map = XGetModifierMapping(getDisplay()); numlock_mask = 0; modeswitch_mask = 0; @@ -684,12 +684,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nPollKeyboard(JNIEnv * env, jclass clazz, jobject buffer) { unsigned char *new_keyboard_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer); - handleMessages(env); memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); } JNIEXPORT int JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReadKeyboard(JNIEnv * env, jclass clazz, jobject buffer, jint buffer_position) { - handleMessages(env); jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer); int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position; return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size); Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Window.h 20 Feb 2005 11:24:22 -0000 1.26 +++ Window.h 21 Nov 2005 13:22:52 -0000 1.27 @@ -49,12 +49,7 @@ #include "extgl.h" #include "extgl_glx.h" - /* - * release input (keyboard, mouse) - */ - extern void handleMessages(JNIEnv *env); - - extern bool checkXError(JNIEnv *env, Display *display); + extern bool checkXError(JNIEnv *, Display *); extern Atom getWarpAtom(void); /* * Various functions to release/acquire keyboard and mouse @@ -64,9 +59,9 @@ extern void handleButtonPress(XButtonEvent *); extern void handleButtonRelease(XButtonEvent *); extern void handleKeyEvent(XKeyEvent *); - extern void updatePointerGrab(void); - extern void updateKeyboardGrab(void); - extern void setGrab(bool); + extern void updatePointerGrab(jint); + extern void updateKeyboardGrab(jint); + extern void setGrab(jint, bool); extern bool isGrabbed(void); extern bool shouldGrab(void); @@ -98,11 +93,11 @@ /* * Return true if we are in fullscreen mode */ - extern bool isFullscreen(void); + extern bool isFullscreen(jint window_mode); /* * Return true if we are in exclusive fullscreen mode */ - extern bool isLegacyFullscreen(void); + extern bool isLegacyFullscreen(jint window_mode); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ 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.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- org_lwjgl_opengl_Display.c 20 Nov 2005 13:19:39 -0000 1.33 +++ org_lwjgl_opengl_Display.c 21 Nov 2005 13:22:52 -0000 1.34 @@ -68,14 +68,11 @@ #define MWM_HINTS_DECORATIONS (1L << 1) -typedef enum {FULLSCREEN_LEGACY, FULLSCREEN_NETWM, WINDOWED} window_mode; - static GLXWindow glx_window = None; static Atom delete_atom; static Colormap cmap; static Window current_win; -static window_mode current_window_mode; static int current_height; static int current_width; static int current_depth; @@ -156,9 +153,9 @@ } while ((event.type != MapNotify) || (event.xmap.event != win)); } -static void updateInputGrab(void) { - updatePointerGrab(); - updateKeyboardGrab(); +static void updateInputGrab(jint window_mode) { + updatePointerGrab(window_mode); + updateKeyboardGrab(window_mode); } static void setRepeatMode(JNIEnv *env, int mode) { @@ -185,36 +182,36 @@ XChangeProperty (getDisplay(), getCurrentWindow(), motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long)); } -static bool releaseInput(JNIEnv *env) { - if (isLegacyFullscreen() || input_released) +static bool releaseInput(JNIEnv *env, jint extension, jint window_mode) { + if (isLegacyFullscreen(window_mode) || input_released) return false; input_released = true; setRepeatMode(env, AutoRepeatModeDefault); - updateInputGrab(); - if (current_window_mode == FULLSCREEN_NETWM) { + updateInputGrab(window_mode); + if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen()); - resetDisplayMode(env, getCurrentScreen(), true); + resetDisplayMode(env, getCurrentScreen(), extension, true); } return true; } -static void acquireInput(JNIEnv *env) { - if (isLegacyFullscreen() || !input_released) +static void acquireInput(JNIEnv *env, jint extension, jint window_mode) { + if (isLegacyFullscreen(window_mode) || !input_released) return; input_released = false; setRepeatMode(env, AutoRepeatModeOff); - updateInputGrab(); - if (current_window_mode == FULLSCREEN_NETWM) { - temporaryRestoreMode(env, getCurrentScreen()); + updateInputGrab(window_mode); + if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { + temporaryRestoreMode(env, getCurrentScreen(), extension); } } -bool isFullscreen(void) { - return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM; +bool isFullscreen(jint window_mode) { + return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY || window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM; } -bool isLegacyFullscreen(void) { - return current_window_mode == FULLSCREEN_LEGACY; +bool isLegacyFullscreen(jint window_mode) { + return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY; } bool shouldGrab(void) { @@ -225,27 +222,27 @@ return grab; } -void setGrab(bool new_grab) { +void setGrab(jint window_mode, bool new_grab) { if (new_grab != grab) { grab = new_grab; - updateInputGrab(); + updateInputGrab(window_mode); } } -static void checkInput(JNIEnv *env) { +static void checkInput(JNIEnv *env, jint extension, jint window_mode) { Window win; int revert_mode; XGetInputFocus(getDisplay(), &win, &revert_mode); if (win == current_win) { - acquireInput(env); + acquireInput(env, extension, window_mode); focused = true; } else { - releaseInput(env); + releaseInput(env, extension, window_mode); focused = false; } } -void handleMessages(JNIEnv *env) { +void handleMessages(JNIEnv *env, jint extension, jint window_mode) { XEvent event; /* Window win; int revert_mode;*/ @@ -296,7 +293,7 @@ break; } } - checkInput(env); + checkInput(env, extension, window_mode); } static void setWindowTitle(const char *title) { @@ -339,19 +336,12 @@ setRepeatMode(env, AutoRepeatModeDefault); } -static bool isNetWMForceDisabled() { - char *supported_env = getenv("LWJGL_DISABLE_NETWM"); - return supported_env != NULL; -} - static bool isNetWMFullscreenSupported(JNIEnv *env) { unsigned long nitems; Atom actual_type; int actual_format; unsigned long bytes_after; Atom *supported_list; - if (isNetWMForceDisabled()) - return false; 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) { @@ -371,11 +361,15 @@ return supported; } +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused) { + return isNetWMFullscreenSupported(env) ? JNI_TRUE : JNI_FALSE; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) { XMoveWindow(getDisplay(), getCurrentWindow(), x, y); } -static bool createWindow(JNIEnv* env, X11PeerInfo *peer_info, int x, int y, int width, int height) { +static bool createWindow(JNIEnv* env, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) { bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"); dirty = true; focused = true; @@ -401,7 +395,7 @@ attribs.background_pixel = 0xFF000000; attribs.win_gravity = NorthWestGravity; attribmask = CWColormap | CWBackPixel | CWEventMask | CWWinGravity; - if (isLegacyFullscreen()) { + if (isLegacyFullscreen(window_mode)) { attribmask |= CWOverrideRedirect; attribs.override_redirect = True; } @@ -417,7 +411,7 @@ } printfDebugJava(env, "Created window"); current_win = win; - if (current_window_mode != WINDOWED || undecorated) { + if (window_mode != org_lwjgl_opengl_LinuxDisplay_WINDOWED || undecorated) { // Use Motif decoration hint property and hope the window manager respects them setDecorations(0); } @@ -431,7 +425,7 @@ XFree(size_hints); delete_atom = XInternAtom(getDisplay(), "WM_DELETE_WINDOW", False); XSetWMProtocols(getDisplay(), win, &delete_atom, 1); - if (current_window_mode == FULLSCREEN_NETWM) { + if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) { Atom fullscreen_atom = XInternAtom(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False); XChangeProperty(getDisplay(), getCurrentWindow(), XInternAtom(getDisplay(), "_NET_WM_STATE", False), XInternAtom(getDisplay(), "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); @@ -460,21 +454,21 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass clazz, jint extension, jint window_mode) { - handleMessages(env); + handleMessages(env, extension, window_mode); } -JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz) { - return getAvailableDisplayModes(env, getCurrentScreen()); +JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) { + return getAvailableDisplayModes(env, getCurrentScreen(), extension); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jobject mode) { - switchDisplayMode(env, mode, getCurrentScreen()); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint extension, jobject mode) { + switchDisplayMode(env, mode, getCurrentScreen(), extension); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz) { - resetDisplayMode(env, getCurrentScreen(), false); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jclass clazz, jint extension) { + resetDisplayMode(env, getCurrentScreen(), extension, false); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz) { @@ -485,22 +479,11 @@ setGammaRamp(env, gamma_buffer, getCurrentScreen()); } -JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jclass clazz) { - return initDisplay(env, getCurrentScreen()); +JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jclass clazz, jint extension) { + return initDisplay(env, getCurrentScreen(), extension); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject mode, jboolean fullscreen, jint x, jint y) { - bool current_fullscreen = fullscreen == JNI_TRUE; - if (current_fullscreen) { - if (getCurrentDisplayModeExtension() == XRANDR && isNetWMFullscreenSupported(env)) { - printfDebugJava(env, "Using NetWM for fullscreen window"); - current_window_mode = FULLSCREEN_NETWM; - } else { - printfDebugJava(env, "Using legacy mode for fullscreen window"); - current_window_mode = FULLSCREEN_LEGACY; - } - } else - current_window_mode = WINDOWED; +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) { X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle); GLXFBConfig *fb_config = NULL; if (peer_info->glx13) { @@ -513,7 +496,7 @@ jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); - bool window_created = createWindow(env, peer_info, x, y, width, height); + bool window_created = createWindow(env, window_mode, peer_info, x, y, width, height); if (!window_created) { return; } @@ -551,8 +534,8 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsActive - (JNIEnv *env, jclass clazz) { - return focused || isLegacyFullscreen() ? JNI_TRUE : JNI_FALSE; + (JNIEnv *env, jclass clazz, jint window_mode) { + return focused || isLegacyFullscreen(window_mode) ? JNI_TRUE : JNI_FALSE; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) { |
|
From: Elias N. <eli...@us...> - 2005-11-21 11:08:23
|
Update of /cvsroot/java-game-lib/LWJGL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18137 Modified Files: build.xml Log Message: build.xml: target 'jars' shouldn't depend on target 'clean' Index: build.xml =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/build.xml,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- build.xml 4 Nov 2005 19:22:52 -0000 1.94 +++ build.xml 21 Nov 2005 11:08:04 -0000 1.95 @@ -231,7 +231,7 @@ </target> <!-- Create ONLY the jar archives --> - <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="clean, -initialize, compile, -createjars"> + <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, compile, -createjars"> <move todir="libs/"> <fileset dir="${lwjgl.temp}/jar"> <include name="*.jar"/> |
|
From: Elias N. <eli...@us...> - 2005-11-21 10:55:59
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15509 Modified Files: display.c Log Message: Linux: Removed superfluous check from display.c Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- display.c 21 Nov 2005 10:45:59 -0000 1.11 +++ display.c 21 Nov 2005 10:55:49 -0000 1.12 @@ -213,7 +213,6 @@ case NONE: // fall through default: - // Should never happen return NULL; } } @@ -257,8 +256,6 @@ } static bool setMode(JNIEnv *env, Display *disp, int screen, int width, int height, int freq, bool temporary) { - if (current_extension == NONE) - return false; int num_modes, i; mode_info *avail_modes = getDisplayModes(disp, screen, &num_modes); if (avail_modes == NULL) { @@ -282,7 +279,7 @@ continue; } break; - case NONE: // Should never happen + case NONE: // Should never happen, since NONE imply no available display modes default: // Should never happen continue; } |
|
From: Elias N. <eli...@us...> - 2005-11-21 10:46:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13690 Modified Files: display.c Log Message: Linux: Added zero size check to display.c Index: display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/display.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- display.c 13 Sep 2005 06:56:14 -0000 1.10 +++ display.c 21 Nov 2005 10:45:59 -0000 1.11 @@ -261,7 +261,7 @@ return false; int num_modes, i; mode_info *avail_modes = getDisplayModes(disp, screen, &num_modes); - if (avail_modes == NULL || num_modes == 0) { + if (avail_modes == NULL) { printfDebugJava(env, "Could not get display modes"); return false; } @@ -350,7 +350,7 @@ return NULL; } avail_modes = getDisplayModes(disp, screen, &num_modes); - if (avail_modes == NULL) { + if (avail_modes == NULL || num_modes == 0) { throwException(env, "Could not get display modes"); XCloseDisplay(disp); return NULL; |