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