From: <eli...@us...> - 2006-10-23 14:23:22
|
Revision: 2594 http://svn.sourceforge.net/java-game-lib/?rev=2594&view=rev Author: elias_naur Date: 2006-10-23 07:22:27 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Linux: Moved another Display instance to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/display.c trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Removed Paths: ------------- trunk/LWJGL/src/native/linux/display.h Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:16:40 UTC (rev 2593) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:22:27 UTC (rev 2594) @@ -430,14 +430,23 @@ public void switchDisplayMode(DisplayMode mode) throws LWJGLException { lockAWT(); try { - nSwitchDisplayMode(getScreen(), current_displaymode_extension, mode); + switchDisplayModeOnTmpDisplay(mode); current_mode = mode; } finally { unlockAWT(); } } - private static native void nSwitchDisplayMode(int screen, int extension, DisplayMode mode) throws LWJGLException; + private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException { + long tmp_display = openDisplay(); + try { + nSwitchDisplayMode(tmp_display, getScreen(), current_displaymode_extension, mode); + } finally { + closeDisplay(tmp_display); + } + } + private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException; + public void resetDisplayMode() { lockAWT(); try { @@ -704,7 +713,7 @@ if (current_window_mode == FULLSCREEN_NETWM) { nIconifyWindow(getDisplay(), getWindow(), getScreen()); try { - nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode); + switchDisplayModeOnTmpDisplay(saved_mode); setGammaRampOnTmpDisplay(saved_gamma); } catch (LWJGLException e) { LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage()); @@ -721,7 +730,7 @@ updateInputGrab(); if (current_window_mode == FULLSCREEN_NETWM) { try { - nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode); + switchDisplayModeOnTmpDisplay(current_mode); setGammaRampOnTmpDisplay(current_gamma); } catch (LWJGLException e) { LWJGLUtil.log("Failed to restore mode: " + e.getMessage()); Modified: trunk/LWJGL/src/native/linux/display.c =================================================================== --- trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:16:40 UTC (rev 2593) +++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:22:27 UTC (rev 2594) @@ -47,7 +47,6 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#include "display.h" #include "common_tools.h" #include "Window.h" #include "org_lwjgl_opengl_LinuxDisplay.h" @@ -319,7 +318,7 @@ } } -bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) { +static bool switchDisplayMode(JNIEnv * env, Display *disp, int screen, jint extension, jobject mode) { if (mode == NULL) { throwException(env, "mode must be non-null"); return false; @@ -331,17 +330,11 @@ int width = (*env)->GetIntField(env, mode, fid_width); int height = (*env)->GetIntField(env, mode, fid_height); int freq = (*env)->GetIntField(env, mode, fid_freq); - Display *disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return false; - } if (!setMode(env, disp, screen, extension, width, height, freq)) { XCloseDisplay(disp); throwException(env, "Could not switch mode."); return false; } - XCloseDisplay(disp); return true; } @@ -403,8 +396,9 @@ return getAvailableDisplayModes(env, disp, getCurrentScreen(), extension); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint screen, jint extension, jobject mode) { - switchDisplayMode(env, screen, extension, mode); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) { + Display *disp = (Display *)(intptr_t)display; + switchDisplayMode(env, disp, screen, extension, mode); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz, jlong display_ptr, jint screen) { Deleted: trunk/LWJGL/src/native/linux/display.h =================================================================== --- trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:16:40 UTC (rev 2593) +++ trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:22:27 UTC (rev 2594) @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * $Id$ - * - * Linux specific library for display handling. - * - * @author elias_naur <eli...@us...> - * @version $Revision$ - */ - -#ifndef _DISPLAY_H -#define _DISPLAY_H - -#include <jni.h> -#include "common_tools.h" - -extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode); - -#endif Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 14:16:40 UTC (rev 2593) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 14:22:27 UTC (rev 2594) @@ -53,7 +53,6 @@ #include "extgl_glx.h" #include "Window.h" #include "context.h" -#include "display.h" #include "org_lwjgl_opengl_LinuxDisplay.h" #include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |