From: <eli...@us...> - 2008-04-07 19:21:47
|
Revision: 2987 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2987&view=rev Author: elias_naur Date: 2008-04-07 12:21:40 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Let the Display resize itself to match its parent, if non null Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-07 18:44:46 UTC (rev 2986) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-04-07 19:21:40 UTC (rev 2987) @@ -50,6 +50,9 @@ import java.util.Arrays; import java.util.HashSet; import java.awt.Canvas; +import java.awt.event.ComponentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; @@ -111,6 +114,16 @@ private static boolean window_created = false; + private static boolean parent_resized; + + private static ComponentListener component_listener = new ComponentAdapter() { + public final void componentResized(ComponentEvent e) { + synchronized (GlobalLock.lock) { + parent_resized = true; + } + } + }; + static { Sys.initialize(); display_impl = createDisplayImplementation(); @@ -238,6 +251,36 @@ } } + private static DisplayMode getEffectiveMode() { + return !fullscreen && parent != null ? new DisplayMode(parent.getWidth(), parent.getHeight()) : current_mode; + } + + private static int getWindowX() { + if (!fullscreen && parent == null) { + // if no display location set, center window + if (x == -1) { + return Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); + } else { + return x; + } + } else { + return 0; + } + } + + private static int getWindowY() { + if (!fullscreen && parent == null) { + // if no display location set, center window + if (y == -1) { + return Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2); + } else { + return y; + } + } else { + return 0; + } + } + /** * Create the native window peer from the given mode and fullscreen flag. * A native context must exist, and it will be attached to the window. @@ -246,25 +289,14 @@ if (window_created) { return; } - int window_x; - int window_y; - if (!fullscreen && parent == null) { - // if no display location set, center window - if (x == -1 && y == -1) { - window_x = Math.max(0, (initial_mode.getWidth() - current_mode.getWidth()) / 2); - window_y = Math.max(0, (initial_mode.getHeight() - current_mode.getHeight()) / 2); - } else { - window_x = x; - window_y = y; - } - } else { - window_x = 0; - window_y = 0; - } Canvas tmp_parent = fullscreen ? null : parent; if (tmp_parent != null && !tmp_parent.isDisplayable()) // Only a best effort check, since the parent can turn undisplayable hereafter throw new LWJGLException("Parent.isDisplayable() must be true"); - display_impl.createWindow(current_mode, fullscreen, tmp_parent, window_x, window_y); + if (tmp_parent != null) { + tmp_parent.addComponentListener(component_listener); + } + DisplayMode mode = getEffectiveMode(); + display_impl.createWindow(mode, fullscreen, tmp_parent, getWindowX(), getWindowY()); window_created = true; setTitle(title); @@ -282,6 +314,9 @@ if (!window_created) { return; } + if (parent != null) { + parent.removeComponentListener(component_listener); + } try { if (context != null && context.isCurrent()) { Context.releaseCurrentContext(); @@ -676,6 +711,10 @@ } pollDevices(); + if (parent_resized) { + reshape(); + parent_resized = false; + } } } @@ -985,11 +1024,16 @@ // offset if already created if(isCreated()) { - display_impl.reshape(x, y, current_mode.getWidth(), current_mode.getHeight()); + reshape(); } } } + private static void reshape() { + DisplayMode mode = getEffectiveMode(); + display_impl.reshape(getWindowX(), getWindowY(), mode.getWidth(), mode.getHeight()); + } + /** * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2", * "Radeon9700". If the adapter cannot be determined, this function returns null. Modified: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 18:44:46 UTC (rev 2986) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java 2008-04-07 19:21:40 UTC (rev 2987) @@ -83,13 +83,7 @@ int current_width = 0; while (isVisible()) { angle += 1.0f; - if (getWidth() != current_width || getHeight() != current_height) { - current_width = getWidth(); - current_height = getHeight(); - Display.setDisplayMode(new DisplayMode(getWidth(), getHeight())); - GL11.glViewport(0, 0, current_width, current_height); - } - GL11.glViewport(0, 0, getWidth(), getHeight()); + GL11.glViewport(0, 0, display_parent.getWidth(), display_parent.getHeight()); GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-07 18:44:46 UTC (rev 2986) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-07 19:21:40 UTC (rev 2987) @@ -240,6 +240,7 @@ Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; XMoveWindow(disp, window, x, y); + XResizeWindow(disp, window, width, height); } JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-09 18:09:34
|
Revision: 2997 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2997&view=rev Author: elias_naur Date: 2008-04-09 11:09:15 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Linux: When parented, take focus on click Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-08 18:03:20 UTC (rev 2996) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-09 18:09:15 UTC (rev 2997) @@ -50,6 +50,7 @@ final class LinuxDisplay implements DisplayImplementation { /* X11 constants */ + public final static int CurrentTime = 0; public final static int GrabSuccess = 0; public final static int AutoRepeatModeOff = 0; public final static int AutoRepeatModeOn = 1; @@ -620,7 +621,7 @@ return peer_info; } - private native static void setInputFocus(long display, long window); + static native void setInputFocus(long display, long window, long time); private void processEvents() { while (LinuxEvent.getPending(getDisplay()) > 0) { @@ -754,7 +755,7 @@ grabServer(getDisplay()); try { if (nGetInputFocus(getDisplay()) == current_focus) - setInputFocus(getDisplay(), getWindow()); + setInputFocus(getDisplay(), getWindow(), CurrentTime); } finally { ungrabServer(getDisplay()); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2008-04-08 18:03:20 UTC (rev 2996) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2008-04-09 18:09:15 UTC (rev 2997) @@ -280,6 +280,8 @@ case LinuxEvent.ButtonPress: /* Fall through */ case LinuxEvent.ButtonRelease: handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton()); + if (Display.getParent() != null) + LinuxDisplay.setInputFocus(display, window, event.getButtonTime()); return true; case LinuxEvent.MotionNotify: handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY()); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-08 18:03:20 UTC (rev 2996) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-09 18:09:15 UTC (rev 2997) @@ -338,10 +338,10 @@ XUngrabServer(disp); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; - XSetInputFocus(disp, window, RevertToParent, CurrentTime); + XSetInputFocus(disp, window, RevertToParent, time); } JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-09 23:40:20
|
Revision: 3000 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3000&view=rev Author: elias_naur Date: 2008-04-09 16:40:18 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Linux: Removed grab/ungrabServer logic and replace it with catching of any X errors occruing because of a XSetInputFocus race Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-09 18:44:25 UTC (rev 2999) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-09 23:40:18 UTC (rev 3000) @@ -752,15 +752,7 @@ if (focused_at_least_once) releaseInput(); if (parent != null && parent.isFocusOwner()) { - // Normally, a real time stamp from an event should be passed to XSetInputFocus instead of CurrentTime, but we don't get timestamps - // from awt. Instead we grab the server and check if the focus changed to avoid a race where our window is made unviewable while focusing it. - grabServer(getDisplay()); - try { - if (nGetInputFocus(getDisplay()) == current_focus) - setInputFocus(getDisplay(), getWindow(), CurrentTime); - } finally { - ungrabServer(getDisplay()); - } + setInputFocusUnsafe(); } } } @@ -768,6 +760,17 @@ private static native void grabServer(long display); private static native void ungrabServer(long display); + private static void setInputFocusUnsafe() { + setInputFocus(getDisplay(), getWindow(), CurrentTime); + try { + checkXError(getDisplay()); + } catch (LWJGLException e) { + // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch ang ignore + LWJGLUtil.log("Got exception while trying to focus: " + e); + } + } + private static native void checkXError(long display) throws LWJGLException; + private void releaseInput() { if (isLegacyFullscreen() || input_released) return; Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-09 18:44:25 UTC (rev 2999) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-09 23:40:18 UTC (rev 3000) @@ -79,7 +79,7 @@ static bool async_x_error; static char error_message[ERR_MSG_SIZE]; -bool checkXError(JNIEnv *env, Display *disp) { +static bool checkXError(JNIEnv *env, Display *disp) { XSync(disp, False); if (async_x_error) { async_x_error = false; @@ -113,6 +113,12 @@ return (intptr_t)display_connection; } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_checkXError(JNIEnv *env, jclass unused, jlong display_ptr) { + Display *disp = (Display *)(intptr_t)display_ptr; + XSync(disp, False); + checkXError(env, disp); +} + JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) { Display *disp = (Display *)(intptr_t)display_ptr; return XDefaultScreen(disp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-10 20:26:02
|
Revision: 3002 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3002&view=rev Author: elias_naur Date: 2008-04-10 13:25:54 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Removed AWTInputAdapter, since Display.setParent() works much betterdiff Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -56,12 +56,4 @@ * @throws LWJGLException if no suitable configuration could be found. */ GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException; - - /** - * Create an AWTCanvasInputImplementation for a specified AWTGLCanvas. - * - * @return A platform specific AWTCanvasInputImplementation. - * @param canvas An AWTGLCanvas - */ - AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException; } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2286 $ - * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ - */ -interface AWTCanvasInputImplementation extends InputImplementation { - void processInput(PeerInfo peer_info); - void init(); - void destroy(); -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -81,9 +81,6 @@ /** Tracks whether initGL() needs to be called */ private boolean first_run; - /** Track the input adapter, if any */ - private volatile AWTCanvasInputImplementation awt_input; - static { Sys.initialize(); implementation = createImplementation(); @@ -102,17 +99,6 @@ } } - /** - * Used from AWTInputAdapter - */ - static AWTCanvasImplementation getImplementation() { - return implementation; - } - - void setInput(AWTCanvasInputImplementation awt_input) { - this.awt_input = awt_input; - } - private void setUpdate() { synchronized(SYNC_LOCK) { update_context = true; @@ -297,9 +283,6 @@ context.update(); update_context = false; } - AWTCanvasInputImplementation current_input = awt_input; - if (current_input != null) - current_input.processInput(peer_info); if (first_run) { first_run = false; initGL(); Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -/** - * This is the static class for using LWJGL input (Mouse and Keyboard) - * with an AWTGLCanvas. - * - * @author Elias Naur - * @version $Revision: 2286 $ - * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $ - */ -public final class AWTInputAdapter { - private static AWTCanvasInputImplementation awt_input; - - /** - * Create AWTInputAdapter with the specified AWTGLCanvas. Use - * update() to receive input. - * - * @param canvas The canvas to receive input from. - */ - public static synchronized void create(AWTGLCanvas canvas) throws LWJGLException { - if (isCreated()) - throw new IllegalStateException("You need to destroy() the adapter."); - awt_input = AWTGLCanvas.getImplementation().createInput(canvas); - // Invoke Mouse.create(awt_input) and Keyboard.create(awt_input) - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - private void invokeCreate(Class input_class) throws Exception { - Method create_method = input_class.getDeclaredMethod("create", new Class[]{InputImplementation.class}); - create_method.setAccessible(true); - create_method.invoke(null, new Object[]{awt_input}); - } - - public Object run() throws Exception { - invokeCreate(Mouse.class); - invokeCreate(Keyboard.class); - return null; - } - }); - } catch (PrivilegedActionException e) { - Throwable cause = e.getCause(); - if (cause instanceof LWJGLException) - throw (LWJGLException)cause; - else - throw new Error(cause); - } - awt_input.init(); - } - - public static synchronized boolean isCreated() { - return awt_input != null; - } - - public static synchronized void destroy() { - if (isCreated()) { - Mouse.destroy(); - Keyboard.destroy(); - awt_input.destroy(); - awt_input = null; - } - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - -import java.awt.Cursor; -import java.awt.Robot; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.LWJGLException; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -abstract class AbstractAWTInput implements AWTCanvasInputImplementation { - private AWTGLCanvas canvas; - private Robot robot; - - private KeyboardEventQueue keyboard_queue; - private MouseEventQueue mouse_queue; - private volatile boolean grab; - - protected AbstractAWTInput(AWTGLCanvas canvas) { - this.canvas = canvas; - } - - protected MouseEventQueue getMouseEventQueue() { - return mouse_queue; - } - - protected KeyboardEventQueue getKeyboardEventQueue() { - return keyboard_queue; - } - - public synchronized void grabMouse(boolean grab) { - this.grab = grab; - if (mouse_queue != null) - mouse_queue.setGrabbed(grab); - } - - protected boolean isGrabbed() { - return grab; - } - - protected final AWTGLCanvas getCanvas() { - return canvas; - } - - public final void init() { - canvas.setInput(this); - } - - public synchronized void destroy() { - canvas.setInput(null); - canvas = null; - } - - public final int getWidth() { - return canvas.getWidth(); - } - - public final int getHeight() { - return canvas.getHeight(); - } - - public boolean hasWheel() { - return AWTUtil.hasWheel(); - } - - public int getButtonCount() { - return AWTUtil.getButtonCount(); - } - - public void createMouse() throws LWJGLException { - mouse_queue = createMouseQueue(); - mouse_queue.register(); - } - - protected MouseEventQueue createMouseQueue() { - return new MouseEventQueue(getCanvas()); - } - - public synchronized void destroyMouse() { - if (mouse_queue != null) { - mouse_queue.unregister(); - mouse_queue = null; - } - } - - public int getNativeCursorCapabilities() { - return AWTUtil.getNativeCursorCapabilities(); - } - - public void setCursorPosition(int x, int y) { - if (robot == null) - robot = AWTUtil.createRobot(canvas); - AWTUtil.setCursorPosition(canvas, robot, x, y); - } - - public void setNativeCursor(Object handle) throws LWJGLException { - canvas.setCursor((Cursor)handle); - } - - public int getMinCursorSize() { - return AWTUtil.getMinCursorSize(); - } - - public int getMaxCursorSize() { - return AWTUtil.getMaxCursorSize(); - } - - public synchronized void createKeyboard() throws LWJGLException { - keyboard_queue = new KeyboardEventQueue(canvas); - keyboard_queue.register(); - } - - public synchronized void destroyKeyboard() { - if (keyboard_queue != null) { - keyboard_queue.unregister(); - keyboard_queue = null; - } - } - - public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { - return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays); - } - - public void destroyCursor(Object cursor_handle) { - } - - public synchronized void readMouse(ByteBuffer buffer) { - mouse_queue.copyEvents(buffer); - } - - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - mouse_queue.poll(coord_buffer, buttons); - } - - public synchronized void readKeyboard(ByteBuffer buffer) { - keyboard_queue.copyEvents(buffer); - } - - public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - keyboard_queue.poll(keyDownBuffer); - } -} Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - -import java.nio.IntBuffer; -import java.nio.ByteBuffer; - -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class LinuxAWTInput extends AbstractAWTInput { - private final long display; - private final long input_window; - private final LinuxEvent event = new LinuxEvent(); - - private long cached_window; - private LinuxMouse cached_mouse; -// private LinuxKeyboard cached_keyboard; - private long blank_cursor = LinuxDisplay.None; - private boolean input_grabbed; - private boolean input_released; - - public LinuxAWTInput(AWTGLCanvas canvas) throws LWJGLException { - super(canvas); - LinuxDisplay.lockAWT(); - try { - this.display = LinuxDisplay.openDisplay(); - this.input_window = createInputOnlyWindow(display, LinuxDisplay.nGetDefaultScreen(display)); - } finally { - LinuxDisplay.unlockAWT(); - } - } - private static native long createInputOnlyWindow(long display, int screen); - - public synchronized void destroy() { - super.destroy(); - LinuxDisplay.lockAWT(); - try { - destroyCursor(); - LinuxDisplay.nDestroyWindow(display, input_window); - LinuxDisplay.closeDisplay(display); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - private void ungrabInputLocked() { - LinuxDisplay.lockAWT(); - try { - ungrabInput(); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - private void ungrabInput() { - if (input_grabbed) { -// LinuxDisplay.nUngrabKeyboard(display); - LinuxDisplay.nUngrabPointer(display); - input_grabbed = false; - } - } - - private void grabInput(long window) { - if (!input_grabbed) { -// int res1 = LinuxDisplay.nGrabKeyboard(display, window); - int res2 = LinuxDisplay.nGrabPointer(display, window, blank_cursor); - if (/*res1 == LinuxDisplay.GrabSuccess && */res2 == LinuxDisplay.GrabSuccess) - input_grabbed = true; - } - } - - private final void destroyCursor() { - if (blank_cursor != LinuxDisplay.None) - LinuxDisplay.nDestroyCursor(display, blank_cursor); - } - - public synchronized void processInput(PeerInfo peer_info) { - LinuxDisplay.lockAWT(); - try { - LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info; - long new_window = linux_peer_info.getDrawable(); - if (cached_mouse == null || new_window != cached_window) { - ungrabInput(); - cached_window = new_window; - try { - cached_mouse = new LinuxMouse(display, new_window, input_window); -// cached_keyboard = new LinuxKeyboard(display, new_window); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create input devices: " + e); - } - destroyCursor(); - this.blank_cursor = LinuxDisplay.nCreateBlankCursor(display, new_window); - } - checkFocus(); - if (!input_grabbed && shouldGrab()) - grabInput(new_window); - update(); - } finally { - LinuxDisplay.unlockAWT(); - } - } - - public void destroyMouse() { - ungrabInputLocked(); - super.destroyMouse(); - } - - private void checkFocus() { - if (getCanvas().isFocusOwner()) { - input_released = false; - } else { - input_released = true; - ungrabInput(); - } - } - - private boolean shouldGrab() { - return !input_released && isGrabbed() && getMouseEventQueue() != null; - } - - private void update() { - while (LinuxEvent.getPending(display) > 0) { - event.nextEvent(display); - if (shouldGrab()) { - long event_window = event.getWindow(); - boolean processed = event.filterEvent(event_window) || - cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event);/* || - cached_keyboard.filterEvent(event) */ - } - } - } - - public synchronized void grabMouse(boolean grab) { - if (grab != isGrabbed()) { - if (cached_mouse != null) - cached_mouse.changeGrabbed(grab, shouldGrab()); - ungrabInputLocked(); - super.grabMouse(grab); - } - } - -/* public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_keyboard != null) - cached_keyboard.poll(keyDownBuffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.pollKeyboard(keyDownBuffer); - } - - public synchronized void readKeyboard(ByteBuffer buffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_keyboard != null) - cached_keyboard.read(buffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.readKeyboard(buffer); - } -*/ - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_mouse != null) - cached_mouse.poll(isGrabbed(), coord_buffer, buttons); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.pollMouse(coord_buffer, buttons); - } - - public synchronized void readMouse(ByteBuffer buffer) { - if (isGrabbed()) { - LinuxDisplay.lockAWT(); - try { - if (cached_mouse != null) - cached_mouse.read(buffer); - } finally { - LinuxDisplay.unlockAWT(); - } - } else - super.readMouse(buffer); - } -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -120,8 +120,4 @@ } } private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException; - - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new LinuxAWTInput(canvas); - } } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class MacOSXAWTInput extends AbstractAWTInput { - private boolean had_focus; - - MacOSXAWTInput(AWTGLCanvas canvas) { - super(canvas); - } - - protected MouseEventQueue createMouseQueue() { - return new MacOSXMouseEventQueue(getCanvas()); - } - - public synchronized void processInput(PeerInfo peer_info) { - boolean has_focus = getCanvas().isFocusOwner(); - if (!had_focus && has_focus) - ((MacOSXMouseEventQueue)getMouseEventQueue()).warpCursor(); - had_focus = has_focus; - } - - public synchronized void destroyMouse() { - if (getMouseEventQueue() != null) - getMouseEventQueue().setGrabbed(false); - super.destroyMouse(); - } -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -63,8 +63,4 @@ */ return null; } - - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new MacOSXAWTInput(canvas); - } } Deleted: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.opengl; - -import java.awt.Cursor; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.LWJGLException; -import org.lwjgl.LWJGLUtil; - -/** - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2586 $ - * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $ - */ -final class WindowsAWTInput extends AbstractAWTInput { - private final static int WS_CHILD = 0x40000000; - private final Cursor blank_cursor; - private Cursor cached_cursor; - - private long cached_hwnd; - private WindowsDirectInputMouse cached_mouse; -// private WindowsKeyboard cached_keyboard; - private boolean has_grabbed; - - public WindowsAWTInput(AWTGLCanvas canvas) throws LWJGLException { - super(canvas); - int w = AWTUtil.getMinCursorSize(); - int h = AWTUtil.getMinCursorSize(); - blank_cursor = AWTUtil.createCursor(w, h, 0, 0, 1, BufferUtils.createIntBuffer(w*h), null); - } - - public synchronized void destroyMouse() { - if (cached_mouse != null) { - grab(false); - cached_mouse.destroy(); - cached_mouse = null; - } - super.destroyMouse(); - } - -/* public synchronized void destroyKeyboard() { - if (cached_keyboard != null) { - cached_keyboard.destroy(); - cached_keyboard = null; - } - super.destroyKeyboard(); - } -*/ - public synchronized void processInput(PeerInfo peer_info) { - WindowsPeerInfo windows_peerinfo = (WindowsPeerInfo)peer_info; - long hwnd = windows_peerinfo.getHwnd(); - try { - hwnd = findTopLevelWindow(hwnd); - if (cached_mouse == null || hwnd != cached_hwnd) { - has_grabbed = false; - cached_hwnd = hwnd; - if (cached_mouse != null) { - cached_mouse.destroy(); - } -/* if (cached_keyboard != null) { - cached_keyboard.destroy(); - }*/ - WindowsDirectInput dinput = WindowsDisplay.createDirectInput(); - cached_mouse = new WindowsDirectInputMouse(dinput, hwnd); -// cached_keyboard = new WindowsKeyboard(dinput, hwnd); - } - if (isGrabbed()) { - /** - * DirectInput won't always stop the cursor from moving on top of the - * task bar and clicking on it. So we'll use ClipCursor to - * contain it while the cursor is grabbed. - */ - WindowsDisplay.setupCursorClipping(hwnd); // Just clip it to a fullscreen window - if (getCanvas().getCursor() != blank_cursor) { - cached_cursor = getCanvas().getCursor(); - /** - * For some reason, DirectInput won't let us blank the cursor - * with the EXCLUSIVE access mode, so we'll work around it with a - * custom blank cursor - */ - getCanvas().setCursor(blank_cursor); - } - } else - WindowsDisplay.resetCursorClipping(); - grab(isGrabbed()); - } catch (LWJGLException e) { - LWJGLUtil.log("Failed to create windows mouse: " + e); - } - } - private static native int getWindowStyles(long hwnd) throws LWJGLException; - private static native long getParentWindow(long hwnd); - - private static long findTopLevelWindow(long hwnd) throws LWJGLException { - int window_styles = getWindowStyles(hwnd); - while ((window_styles & WS_CHILD) != 0) { - hwnd = getParentWindow(hwnd); - window_styles = getWindowStyles(hwnd); - } - return hwnd; - } - - private void grab(boolean grab) { - if (has_grabbed != grab) { - cached_mouse.grab(grab); -// cached_keyboard.grab(grab); - has_grabbed = grab; - cached_mouse.flush(); -// cached_keyboard.flush(); - getMouseEventQueue().clearEvents(); -// getKeyboardEventQueue().clearEvents(); - if (!grab) { - getCanvas().setCursor(cached_cursor); - } - } - } - - public synchronized void grabMouse(boolean grab) { - if (grab != isGrabbed()) { - /* Only ungrab since grabbing can only occur in processInput - * when the hwnd is guaranteed valid - */ - if (cached_mouse != null && !grab) - grab(grab); - super.grabMouse(grab); - } - } - - public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { - if (isGrabbed()) { - if (cached_mouse != null) - cached_mouse.poll(coord_buffer, buttons); - } else - super.pollMouse(coord_buffer, buttons); - } - - public synchronized void readMouse(ByteBuffer buffer) { - if (isGrabbed()) { - if (cached_mouse != null) - cached_mouse.read(buffer); - } else - super.readMouse(buffer); - } - -/* public synchronized void readKeyboard(ByteBuffer buffer) { - if (isGrabbed()) { - if (cached_keyboard != null) - cached_keyboard.read(buffer); - } else - super.readKeyboard(buffer); - } - - public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) { - if (isGrabbed()) { - if (cached_keyboard != null) - cached_keyboard.poll(keyDownBuffer); - } else - super.pollKeyboard(keyDownBuffer); - }*/ -} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -66,10 +66,6 @@ }); } - public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - return new WindowsAWTInput(canvas); - } - public PeerInfo createPeerInfo(Canvas component, PixelFormat pixel_format) throws LWJGLException { return new WindowsAWTGLCanvasPeerInfo(component, pixel_format); } Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -35,8 +35,6 @@ import java.awt.BorderLayout; import java.awt.Canvas; -import org.lwjgl.opengl.AWTInputAdapter; - public class AppletLoaderTest extends Applet { Test test = null; @@ -44,7 +42,6 @@ public void destroy() { super.destroy(); System.out.println("*** destroy ***"); - AWTInputAdapter.destroy(); } public void start() { Modified: trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -35,7 +35,6 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.AWTGLCanvas; -import org.lwjgl.opengl.AWTInputAdapter; import org.lwjgl.opengl.GL11; public class OpenGL extends AWTGLCanvas implements Test { @@ -55,11 +54,6 @@ y = 240; GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); setVSyncEnabled(true); - try { - AWTInputAdapter.create(this); - } catch (LWJGLException e) { - e.printStackTrace(); - } } public void paintGL() { @@ -93,9 +87,6 @@ String key_name = Keyboard.getKeyName(Keyboard.getEventKey()); if (Keyboard.getEventKeyState()) { switch (Keyboard.getEventKey()) { - case Keyboard.KEY_H: - AWTInputAdapter.destroy(); - break; case Keyboard.KEY_G: Mouse.setGrabbed(!Mouse.isGrabbed()); break; Deleted: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,384 +0,0 @@ -/* - * Copyright (c) 2002-2008 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. - */ -package org.lwjgl.test.opengl.awt; - -import java.awt.Frame; -import java.awt.Color; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.nio.FloatBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.LWJGLException; -import org.lwjgl.input.Mouse; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.ARBTransposeMatrix; -import org.lwjgl.opengl.AWTGLCanvas; -import org.lwjgl.opengl.AWTInputAdapter; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GLContext; - -/** - * <p> - * Gears demo using AWTInputAdapter input - * <p> - * @version $Revision$ - * @author Brian Matzon <br...@ma...> - * @author Elias Naur <eli...@us...> - * $Id$ - */ -public class AWTInputAdapterTest extends Frame { - /** AWT GL canvas */ - private AWTGLCanvas canvas0; - - private float view_rotx = 20.0f; - - private float view_roty = 30.0f; - - private float view_rotz = 0.0f; - - private int gear1; - - private int gear2; - - private int gear3; - - private float angle = 0.0f; - - /** - * C'tor - */ - public AWTInputAdapterTest() throws LWJGLException { - setTitle("Gears"); - setSize(300, 300); - setBackground(Color.BLACK); - add(canvas0 = new AWTGLCanvas() { - long startTime = 0; - long fps = 0; - int current_width; - int current_height; - public void paintGL() { - - if(startTime == 0) { - setup(); - startTime = System.currentTimeMillis() + 5000; - } - - try { - angle += 2.0f; - if (getWidth() != current_width || getHeight() != current_height) { - current_width = getWidth(); - current_height = getHeight(); - GL11.glViewport(0, 0, current_width, current_height); - } - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); - - GL11.glPushMatrix(); - GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); - GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); - GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - - GL11.glPushMatrix(); - GL11.glTranslatef(-3.0f, -2.0f, 0.0f); - GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear1); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(3.1f, -2.0f, 0.0f); - GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear2); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslatef(-3.1f, 4.2f, 0.0f); - GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f); - GL11.glCallList(gear3); - GL11.glPopMatrix(); - - GL11.glPopMatrix(); - swapBuffers(); - repaint(); - } catch (LWJGLException e) { - throw new RuntimeException(e); - } - if (startTime > System.currentTimeMillis()) { - fps++; - } else { - long timeUsed = 5000 + (startTime - System.currentTimeMillis()); - startTime = System.currentTimeMillis() + 5000; - System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = " - + (fps / (timeUsed / 1000f))); - fps = 0; - } - if (Mouse.isCreated()) { - Mouse.poll(); - while (Mouse.next()) { - view_roty += Mouse.getEventDX()*.1; - view_rotx -= Mouse.getEventDY()*.1; - } - } - if (Keyboard.isCreated()) { - Keyboard.poll(); - } - while (Keyboard.isCreated() && Keyboard.next()) { - if (Keyboard.getEventKey() != Keyboard.KEY_NONE) { - String key_name = Keyboard.getKeyName(Keyboard.getEventKey()); - if (Keyboard.getEventKeyState()) { - switch (Keyboard.getEventKey()) { - case Keyboard.KEY_ESCAPE: - System.exit(0); - break; - case Keyboard.KEY_H: - AWTInputAdapter.destroy(); - break; - case Keyboard.KEY_G: - Mouse.setGrabbed(!Mouse.isGrabbed()); - break; - default: - break; - } - System.out.println("Pressed: " + key_name); - } else - System.out.println("Released: " + key_name); - } - if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE) - System.out.println("Typed: " + Keyboard.getEventCharacter()); - } - if (Keyboard.isCreated()) { - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) - view_rotx -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) - view_rotx += .1; - if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) - view_roty -= .1; - else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) - view_roty += .1; - } - } - }); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - dispose(); - System.exit(0); - } - }); - AWTInputAdapter.create(canvas0); - canvas0.setFocusable(true); - canvas0.requestFocus(); - setResizable(true); - setVisible(true); - } - - private void setup() { - // setup ogl - FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f}); - FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f}); - FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f}); - FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f}); - pos.flip(); - red.flip(); - green.flip(); - blue.flip(); - - GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_LIGHT0); - GL11.glEnable(GL11.GL_DEPTH_TEST); - - /* make the gears */ - gear1 = GL11.glGenLists(1); - GL11.glNewList(gear1, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0f, 4.0f, 1.0f, 20, 0.7f); - GL11.glEndList(); - - gear2 = GL11.glGenLists(1); - GL11.glNewList(gear2, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5f, 2.0f, 2.0f, 10, 0.7f); - GL11.glEndList(); - - gear3 = GL11.glGenLists(1); - GL11.glNewList(gear3, GL11.GL_COMPILE); - GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3f, 2.0f, 0.5f, 10, 0.7f); - GL11.glEndList(); - - GL11.glEnable(GL11.GL_NORMALIZE); - - GL11.glMatrixMode(GL11.GL_PROJECTION); - - System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing. Press 'H' to destroy the AWTInputAdapter."); - System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR)); - System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER)); - System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION)); - System.err.println(); - System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix); - if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) { - // --- not using extensions - GL11.glLoadIdentity(); - } else { - // --- using extensions - final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put( - new float[] { 1, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1}); - identityTranspose.flip(); - ARBTransposeMatrix.glLoadTransposeMatrixARB(identityTranspose); - } - - float h = (float) 300 / (float) 300; - GL11.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glTranslatef(0.0f, 0.0f, -40.0f); - } - - /** - * Draw a gear wheel. You'll probably want to call this function when - * building a display list since we do a lot of trig here. - * - * @param inner_radius radius of hole at center - * @param outer_radius radius at center of teeth - * @param width width of gear - * @param teeth number of teeth - * @param tooth_depth depth of tooth - */ - private void gear(float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { - int i; - float r0, r1, r2; - float angle, da; - float u, v, len; - - r0 = inner_radius; - r1 = outer_radius - tooth_depth / 2.0f; - r2 = outer_radius + tooth_depth / 2.0f; - - da = 2.0f * (float) Math.PI / teeth / 4.0f; - - GL11.glShadeModel(GL11.GL_FLAT); - - GL11.glNormal3f(0.0f, 0.0f, 1.0f); - - /* draw front face */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - if (i < teeth) { - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), - width * 0.5f); - } - } - GL11.glEnd(); - - /* draw front sides of teeth */ - GL11.glBegin(GL11.GL_QUADS); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2.0f * da), r2 * (float) Math.sin(angle + 2.0f * da), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3.0f * da), r1 * (float) Math.sin(angle + 3.0f * da), width * 0.5f); - } - GL11.glEnd(); - - /* draw back face */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - } - GL11.glEnd(); - - /* draw back sides of teeth */ - GL11.glBegin(GL11.GL_QUADS); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - } - GL11.glEnd(); - - /* draw outward faces of teeth */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i < teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle), r1 * (float) Math.sin(angle), -width * 0.5f); - u = r2 * (float) Math.cos(angle + da) - r1 * (float) Math.cos(angle); - v = r2 * (float) Math.sin(angle + da) - r1 * (float) Math.sin(angle); - len = (float) Math.sqrt(u * u + v * v); - u /= len; - v /= len; - GL11.glNormal3f(v, -u, 0.0f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + da), r2 * (float) Math.sin(angle + da), -width * 0.5f); - GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), width * 0.5f); - GL11.glVertex3f(r2 * (float) Math.cos(angle + 2 * da), r2 * (float) Math.sin(angle + 2 * da), -width * 0.5f); - u = r1 * (float) Math.cos(angle + 3 * da) - r2 * (float) Math.cos(angle + 2 * da); - v = r1 * (float) Math.sin(angle + 3 * da) - r2 * (float) Math.sin(angle + 2 * da); - GL11.glNormal3f(v, -u, 0.0f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(angle + 3 * da), r1 * (float) Math.sin(angle + 3 * da), -width * 0.5f); - GL11.glNormal3f((float) Math.cos(angle), (float) Math.sin(angle), 0.0f); - } - GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), width * 0.5f); - GL11.glVertex3f(r1 * (float) Math.cos(0), r1 * (float) Math.sin(0), -width * 0.5f); - GL11.glEnd(); - - GL11.glShadeModel(GL11.GL_SMOOTH); - - /* draw inside radius cylinder */ - GL11.glBegin(GL11.GL_QUAD_STRIP); - for (i = 0; i <= teeth; i++) { - angle = i * 2.0f * (float) Math.PI / teeth; - GL11.glNormal3f(-(float) Math.cos(angle), -(float) Math.sin(angle), 0.0f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), -width * 0.5f); - GL11.glVertex3f(r0 * (float) Math.cos(angle), r0 * (float) Math.sin(angle), width * 0.5f); - } - GL11.glEnd(); - } - - public static void main(String[] args) throws LWJGLException { - new AWTInputAdapterTest(); - } -} Deleted: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2002-2008 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: org_lwjgl_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $ - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2598 $ - */ - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <jni.h> -#include "common_tools.h" -#include "org_lwjgl_opengl_LinuxAWTInput.h" - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxAWTInput_createInputOnlyWindow(JNIEnv *env, jclass unused, jlong display_ptr, jint screen) { - Display *disp = (Display *)(intptr_t)display_ptr; - Window window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, 0, NULL); - return window; -} Deleted: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2008-04-10 20:14:15 UTC (rev 3001) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2008-04-10 20:25:54 UTC (rev 3002) @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002-2008 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: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2575 2006-09-19 14:17:13Z elias_naur $ - * - * @author elias_naur <eli...@us...> - * @version $Revision: 2575 $ - */ - -#include <jni.h> -#include "context.h" -#include "org_lwjgl_opengl_WindowsAWTInput.h" - -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getWindowStyles(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(intptr_t)hwnd_ptr; - WINDOWINFO window_info; - if (!GetWindowInfo(hwnd, &window_info)) { - throwFormattedException(env, "Failed to get window info (%d).", GetLastError()); - return 0; - } - return window_info.dwStyle; -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getParentWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) { - HWND hwnd = (HWND)(intptr_t)hwnd_ptr; - return (intptr_t)GetParent(hwnd); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-12 20:07:28
|
Revision: 3007 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3007&view=rev Author: elias_naur Date: 2008-04-12 13:07:23 -0700 (Sat, 12 Apr 2008) Log Message: ----------- Linux: Rewrote focus handling to cope with the weird focus behaviour when running in an XEmbed enabled jvm (applet mode) Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-11 12:23:07 UTC (rev 3006) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 20:07:23 UTC (rev 3007) @@ -57,6 +57,18 @@ public final static int AutoRepeatModeDefault = 2; public final static int None = 0; + private final static int KeyPressMask = 1 << 0; + private final static int KeyReleaseMask = 1 << 1; + private final static int ButtonPressMask = 1 << 2; + private final static int ButtonReleaseMask = 1 << 3; + + private final static int NotifyAncestor = 0; + private final static int NotifyNonlinear = 3; + private final static int NotifyPointer = 5; + private final static int NotifyPointerRoot = 6; + private final static int NotifyDetailNone = 7; + + /** Window mode enum */ private static final int FULLSCREEN_LEGACY = 1; private static final int FULLSCREEN_NETWM = 2; @@ -78,6 +90,7 @@ /** Event buffer */ private final LinuxEvent event_buffer = new LinuxEvent(); + private final LinuxEvent tmp_event_buffer = new LinuxEvent(); /** Current mode swithcing API */ private int current_displaymode_extension = NONE; @@ -103,10 +116,13 @@ private boolean minimized; private boolean dirty; private boolean close_requested; - private boolean focused_at_least_once; private long current_cursor; private long blank_cursor; private Canvas parent; + private long parent_focus_window; + private boolean parent_focus_window_valid; + private long parent_window; + private boolean xembedded; private LinuxKeyboard keyboard; private LinuxMouse mouse; @@ -371,16 +387,17 @@ current_window_mode = getWindowMode(fullscreen); boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; this.parent = parent; - long parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); + parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); + xembedded = parent != null && isAncestorXEmbedded(parent_window); blank_cursor = createBlankCursor(); + parent_focus_window_valid = false; current_cursor = None; - focused = true; + focused = false; input_released = false; pointer_grabbed = false; keyboard_grabbed = false; close_requested = false; - focused_at_least_once = false; grab = false; minimized = false; dirty = true; @@ -397,7 +414,22 @@ } private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle) throws LWJGLException; private static native long getRootWindow(long display, int screen); + private static native boolean hasProperty(long display, long window, long property); + private static native long getParentWindow(long display, long window) throws LWJGLException; + private boolean isAncestorXEmbedded(long window) throws LWJGLException { + long xembed_atom = internAtom("_XEMBED_INFO", true); + if (xembed_atom != None) { + long w = parent_window; + while (w != None) { + if (hasProperty(getDisplay(), w, xembed_atom)) + return true; + w = getParentWindow(getDisplay(), w); + } + } + return false; + } + private static long getHandle(Canvas parent) throws LWJGLException { AWTCanvasImplementation awt_impl = AWTGLCanvas.createImplementation(); LinuxPeerInfo parent_peer_info = (LinuxPeerInfo)awt_impl.createPeerInfo(parent, null); @@ -623,17 +655,49 @@ static native void setInputFocus(long display, long window, long time); + private void relayEventToParent(LinuxEvent event_buffer, int event_mask) { + tmp_event_buffer.copyFrom(event_buffer); + tmp_event_buffer.setWindow(parent_window); + tmp_event_buffer.sendEvent(getDisplay(), parent_window, true, event_mask); + } + + private void relayEventToParent(LinuxEvent event_buffer) { + if (parent == null) + return; + switch (event_buffer.getType()) { + case LinuxEvent.KeyPress: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.KeyRelease: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.ButtonPress: + relayEventToParent(event_buffer, KeyPressMask); + break; + case LinuxEvent.ButtonRelease: + relayEventToParent(event_buffer, KeyPressMask); + break; + default: + break; + } + } + private void processEvents() { while (LinuxEvent.getPending(getDisplay()) > 0) { event_buffer.nextEvent(getDisplay()); long event_window = event_buffer.getWindow(); - if (event_buffer.getType() == LinuxEvent.ButtonPress && parent != null) - setInputFocus(getDisplay(), getWindow(), event_buffer.getButtonTime()); + relayEventToParent(event_buffer); if (event_window != getWindow() || event_buffer.filterEvent(event_window) || (mouse != null && mouse.filterEvent(grab, shouldWarpPointer(), event_buffer)) || (keyboard != null && keyboard.filterEvent(event_buffer))) continue; switch (event_buffer.getType()) { + case LinuxEvent.FocusIn: + setFocused(true, event_buffer.getFocusDetail()); + break; + case LinuxEvent.FocusOut: + setFocused(false, event_buffer.getFocusDetail()); + break; case LinuxEvent.ClientMessage: if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom)) close_requested = true; @@ -641,7 +705,6 @@ case LinuxEvent.MapNotify: dirty = true; minimized = false; - updateInputGrab(); break; case LinuxEvent.UnmapNotify: dirty = true; @@ -743,29 +806,41 @@ } private void checkInput() { - long current_focus = nGetInputFocus(getDisplay()); - focused = current_focus == getWindow(); + if (parent == null) + return; if (focused) { - focused_at_least_once = true; - acquireInput(); + if (xembedded && !parent.isFocusOwner() && parent_focus_window_valid) { + setInputFocusUnsafe(parent_focus_window); + } } else { - if (focused_at_least_once) - releaseInput(); - if (parent != null && parent.isFocusOwner()) { - setInputFocusUnsafe(); + if (parent.isFocusOwner()) { + if (xembedded) { + parent_focus_window = nGetInputFocus(getDisplay()); + parent_focus_window_valid = true; + } + setInputFocusUnsafe(getWindow()); } } } + + private void setFocused(boolean got_focus, int focus_detail) { + if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot) + return; + focused = got_focus; + if (focused) { + acquireInput(); + } else { + releaseInput(); + } + } static native long nGetInputFocus(long display); - private static native void grabServer(long display); - private static native void ungrabServer(long display); - private static void setInputFocusUnsafe() { - setInputFocus(getDisplay(), getWindow(), CurrentTime); + private void setInputFocusUnsafe(long window) { + setInputFocus(getDisplay(), window, CurrentTime); try { checkXError(getDisplay()); } catch (LWJGLException e) { - // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch ang ignore + // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore LWJGLUtil.log("Got exception while trying to focus: " + e); } } @@ -921,10 +996,6 @@ } } -/* public int isStateKeySet(int key) { - return Keyboard.STATE_UNKNOWN; - } -*/ private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; private static long createBlankCursor() { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2008-04-11 12:23:07 UTC (rev 3006) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2008-04-12 20:07:23 UTC (rev 3007) @@ -41,6 +41,8 @@ * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $ */ final class LinuxEvent { + public final static int FocusIn = 9; + public final static int FocusOut = 10; public final static int KeyPress = 2; public final static int KeyRelease = 3; public final static int ButtonPress = 4; @@ -58,8 +60,21 @@ } private static native ByteBuffer createEventBuffer(); + public final void copyFrom(LinuxEvent event) { + int pos = event_buffer.position(); + int event_pos = event.event_buffer.position(); + event_buffer.put(event.event_buffer); + event_buffer.position(pos); + event.event_buffer.position(event_pos); + } + public final static native int getPending(long display); + public final void sendEvent(long display, long window, boolean propagate, long event_mask) { + nSendEvent(event_buffer, display, window, propagate, event_mask); + } + private static native void nSendEvent(ByteBuffer event_buffer, long display, long window, boolean propagate, long event_mask); + public final boolean filterEvent(long window) { return nFilterEvent(event_buffer, window); } @@ -80,6 +95,23 @@ } private static native long nGetWindow(ByteBuffer event_buffer); + public final void setWindow(long window) { + nSetWindow(event_buffer, window); + } + private static native void nSetWindow(ByteBuffer event_buffer, long window); + + /* Focus methods */ + + public final int getFocusMode() { + return nGetFocusMode(event_buffer); + } + private static native int nGetFocusMode(ByteBuffer event_buffer); + + public final int getFocusDetail() { + return nGetFocusDetail(event_buffer); + } + private static native int nGetFocusDetail(ByteBuffer event_buffer); + /* ClientMessage methods */ public final long getClientMessageType() { Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-11 12:23:07 UTC (rev 3006) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 20:07:23 UTC (rev 3007) @@ -288,7 +288,7 @@ return false; cmap = XCreateColormap(disp, parent, vis_info->visual, AllocNone); attribs.colormap = cmap; - attribs.event_mask = ExposureMask | /*FocusChangeMask | */VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; + attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; attribmask = CWColormap | CWEventMask; if (isLegacyFullscreen(window_mode)) { attribmask |= CWOverrideRedirect; @@ -334,14 +334,38 @@ return win; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_grabServer(JNIEnv *env, jclass unused, jlong display) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; - XGrabServer(disp); + Window window = (Window)window_ptr; + Window root, parent; + Window *children; + unsigned int nchildren; + if (XQueryTree(disp, window, &root, &parent, &children, &nchildren) == 0) { + throwException(env, "XQueryTree failed"); + return None; + } + if (children != NULL) + XFree(children); + return parent; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_ungrabServer(JNIEnv *env, jclass unused, jlong display) { +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasProperty(JNIEnv *env, jclass unusued, jlong display, jlong window_ptr, jlong property_ptr) { Display *disp = (Display *)(intptr_t)display; - XUngrabServer(disp); + Window window = (Window)window_ptr; + Atom property = (Atom)property_ptr; + int num_props; + Atom *properties = XListProperties(disp, window, &num_props); + if (properties == NULL) + return JNI_FALSE; + jboolean result = JNI_FALSE; + for (int i = 0; i < num_props; i++) { + if (properties[i] == property) { + result = JNI_TRUE; + break; + } + } + XFree(properties); + return result; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) { Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2008-04-11 12:23:07 UTC (rev 3006) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2008-04-12 20:07:23 UTC (rev 3007) @@ -53,6 +53,29 @@ return XPending(disp); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSetWindow(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Window window = (Window)window_ptr; + event->xany.window = window; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nSendEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong display_ptr, jlong window_ptr, jboolean propagate, jlong eventmask) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + Display *disp = (Display *)(intptr_t)display_ptr; + Window window = (Window)window_ptr; + XSendEvent(disp, window, propagate == JNI_TRUE ? True : False, eventmask, event); +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusDetail(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xfocus.detail; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetFocusMode(JNIEnv *env, jclass unused, jobject event_buffer) { + XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); + return event->xfocus.mode; +} + JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) { XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer); Window window = (Window)window_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-12 20:40:29
|
Revision: 3008 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3008&view=rev Author: elias_naur Date: 2008-04-12 13:40:27 -0700 (Sat, 12 Apr 2008) Log Message: ----------- Linux: Added support for XFixesChangeSaveSet to increase robustness of parented mode Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 20:07:23 UTC (rev 3007) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 20:40:27 UTC (rev 3008) @@ -68,6 +68,9 @@ private final static int NotifyPointerRoot = 6; private final static int NotifyDetailNone = 7; + private final static int SetModeInsert = 0; + private final static int SaveSetRoot = 1; + private final static int SaveSetUnmap = 1; /** Window mode enum */ private static final int FULLSCREEN_LEGACY = 1; @@ -382,13 +385,21 @@ try { incDisplay(); try { + if (parent != null && !hasXFixes(getDisplay(), 1)) + throw new LWJGLException("No XFixes extension available"); ByteBuffer handle = peer_info.lockAndGetHandle(); try { current_window_mode = getWindowMode(fullscreen); boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; this.parent = parent; - parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); - current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); + long root_window = getRootWindow(getDisplay(), getDefaultScreen()); + current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, root_window); + if (parent != null) { + parent_window = getHandle(parent); + changeSaveSet(getDisplay(), current_window, SetModeInsert, SaveSetRoot, SaveSetUnmap); + reparentWindow(getDisplay(), current_window, parent_window, x, y); + } + mapRaised(getDisplay(), current_window); xembedded = parent != null && isAncestorXEmbedded(parent_window); blank_cursor = createBlankCursor(); parent_focus_window_valid = false; @@ -416,6 +427,10 @@ private static native long getRootWindow(long display, int screen); private static native boolean hasProperty(long display, long window, long property); private static native long getParentWindow(long display, long window) throws LWJGLException; + private static native void mapRaised(long display, long window); + private static native boolean hasXFixes(long display, int major); + private static native void reparentWindow(long display, long window, long parent, int x, int y); + private static native void changeSaveSet(long display, long window, int mode, int target, int map); private boolean isAncestorXEmbedded(long window) throws LWJGLException { long xembed_atom = internAtom("_XEMBED_INFO", true); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 20:07:23 UTC (rev 3007) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 20:40:27 UTC (rev 3008) @@ -43,6 +43,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/extensions/xf86vmode.h> +#include <X11/extensions/Xfixes.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -326,7 +327,6 @@ XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False), XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); } - XMapRaised(disp, win); if (!checkXError(env, disp)) { destroyWindow(env, disp, win); return 0; @@ -334,6 +334,36 @@ return win; } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_reparentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr, jlong parent_ptr, jint x, jint y) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + Window parent = (Window)parent_ptr; + XReparentWindow(disp, window, parent, x, y); +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasXFixes(JNIEnv *env, jclass unused, jlong display, jint major_requested) { + Display *disp = (Display *)(intptr_t)display; + int event, error; + if (!XFixesQueryExtension(disp, &event, &error)) + return JNI_FALSE; + int major, minor; + if (!XFixesQueryVersion(disp, &major, &minor)) + return JNI_FALSE; + return major >= major_requested ? JNI_TRUE : JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + XMapRaised(disp, window); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_changeSaveSet(JNIEnv *env, jclass unused, jlong display, jlong window_ptr, jint mode, jint target, jint map) { + Display *disp = (Display *)(intptr_t)display; + Window window = (Window)window_ptr; + XFixesChangeSaveSet(disp, window, mode, target, map); +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-12 23:09:52
|
Revision: 3012 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3012&view=rev Author: elias_naur Date: 2008-04-12 16:09:47 -0700 (Sat, 12 Apr 2008) Log Message: ----------- Linux: Removed change set code again Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 21:49:57 UTC (rev 3011) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 23:09:47 UTC (rev 3012) @@ -404,23 +404,13 @@ try { incDisplay(); try { - if (parent != null && !hasXFixes(getDisplay(), 1)) - throw new LWJGLException("No XFixes extension available"); ByteBuffer handle = peer_info.lockAndGetHandle(); try { current_window_mode = getWindowMode(fullscreen); boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED; this.parent = parent; - long root_window = getRootWindow(getDisplay(), getDefaultScreen()); - current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, root_window); - if (parent != null) { - parent.addFocusListener(focus_listener); - parent_focused = parent.isFocusOwner(); - parent_focus_changed = true; - parent_window = getHandle(parent); - changeSaveSet(getDisplay(), current_window, SetModeInsert, SaveSetRoot, SaveSetUnmap); - reparentWindow(getDisplay(), current_window, parent_window, x, y); - } + long parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); + current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window); mapRaised(getDisplay(), current_window); xembedded = parent != null && isAncestorXEmbedded(parent_window); blank_cursor = createBlankCursor(); @@ -434,6 +424,11 @@ grab = false; minimized = false; dirty = true; + if (parent != null) { + parent.addFocusListener(focus_listener); + parent_focused = parent.isFocusOwner(); + parent_focus_changed = true; + } } finally { peer_info.unlock(); } @@ -450,9 +445,7 @@ private static native boolean hasProperty(long display, long window, long property); private static native long getParentWindow(long display, long window) throws LWJGLException; private static native void mapRaised(long display, long window); - private static native boolean hasXFixes(long display, int major); private static native void reparentWindow(long display, long window, long parent, int x, int y); - private static native void changeSaveSet(long display, long window, int mode, int target, int map); private boolean isAncestorXEmbedded(long window) throws LWJGLException { long xembed_atom = internAtom("_XEMBED_INFO", true); Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 21:49:57 UTC (rev 3011) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 23:09:47 UTC (rev 3012) @@ -43,7 +43,6 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/extensions/xf86vmode.h> -#include <X11/extensions/Xfixes.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> @@ -330,29 +329,12 @@ XReparentWindow(disp, window, parent, x, y); } -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_hasXFixes(JNIEnv *env, jclass unused, jlong display, jint major_requested) { - Display *disp = (Display *)(intptr_t)display; - int event, error; - if (!XFixesQueryExtension(disp, &event, &error)) - return JNI_FALSE; - int major, minor; - if (!XFixesQueryVersion(disp, &major, &minor)) - return JNI_FALSE; - return major >= major_requested ? JNI_TRUE : JNI_FALSE; -} - JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_mapRaised(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; XMapRaised(disp, window); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_changeSaveSet(JNIEnv *env, jclass unused, jlong display, jlong window_ptr, jint mode, jint target, jint map) { - Display *disp = (Display *)(intptr_t)display; - Window window = (Window)window_ptr; - XFixesChangeSaveSet(disp, window, mode, target, map); -} - JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getParentWindow(JNIEnv *env, jclass unused, jlong display, jlong window_ptr) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-13 08:34:42
|
Revision: 3013 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3013&view=rev Author: elias_naur Date: 2008-04-13 01:34:39 -0700 (Sun, 13 Apr 2008) Log Message: ----------- Linux: Moved X error handling to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/lwjgl.map trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-12 23:09:47 UTC (rev 3012) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-13 08:34:39 UTC (rev 3013) @@ -90,6 +90,7 @@ /** Current X11 Display pointer */ private static long display; private static long current_window; + private static long saved_error_handler; private static int display_connection_usage_count = 0; @@ -268,22 +269,39 @@ static void incDisplay() throws LWJGLException { if (display_connection_usage_count == 0) { GLContext.loadOpenGLLibrary(); + saved_error_handler = setErrorHandler(); display = openDisplay(); +// synchronize(display, true); } display_connection_usage_count++; } - + private static native int callErrorHandler(long handler, long display, long error_ptr); + private static native long setErrorHandler(); + private static native long resetErrorHandler(long handler); + private static native void synchronize(long display, boolean synchronize); + + private static int globalErrorHandler(long display, long event_ptr, long error_display, long serial, long error_code, long request_code, long minor_code) throws LWJGLException { + if (display == getDisplay()) { + String error_msg = getErrorText(display, error_code); + throw new LWJGLException("X Error - disp: 0x" + Long.toHexString(error_display) + " serial: " + serial + " error: " + error_msg + " request_code: " + request_code + " minor_code: " + minor_code); + } else if (saved_error_handler != 0) + callErrorHandler(saved_error_handler, display, event_ptr); + return 0; + } + private static native String getErrorText(long display, long error_code); + static void decDisplay() { + display_connection_usage_count--; + if (display_connection_usage_count < 0) + throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count); /* * Some drivers (at least some versions of the radeon dri driver) * don't like it when the display is closed and later re-opened, * so we'll just let the singleton display connection leak. */ -/* display_connection_usage_count--; - if (display_connection_usage_count < 0) - throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count); - if (display_connection_usage_count == 0) { +/* if (display_connection_usage_count == 0) { closeDisplay(display); + resetErrorHandler(saved_error_handler); display = 0; GLContext.unloadOpenGLLibrary(); }*/ @@ -870,15 +888,15 @@ static native long nGetInputFocus(long display); private void setInputFocusUnsafe(long window) { - setInputFocus(getDisplay(), window, CurrentTime); try { - checkXError(getDisplay()); + setInputFocus(getDisplay(), window, CurrentTime); + sync(getDisplay(), false); } catch (LWJGLException e) { // Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore LWJGLUtil.log("Got exception while trying to focus: " + e); } } - private static native void checkXError(long display) throws LWJGLException; + private static native void sync(long display, boolean throw_away_events) throws LWJGLException; private void releaseInput() { if (isLegacyFullscreen() || input_released) Modified: trunk/LWJGL/src/native/linux/lwjgl.map =================================================================== --- trunk/LWJGL/src/native/linux/lwjgl.map 2008-04-12 23:09:47 UTC (rev 3012) +++ trunk/LWJGL/src/native/linux/lwjgl.map 2008-04-13 08:34:39 UTC (rev 3013) @@ -1,4 +1,7 @@ { - global: Java_*; + global: + Java_*; + JNI_OnLoad; + JNI_OnUnload; local: *; }; Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-12 23:09:47 UTC (rev 3012) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-13 08:34:39 UTC (rev 3013) @@ -76,35 +76,27 @@ static Visual *current_visual; -static bool async_x_error; -static char error_message[ERR_MSG_SIZE]; - static bool checkXError(JNIEnv *env, Display *disp) { XSync(disp, False); - if (async_x_error) { - async_x_error = false; - if (env != NULL) - throwException(env, error_message); - else - printfDebug(error_message); - return false; - } else - return true; + return (*env)->ExceptionCheck(env) == JNI_FALSE; } -static int errorHandler(Display *disp, XErrorEvent *error) { - char err_msg_buffer[ERR_MSG_SIZE]; - XGetErrorText(disp, error->error_code, err_msg_buffer, ERR_MSG_SIZE); - err_msg_buffer[ERR_MSG_SIZE - 1] = '\0'; - snprintf(error_message, ERR_MSG_SIZE, "X Error - serial: %d, error_code: %s, request_code: %d, minor_code: %d", (int)error->serial, err_msg_buffer, (int)error->request_code, (int)error->minor_code); - error_message[ERR_MSG_SIZE - 1] = '\0'; - async_x_error = true; - return 0; +static int global_error_handler(Display *disp, XErrorEvent *error) { + JNIEnv *env = getThreadEnv(); + if (env != NULL) { + jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay"); + if (org_lwjgl_LinuxDisplay_class == NULL) + return 0; + jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I"); + if (handler_method == NULL) + return 0; + return (*env)->CallStaticIntMethod(env, org_lwjgl_LinuxDisplay_class, handler_method, (jlong)(intptr_t)disp, (jlong)(intptr_t)error, + (jlong)(intptr_t)error->display, (jlong)error->serial, (jlong)error->error_code, (jlong)error->request_code, (jlong)error->minor_code); + } else + return 0; } static jlong openDisplay(JNIEnv *env) { - async_x_error = false; - XSetErrorHandler(errorHandler); Display *display_connection = XOpenDisplay(NULL); if (display_connection == NULL) { throwException(env, "Could not open X display connection"); @@ -113,12 +105,35 @@ return (intptr_t)display_connection; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_checkXError(JNIEnv *env, jclass unused, jlong display_ptr) { +JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) { Display *disp = (Display *)(intptr_t)display_ptr; - XSync(disp, False); - checkXError(env, disp); + char err_msg_buffer[ERR_MSG_SIZE]; + XGetErrorText(disp, error_code, err_msg_buffer, ERR_MSG_SIZE); + err_msg_buffer[ERR_MSG_SIZE - 1] = '\0'; + return NewStringNativeWithLength(env, err_msg_buffer, strlen(err_msg_buffer)); } +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_callErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr, jlong display_ptr, jlong event_ptr) { + XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr; + Display *disp = (Display *)(intptr_t)display_ptr; + XErrorEvent *event = (XErrorEvent *)(intptr_t)event_ptr; + return (jint)handler(disp, event); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setErrorHandler(JNIEnv *env, jclass unused) { + return (intptr_t)XSetErrorHandler(global_error_handler); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetErrorHandler(JNIEnv *env, jclass unused, jlong handler_ptr) { + XErrorHandler handler = (XErrorHandler)(intptr_t)handler_ptr; + return (intptr_t)XSetErrorHandler(handler); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_sync(JNIEnv *env, jclass unused, jlong display_ptr, jboolean throw_away_events) { + Display *disp = (Display *)(intptr_t)display_ptr; + XSync(disp, throw_away_events ? True : False); +} + JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) { Display *disp = (Display *)(intptr_t)display_ptr; return XDefaultScreen(disp); @@ -238,6 +253,11 @@ XResizeWindow(disp, window, width, height); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_synchronize(JNIEnv *env, jclass clazz, jlong display, jboolean synchronize) { + Display *disp = (Display *)(intptr_t)display; + XSynchronize(disp, synchronize ? True : False); +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getRootWindow(JNIEnv *env, jclass clazz, jlong display, jint screen) { Display *disp = (Display *)(intptr_t)display; return RootWindow(disp, screen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-13 18:43:30
|
Revision: 3020 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3020&view=rev Author: elias_naur Date: 2008-04-13 11:43:27 -0700 (Sun, 13 Apr 2008) Log Message: ----------- Applet focus fixes Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-13 18:26:22 UTC (rev 3019) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-04-13 18:43:27 UTC (rev 3020) @@ -468,7 +468,7 @@ private boolean isAncestorXEmbedded(long window) throws LWJGLException { long xembed_atom = internAtom("_XEMBED_INFO", true); if (xembed_atom != None) { - long w = parent_window; + long w = window; while (w != None) { if (hasProperty(getDisplay(), w, xembed_atom)) return true; Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-13 18:26:22 UTC (rev 3019) +++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2008-04-13 18:43:27 UTC (rev 3020) @@ -85,8 +85,11 @@ JNIEnv *env = getThreadEnv(); if (env != NULL) { jclass org_lwjgl_LinuxDisplay_class = (*env)->FindClass(env, "org/lwjgl/opengl/LinuxDisplay"); - if (org_lwjgl_LinuxDisplay_class == NULL) + if (org_lwjgl_LinuxDisplay_class == NULL) { + // Don't propagate error + (*env)->ExceptionClear(env); return 0; + } jmethodID handler_method = (*env)->GetStaticMethodID(env, org_lwjgl_LinuxDisplay_class, "globalErrorHandler", "(JJJJJJJ)I"); if (handler_method == NULL) return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-30 15:29:42
|
Revision: 3056 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3056&view=rev Author: elias_naur Date: 2008-04-30 08:29:39 -0700 (Wed, 30 Apr 2008) Log Message: ----------- Windows: Moved child window style selection to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/context.c trunk/LWJGL/src/native/windows/context.h trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 14:58:47 UTC (rev 3055) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 15:29:39 UTC (rev 3056) @@ -154,7 +154,7 @@ this.parent = parent; long parent_hwnd = parent != null ? getHwnd(parent) : 0; boolean isUndecorated = isUndecorated(); - nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent_hwnd); + nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent != null, parent_hwnd); peer_info.initDC(); showWindow(getHwnd(), SW_SHOWDEFAULT); if (parent == null) { @@ -162,7 +162,7 @@ setFocus(getHwnd()); } } - private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, long parent_hwnd) throws LWJGLException; + private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); Modified: trunk/LWJGL/src/native/windows/context.c =================================================================== --- trunk/LWJGL/src/native/windows/context.c 2008-04-30 14:58:47 UTC (rev 3055) +++ trunk/LWJGL/src/native/windows/context.c 2008-04-30 15:29:39 UTC (rev 3056) @@ -139,13 +139,13 @@ * * Returns true for success, or false for failure */ -HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent) +HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, bool child_window, HWND parent) { RECT clientSize; DWORD exstyle, windowflags; HWND new_hwnd; - getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated, parent != NULL); + getWindowFlags(&windowflags, &exstyle, fullscreen, undecorated, child_window); // If we're not a fullscreen window, adjust the height to account for the // height of the title bar (unless undecorated) @@ -468,5 +468,5 @@ HWND createDummyWindow(int origin_x, int origin_y) { if (!registerDummyWindow()) return NULL; - return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, NULL); + return createWindow(_CONTEXT_PRIVATE_CLASS_NAME, origin_x, origin_y, 1, 1, false, false, false, NULL); } Modified: trunk/LWJGL/src/native/windows/context.h =================================================================== --- trunk/LWJGL/src/native/windows/context.h 2008-04-30 14:58:47 UTC (rev 3055) +++ trunk/LWJGL/src/native/windows/context.h 2008-04-30 15:29:39 UTC (rev 3056) @@ -89,7 +89,7 @@ * * Returns true for success, or false for failure */ -extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, HWND parent); +extern HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated, bool child_window, HWND parent); extern int findPixelFormatOnDC(JNIEnv *env, HDC hdc, int origin_x, int origin_y, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer, bool floating_point); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 14:58:47 UTC (rev 3055) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 15:29:39 UTC (rev 3056) @@ -193,7 +193,7 @@ freeSmallIcon(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jlong parent_hwnd) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { jclass cls_displayMode = (*env)->GetObjectClass(env, mode); jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I"); @@ -208,7 +208,7 @@ oneShotInitialised = true; } - display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, (HWND)parent_hwnd); + display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, child_window, (HWND)parent_hwnd); if (display_hwnd == NULL) { throwException(env, "Failed to create the window."); return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-30 16:01:27
|
Revision: 3057 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3057&view=rev Author: elias_naur Date: 2008-04-30 09:01:25 -0700 (Wed, 30 Apr 2008) Log Message: ----------- Windows: Made WindowsDisplayPeerInfo take hwnd and hdc arguments Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 15:29:39 UTC (rev 3056) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 16:01:25 UTC (rev 3057) @@ -155,7 +155,7 @@ long parent_hwnd = parent != null ? getHwnd(parent) : 0; boolean isUndecorated = isUndecorated(); nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent != null, parent_hwnd); - peer_info.initDC(); + peer_info.initDC(getHwnd(), getHdc()); showWindow(getHwnd(), SW_SHOWDEFAULT); if (parent == null) { setForegroundWindow(getHwnd()); @@ -468,6 +468,7 @@ private static native long getDllInstance(); private static native long getHwnd(); + private static native long getHdc(); private static native long getDesktopWindow(); static void centerCursor(long hwnd) { getGlobalClientRect(getHwnd(), rect); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java 2008-04-30 15:29:39 UTC (rev 3056) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java 2008-04-30 16:01:25 UTC (rev 3057) @@ -49,11 +49,11 @@ GLContext.loadOpenGLLibrary(); } - void initDC() throws LWJGLException { - nInitDC(getHandle()); + void initDC(long hwnd, long hdc) throws LWJGLException { + nInitDC(getHandle(), hwnd, hdc); choosePixelFormat(0, 0, pixel_format, null, true, true, false, true); } - private static native void nInitDC(ByteBuffer peer_info_handle); + private static native void nInitDC(ByteBuffer peer_info_handle, long hwnd, long hdc); protected void doLockAndInitHandle() throws LWJGLException { // NO-OP Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 15:29:39 UTC (rev 3056) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 16:01:25 UTC (rev 3057) @@ -155,15 +155,14 @@ } } +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getHdc(JNIEnv *env, jclass unused) { + return (INT_PTR)display_hdc; +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getHwnd(JNIEnv *env, jclass unused) { return (INT_PTR)display_hwnd; } -/* - * Class: org_lwjgl_Window - * Method: nSetTitle - * Signature: ()V - */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setTitle (JNIEnv * env, jobject self, jstring title_obj) { char * title = GetStringNativeChars(env, title_obj); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2008-04-30 15:29:39 UTC (rev 3056) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2008-04-30 16:01:25 UTC (rev 3057) @@ -44,8 +44,10 @@ #include "common_tools.h" JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nInitDC - (JNIEnv *env, jclass clazz, jobject peer_info_handle) { + (JNIEnv *env, jclass clazz, jobject peer_info_handle, jlong hwnd_ptr, jlong hdc_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + HDC hdc = (HDC)(INT_PTR)hdc_ptr; WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->drawable_hdc = getCurrentHDC(); - peer_info->u.hwnd = getCurrentHWND(); + peer_info->drawable_hdc = hdc; + peer_info->u.hwnd = hwnd; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-04-30 16:40:22
|
Revision: 3058 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3058&view=rev Author: elias_naur Date: 2008-04-30 09:40:14 -0700 (Wed, 30 Apr 2008) Log Message: ----------- Windows: Moved hwnd and hdc to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/Window.h trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-04-30 16:01:25 UTC (rev 3057) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-04-30 16:40:14 UTC (rev 3058) @@ -31,7 +31,13 @@ */ package org.lwjgl; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; +import java.security.AccessController; +import java.lang.reflect.Method; +import org.lwjgl.opengl.Display; + /** * <p> * @author $Author$ @@ -39,7 +45,7 @@ * $Id$ */ final class WindowsSysImplementation extends DefaultSysImplementation { - private final static int JNI_VERSION = 16; + private final static int JNI_VERSION = 17; static { Sys.initialize(); @@ -53,10 +59,41 @@ return 1000; } - public native long getTime(); + public long getTime() { + return nGetTime(); + } + private static native long nGetTime(); - public native void alert(String title, String message); + private static long getHwnd() { + /* Use reflection since we can't make Display.getImplementation + * public + */ + try { + Long hwnd_obj = (Long)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null); + getImplementation_method.setAccessible(true); + Object display_impl = getImplementation_method.invoke(null, null); + if (display_impl == null) + return null; + Class WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay"); + Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd", null); + getHwnd_method.setAccessible(true); + Long hwnd = (Long)getHwnd_method.invoke(display_impl, null); + return hwnd; + } + }); + return hwnd_obj.longValue(); + } catch (PrivilegedActionException e) { + throw new Error(e); + } + } + public void alert(String title, String message) { + nAlert(getHwnd(), title, message); + } + private static native void nAlert(long parent_hwnd, String title, String message); + public boolean openURL(final String url) { try { LWJGLUtil.execPrivileged(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); @@ -67,5 +104,8 @@ } } - public native String getClipboard(); + public String getClipboard() { + return nGetClipboard(); + } + private static native String nGetClipboard(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 16:01:25 UTC (rev 3057) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 16:40:14 UTC (rev 3058) @@ -140,6 +140,9 @@ private boolean did_maximize; private boolean inAppActivate; + private long hwnd; + private long hdc; + public WindowsDisplay() { current_display = this; } @@ -154,7 +157,15 @@ this.parent = parent; long parent_hwnd = parent != null ? getHwnd(parent) : 0; boolean isUndecorated = isUndecorated(); - nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent != null, parent_hwnd); + this.hwnd = nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent != null, parent_hwnd); + if (hwnd == 0) { + throw new LWJGLException("Failed to create window"); + } + this.hdc = getDC(hwnd); + if (hdc == 0) { + nDestroyWindow(hwnd, hdc); + throw new LWJGLException("Failed to get dc"); + } peer_info.initDC(getHwnd(), getHdc()); showWindow(getHwnd(), SW_SHOWDEFAULT); if (parent == null) { @@ -162,7 +173,7 @@ setFocus(getHwnd()); } } - private native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; + private native long nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); @@ -180,10 +191,10 @@ } public void destroyWindow() { - nDestroyWindow(); + nDestroyWindow(hwnd, hdc); resetCursorClipping(); } - private static native void nDestroyWindow(); + private static native void nDestroyWindow(long hwnd, long hdc); static void resetCursorClipping() { if (cursor_clipped) { try { @@ -338,7 +349,10 @@ } private static native DisplayMode getCurrentDisplayMode() throws LWJGLException; - public native void setTitle(String title); + public void setTitle(String title) { + nSetTitle(hwnd, title); + } + private static native void nSetTitle(long hwnd, String title); public boolean isCloseRequested() { boolean saved = close_requested; @@ -467,11 +481,19 @@ static native int getSystemMetrics(int index); private static native long getDllInstance(); - private static native long getHwnd(); - private static native long getHdc(); + + private long getHwnd() { + return hwnd; + } + + private long getHdc() { + return hdc; + } + + private static native long getDC(long hwnd); private static native long getDesktopWindow(); static void centerCursor(long hwnd) { - getGlobalClientRect(getHwnd(), rect); + getGlobalClientRect(hwnd, rect); int local_offset_x = rect.left; int local_offset_y = rect.top; getGlobalClientRect(getDesktopWindow(), rect2); @@ -482,7 +504,7 @@ int local_x = center_x - local_offset_x; int local_y = center_y - local_offset_y; if (current_display != null) - current_display.setMousePosition(local_x, transformY(getHwnd(), local_y)); + current_display.setMousePosition(local_x, transformY(hwnd, local_y)); } private void setMousePosition(int x, int y) { @@ -582,12 +604,12 @@ int size = icons[i].limit() / 4; if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) { - nSetWindowIconSmall(small_icon_size, small_icon_size, icons[i].asIntBuffer()); + nSetWindowIconSmall(hwnd, small_icon_size, small_icon_size, icons[i].asIntBuffer()); used++; done_small = true; } if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) { - nSetWindowIconLarge(large_icon_size, large_icon_size, icons[i].asIntBuffer()); + nSetWindowIconLarge(hwnd, large_icon_size, large_icon_size, icons[i].asIntBuffer()); used++; done_large = true; } @@ -596,9 +618,9 @@ return used; } - private static native int nSetWindowIconSmall(int width, int height, IntBuffer icon); + private static native int nSetWindowIconSmall(long hwnd, int width, int height, IntBuffer icon); - private static native int nSetWindowIconLarge(int width, int height, IntBuffer icon); + private static native int nSetWindowIconLarge(long hwnd, int width, int height, IntBuffer icon); private void handleMouseButton(int button, int state, long millis) { if (mouse != null) Modified: trunk/LWJGL/src/native/windows/Window.h =================================================================== --- trunk/LWJGL/src/native/windows/Window.h 2008-04-30 16:01:25 UTC (rev 3057) +++ trunk/LWJGL/src/native/windows/Window.h 2008-04-30 16:40:14 UTC (rev 3058) @@ -62,7 +62,4 @@ #define WINDOW_H_API extern #endif /* _PRIVATE_WINDOW_H_ */ - WINDOW_H_API HDC getCurrentHDC(); - - WINDOW_H_API HWND getCurrentHWND(); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Modified: trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2008-04-30 16:01:25 UTC (rev 3057) +++ trunk/LWJGL/src/native/windows/org_lwjgl_Sys.c 2008-04-30 16:40:14 UTC (rev 3058) @@ -45,7 +45,7 @@ #include "common_tools.h" #include <malloc.h> -JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_getTime(JNIEnv * env, jobject ignored) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetTime(JNIEnv * env, jclass unused) { DWORD time; timeBeginPeriod(1); @@ -55,10 +55,11 @@ return time; } -JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_alert(JNIEnv * env, jobject ignored, jstring title, jstring message) { +JNIEXPORT void JNICALL Java_org_lwjgl_WindowsSysImplementation_nAlert(JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title, jstring message) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; char * eMessageText = GetStringNativeChars(env, message); char * cTitleBarText = GetStringNativeChars(env, title); - MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); + MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText); @@ -66,8 +67,8 @@ free(cTitleBarText); } -JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_getClipboard - (JNIEnv * env, jobject ignored) +JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard + (JNIEnv * env, jclass unused) { // Check to see if there's text available in the clipboard BOOL textAvailable = IsClipboardFormatAvailable(CF_TEXT); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 16:01:25 UTC (rev 3057) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 16:40:14 UTC (rev 3058) @@ -52,20 +52,9 @@ static HICON small_icon = NULL; static HICON large_icon = NULL; -static HWND display_hwnd = NULL; // Handle to the window -static HDC display_hdc = NULL; // Device context - // has recovered from minimized #define WINDOWCLASSNAME "LWJGL" -HDC getCurrentHDC() { - return display_hdc; -} - -HWND getCurrentHWND() { - return display_hwnd; -} - static void freeLargeIcon() { if (large_icon != NULL) { DestroyIcon(large_icon); @@ -140,33 +129,29 @@ * work properly */ MSG msg; - if (display_hwnd != NULL) { - while (!(*env)->ExceptionOccurred(env) && PeekMessage( - &msg, // message information - NULL, // handle to window - 0, // first message - 0, // last message - PM_REMOVE // removal options - )) - { - DispatchMessage(&msg); - TranslateMessage(&msg); - } + while (!(*env)->ExceptionOccurred(env) && PeekMessage( + &msg, // message information + NULL, // handle to window + 0, // first message + 0, // last message + PM_REMOVE // removal options + )) + { + DispatchMessage(&msg); + TranslateMessage(&msg); } } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getHdc(JNIEnv *env, jclass unused) { - return (INT_PTR)display_hdc; +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getDC(JNIEnv *env, jclass unused, jlong hwnd_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + return (INT_PTR)GetDC(hwnd); } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getHwnd(JNIEnv *env, jclass unused) { - return (INT_PTR)display_hwnd; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setTitle - (JNIEnv * env, jobject self, jstring title_obj) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetTitle + (JNIEnv * env, jclass unused, jlong hwnd_ptr, jstring title_obj) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; char * title = GetStringNativeChars(env, title_obj); - SetWindowText(display_hwnd, title); + SetWindowText(hwnd, title); free(title); } @@ -183,45 +168,39 @@ return org_lwjgl_WindowsSysImplementation_JNI_VERSION; } -static void destroyWindow(JNIEnv *env) { - jclass display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(display_hwnd, GWLP_USERDATA); - closeWindow(&display_hwnd, &display_hdc); +static void destroyWindow(JNIEnv *env, HWND *hwnd, HDC *hdc) { + jclass display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(*hwnd, GWLP_USERDATA); + closeWindow(hwnd, hdc); if (display_class_global != NULL) (*env)->DeleteGlobalRef(env, display_class_global); freeLargeIcon(); freeSmallIcon(); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { jclass cls_displayMode = (*env)->GetObjectClass(env, mode); jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); 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); + HWND hwnd; static bool oneShotInitialised = false; if (!oneShotInitialised) { if (!registerWindow(lwjglWindowProc, WINDOWCLASSNAME)) { throwException(env, "Could not register window class"); - return; + return 0; } oneShotInitialised = true; } - display_hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, child_window, (HWND)parent_hwnd); - if (display_hwnd == NULL) { - throwException(env, "Failed to create the window."); - return; - } - display_hdc = GetDC(display_hwnd); - if (display_hdc == NULL) { - destroyWindow(env); - throwException(env, "Failed to get the window DC."); - return; - } + hwnd = createWindow(WINDOWCLASSNAME, x, y, width, height, fullscreen, undecorated, child_window, (HWND)parent_hwnd); + return (INT_PTR)hwnd; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz) { - destroyWindow(env); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + destroyWindow(env, &hwnd, &hdc); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) { @@ -475,15 +454,16 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconSmall - (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint width, jint height, jobject iconBuffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); freeSmallIcon(); small_icon = createWindowIcon(env, imgData, width, height); if (small_icon != NULL) { - if (display_hwnd != NULL) { - SendMessage(display_hwnd, WM_SETICON, ICON_SMALL, (LPARAM) (small_icon)); + if (hwnd != NULL) { + SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) (small_icon)); return 0; } @@ -493,15 +473,16 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconLarge - (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint width, jint height, jobject iconBuffer) { + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); freeLargeIcon(); large_icon = createWindowIcon(env, imgData, width, height); if (large_icon != NULL) { - if (display_hwnd != NULL) { - SendMessage(display_hwnd, WM_SETICON, ICON_BIG, (LPARAM) (large_icon)); + if (hwnd != NULL) { + SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) (large_icon)); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-05-01 09:21:00
|
Revision: 3060 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3060&view=rev Author: elias_naur Date: 2008-05-01 02:20:57 -0700 (Thu, 01 May 2008) Log Message: ----------- Windows: Moved icon handles to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-04-30 19:00:08 UTC (rev 3059) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-05-01 09:20:57 UTC (rev 3060) @@ -45,7 +45,7 @@ * $Id$ */ final class WindowsSysImplementation extends DefaultSysImplementation { - private final static int JNI_VERSION = 17; + private final static int JNI_VERSION = 18; static { Sys.initialize(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-04-30 19:00:08 UTC (rev 3059) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-05-01 09:20:57 UTC (rev 3060) @@ -68,6 +68,7 @@ private final static int WM_SYSKEYDOWN = 260; private final static int WM_SYSCHAR = 262; private final static int WM_CHAR = 258; + private final static int WM_SETICON = 0x0080; private final static int WM_QUIT = 0x0012; private final static int WM_SYSCOMMAND = 0x0112; @@ -113,6 +114,9 @@ private final static int SW_SHOWDEFAULT = 10; private final static int SW_RESTORE = 9; + private final static int ICON_SMALL = 0; + private final static int ICON_BIG = 1; + private final static IntBuffer rect_buffer = BufferUtils.createIntBuffer(4); private final static Rect rect = new Rect(); private final static Rect rect2 = new Rect(); @@ -143,6 +147,9 @@ private long hwnd; private long hdc; + private long small_icon; + private long large_icon; + public WindowsDisplay() { current_display = this; } @@ -192,6 +199,8 @@ public void destroyWindow() { nDestroyWindow(hwnd, hdc); + freeLargeIcon(); + freeSmallIcon(); resetCursorClipping(); } private static native void nDestroyWindow(long hwnd, long hdc); @@ -580,7 +589,20 @@ ((WindowsPbufferPeerInfo)handle).releaseTexImageFromPbuffer(buffer); } + private void freeSmallIcon() { + if (small_icon != 0) { + destroyIcon(small_icon); + small_icon = 0; + } + } + private void freeLargeIcon() { + if (large_icon != 0) { + destroyIcon(large_icon); + large_icon = 0; + } + } + /** * Sets one or more icons for the Display. * <ul> @@ -604,12 +626,16 @@ int size = icons[i].limit() / 4; if ((((int) Math.sqrt(size)) == small_icon_size) && (!done_small)) { - nSetWindowIconSmall(hwnd, small_icon_size, small_icon_size, icons[i].asIntBuffer()); + freeSmallIcon(); + small_icon = createIcon(small_icon_size, small_icon_size, icons[i].asIntBuffer()); + sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_icon); used++; done_small = true; } if ((((int) Math.sqrt(size)) == large_icon_size) && (!done_large)) { - nSetWindowIconLarge(hwnd, large_icon_size, large_icon_size, icons[i].asIntBuffer()); + freeLargeIcon(); + large_icon = createIcon(large_icon_size, large_icon_size, icons[i].asIntBuffer()); + sendMessage(hwnd, WM_SETICON, ICON_BIG, large_icon); used++; done_large = true; } @@ -617,11 +643,10 @@ return used; } + private static native long createIcon(int width, int height, IntBuffer icon); + private static native void destroyIcon(long handle); + private static native long sendMessage(long hwnd, long msg, long wparam, long lparam); - private static native int nSetWindowIconSmall(long hwnd, int width, int height, IntBuffer icon); - - private static native int nSetWindowIconLarge(long hwnd, int width, int height, IntBuffer icon); - private void handleMouseButton(int button, int state, long millis) { if (mouse != null) mouse.handleMouseButton((byte)button, (byte)state, millis); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-04-30 19:00:08 UTC (rev 3059) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-05-01 09:20:57 UTC (rev 3060) @@ -50,25 +50,8 @@ #include "org_lwjgl_WindowsSysImplementation.h" #include "context.h" -static HICON small_icon = NULL; -static HICON large_icon = NULL; - #define WINDOWCLASSNAME "LWJGL" -static void freeLargeIcon() { - if (large_icon != NULL) { - DestroyIcon(large_icon); - large_icon = NULL; - } -} - -static void freeSmallIcon() { - if (small_icon != NULL) { - DestroyIcon(small_icon); - small_icon = NULL; - } -} - /* * WindowProc for the GL window. */ @@ -173,8 +156,6 @@ closeWindow(hwnd, hdc); if (display_class_global != NULL) (*env)->DeleteGlobalRef(env, display_class_global); - freeLargeIcon(); - freeSmallIcon(); } JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { @@ -453,42 +434,22 @@ return icon; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconSmall - (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint width, jint height, jobject iconBuffer) -{ - HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_destroyIcon + (JNIEnv *env, jclass clazz, jlong handle) { + HICON icon = (HICON)(INT_PTR)handle; + DestroyIcon(icon); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_createIcon + (JNIEnv *env, jclass clazz, jint width, jint height, jobject iconBuffer) { jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); - - freeSmallIcon(); - small_icon = createWindowIcon(env, imgData, width, height); - if (small_icon != NULL) { - if (hwnd != NULL) { - SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) (small_icon)); - - return 0; - } - } - - return -1; + return (INT_PTR)createWindowIcon(env, imgData, width, height); } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetWindowIconLarge - (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jint width, jint height, jobject iconBuffer) -{ +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_sendMessage + (JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong msg, jlong wparam, jlong lparam) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; - jint *imgData = (jint *)(*env)->GetDirectBufferAddress(env, iconBuffer); - - freeLargeIcon(); - large_icon = createWindowIcon(env, imgData, width, height); - if (large_icon != NULL) { - if (hwnd != NULL) { - SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) (large_icon)); - - return 0; - } - } - - return -1; + return SendMessage(hwnd, (UINT)msg, (WPARAM)wparam, (LPARAM)lparam); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nSetCursorPosition This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-05-01 09:37:29
|
Revision: 3061 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3061&view=rev Author: elias_naur Date: 2008-05-01 02:37:21 -0700 (Thu, 01 May 2008) Log Message: ----------- Windows: Split nChoosePixelFormat's applyPixelFormat() out in a seperate function Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2008-05-01 09:20:57 UTC (rev 3060) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2008-05-01 09:37:21 UTC (rev 3061) @@ -49,10 +49,17 @@ private static native ByteBuffer createHandle(); protected void choosePixelFormat(int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException { - nChoosePixelFormat(getHandle(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered); + int pixel_format_id = nChoosePixelFormat(getHdc(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered); + setPixelFormat(getHdc(), pixel_format_id); } - private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; + private static native int nChoosePixelFormat(long hdc, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException; + private static native void setPixelFormat(long hdc, int pixel_format) throws LWJGLException; + public final long getHdc() { + return nGetHdc(getHandle()); + } + private static native long nGetHdc(ByteBuffer handle); + public final long getHwnd() { return nGetHwnd(getHandle()); } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2008-05-01 09:20:57 UTC (rev 3060) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2008-05-01 09:37:21 UTC (rev 3061) @@ -47,18 +47,25 @@ return newJavaManagedByteBuffer(env, sizeof(WindowsPeerInfo)); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat - (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { - WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nChoosePixelFormat + (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint origin_x, jint origin_y, jobject pixel_format, jobject pixel_format_caps, jboolean use_hdc_bpp, jboolean window, jboolean pbuffer, jboolean double_buffer) { + HDC hdc = (HDC)(INT_PTR)hdc_ptr; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); bool floating_point = (bool)(*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "floating_point", "Z")); - int pixel_format_id = findPixelFormatOnDC(env, peer_info->drawable_hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); - if (pixel_format_id == -1) - return; - // Let it throw - applyPixelFormat(env, peer_info->drawable_hdc, pixel_format_id); + return findPixelFormatOnDC(env, hdc, origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, window, pbuffer, double_buffer, floating_point); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_setPixelFormat + (JNIEnv *env, jclass clazz, jlong hdc_ptr, jint pixel_format) { + HDC hdc = (HDC)(INT_PTR)hdc_ptr; + applyPixelFormat(env, hdc, pixel_format); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHdc(JNIEnv *env, jclass unused, jobject peer_info_handle) { + WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); + return (intptr_t)peer_info->drawable_hdc; +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); return (intptr_t)peer_info->u.hwnd; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-05-05 16:46:20
|
Revision: 3065 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3065&view=rev Author: elias_naur Date: 2008-05-05 09:46:16 -0700 (Mon, 05 May 2008) Log Message: ----------- Windows: Generalized WindowsDispaly.nCreateWindow Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-05-02 11:05:49 UTC (rev 3064) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2008-05-05 16:46:16 UTC (rev 3065) @@ -45,7 +45,7 @@ * $Id$ */ final class WindowsSysImplementation extends DefaultSysImplementation { - private final static int JNI_VERSION = 18; + private final static int JNI_VERSION = 19; static { Sys.initialize(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-05-02 11:05:49 UTC (rev 3064) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-05-05 16:46:16 UTC (rev 3065) @@ -164,7 +164,7 @@ this.parent = parent; long parent_hwnd = parent != null ? getHwnd(parent) : 0; boolean isUndecorated = isUndecorated(); - this.hwnd = nCreateWindow(mode, fullscreen, x, y, isUndecorated, parent != null, parent_hwnd); + this.hwnd = nCreateWindow(fullscreen, x, y, mode.getWidth(), mode.getHeight(), isUndecorated, parent != null, parent_hwnd); if (hwnd == 0) { throw new LWJGLException("Failed to create window"); } @@ -187,7 +187,7 @@ throw e; } } - private native long nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; + private native long nCreateWindow(boolean fullscreen, int x, int y, int width, int height, boolean undecorated, boolean child_window, long parent_hwnd) throws LWJGLException; private static boolean isUndecorated() { return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-05-02 11:05:49 UTC (rev 3064) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-05-05 16:46:16 UTC (rev 3065) @@ -158,12 +158,7 @@ (*env)->DeleteGlobalRef(env, display_class_global); } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jobject mode, jboolean fullscreen, jint x, jint y, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { - jclass cls_displayMode = (*env)->GetObjectClass(env, mode); - jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I"); - 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); +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jboolean fullscreen, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { HWND hwnd; static bool oneShotInitialised = false; if (!oneShotInitialised) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2008-05-05 17:24:43
|
Revision: 3066 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3066&view=rev Author: elias_naur Date: 2008-05-05 10:24:42 -0700 (Mon, 05 May 2008) Log Message: ----------- Windows: Split WindowsDisplay.nDestroyWindow into nReleaseDC and nDestroyWindow Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-05-05 16:46:16 UTC (rev 3065) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-05-05 17:24:42 UTC (rev 3066) @@ -170,7 +170,7 @@ } this.hdc = getDC(hwnd); if (hdc == 0) { - nDestroyWindow(hwnd, hdc); + nDestroyWindow(hwnd); throw new LWJGLException("Failed to get dc"); } try { @@ -183,7 +183,8 @@ setFocus(getHwnd()); } } catch (LWJGLException e) { - nDestroyWindow(hwnd, hdc); + nReleaseDC(hwnd, hdc); + nDestroyWindow(hwnd); throw e; } } @@ -205,12 +206,14 @@ } public void destroyWindow() { - nDestroyWindow(hwnd, hdc); + nReleaseDC(hwnd, hdc); + nDestroyWindow(hwnd); freeLargeIcon(); freeSmallIcon(); resetCursorClipping(); } - private static native void nDestroyWindow(long hwnd, long hdc); + private static native void nReleaseDC(long hwnd, long hdc); + private static native void nDestroyWindow(long hwnd); static void resetCursorClipping() { if (cursor_clipped) { try { Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-05-05 16:46:16 UTC (rev 3065) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2008-05-05 17:24:42 UTC (rev 3066) @@ -151,13 +151,6 @@ return org_lwjgl_WindowsSysImplementation_JNI_VERSION; } -static void destroyWindow(JNIEnv *env, HWND *hwnd, HDC *hdc) { - jclass display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(*hwnd, GWLP_USERDATA); - closeWindow(hwnd, hdc); - if (display_class_global != NULL) - (*env)->DeleteGlobalRef(env, display_class_global); -} - JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEnv *env, jobject self, jboolean fullscreen, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child_window, jlong parent_hwnd) { HWND hwnd; static bool oneShotInitialised = false; @@ -173,12 +166,22 @@ return (INT_PTR)hwnd; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) { HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; HDC hdc = (HDC)(INT_PTR)hdc_ptr; - destroyWindow(env, &hwnd, &hdc); + ReleaseDC(hwnd, hdc); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong hwnd_ptr) { + jclass display_class_global; + HWND hwnd = (HWND)(INT_PTR)hwnd_ptr; + display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA); + ShowWindow(hwnd, SW_HIDE); + DestroyWindow(hwnd); + if (display_class_global != NULL) + (*env)->DeleteGlobalRef(env, display_class_global); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_clientToScreen(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) { HWND hwnd = (HWND)(INT_PTR)hwnd_int; POINT point; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |