From: <eli...@us...> - 2006-06-07 06:36:23
|
Revision: 2356 Author: elias_naur Date: 2006-06-06 23:35:52 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2356&view=rev Log Message: ----------- Mac OS X: Fixed flickering caused by the new context handling in AWTGLCanvas Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -145,6 +145,18 @@ } /** + * Release the context from its drawable. This is necessary on some platforms, + * like Mac OS X, where binding the context to a drawable and binding the context + * for rendering are two distinct actions and where calling releaseDrawable + * on every releaseCurrentContext results in artifacts. + */ + public synchronized void releaseDrawable() throws LWJGLException { + if (destroyed) + throw new IllegalStateException("Context is destroyed"); + implementation.releaseDrawable(getHandle()); + } + + /** * Update the context. Should be called whenever it's drawable is moved or resized */ public synchronized void update() { @@ -198,6 +210,7 @@ private void checkDestroy() { if (!destroyed && destroy_requested) { try { + releaseDrawable(); implementation.destroy(peer_info, handle); destroyed = true; thread = null; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -56,6 +56,11 @@ public void swapBuffers() throws LWJGLException; /** + * Release the context from its drawable, if any. + */ + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException; + + /** * Release the current context (if any). After this call, no context is current. */ public void releaseCurrentContext() throws LWJGLException; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -283,10 +283,11 @@ } try { if (context.isCurrent()) { + context.releaseDrawable(); Context.releaseCurrentContext(); } } catch (LWJGLException e) { - LWJGLUtil.log("Exception occurred while trying to release context"); + LWJGLUtil.log("Exception occurred while trying to release context: " + e); } // Automatically destroy keyboard & mouse Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -57,6 +57,9 @@ } private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -68,16 +68,13 @@ private static native void nUpdate(ByteBuffer context_handle); public void releaseCurrentContext() throws LWJGLException { - Context current_context = Context.getCurrentContext(); - if (current_context != null) { - synchronized (current_context) { - clearDrawable(current_context.getHandle()); - } - } nReleaseCurrentContext(); } private static native void nReleaseCurrentContext() throws LWJGLException; + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + clearDrawable(context_handle); + } private static native void clearDrawable(ByteBuffer handle) throws LWJGLException; static void resetView(PeerInfo peer_info, Context context) throws LWJGLException { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -68,6 +68,9 @@ } private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } + public void update(ByteBuffer context_handle) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2006-07-02 20:26:57
|
Revision: 2403 Author: matzon Date: 2006-07-02 13:26:49 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2403&view=rev Log Message: ----------- made Display priveledged action private. Fixes a possible security exploit that would allow anyone to get a boolean from System properties *gasp* Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-01 05:33:14 UTC (rev 2402) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-02 20:26:49 UTC (rev 2403) @@ -711,7 +711,7 @@ /** * Gets a boolean property as a privileged action. */ - static boolean getPrivilegedBoolean(final String property_name) { + private static boolean getPrivilegedBoolean(final String property_name) { Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return new Boolean(Boolean.getBoolean(property_name)); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2006-07-01 05:33:14 UTC (rev 2402) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2006-07-02 20:26:49 UTC (rev 2403) @@ -48,6 +48,7 @@ import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.security.AccessController; +import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; @@ -72,7 +73,7 @@ addComponentListener(this); canvas = new MacOSXGLCanvas(); add(canvas, BorderLayout.CENTER); - boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + boolean undecorated = getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); setUndecorated(fullscreen || undecorated); if ( fullscreen ) { try { @@ -212,4 +213,16 @@ } return result; } + + /** + * Gets a boolean property as a privileged action. + */ + private static boolean getPrivilegedBoolean(final String property_name) { + Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return new Boolean(Boolean.getBoolean(property_name)); + } + }); + return value.booleanValue(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-02 22:42:33
|
Revision: 2416 Author: elias_naur Date: 2006-07-02 15:41:59 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2416&view=rev Log Message: ----------- Spelling fixes Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java Modified: trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-02 22:01:27 UTC (rev 2415) +++ trunk/LWJGL/src/java/org/lwjgl/applet/LWJGLInstaller.java 2006-07-02 22:41:59 UTC (rev 2416) @@ -123,7 +123,7 @@ } // create a temporary dir for the native files - String user_temp_dir = getPriveledgedString("java.io.tmpdir"); + String user_temp_dir = getPriviledgedString("java.io.tmpdir"); String path = createTemporaryDir(user_temp_dir); if(path == null) { throw new LWJGLException("Failed creation of temporary directory in " + user_temp_dir); @@ -251,7 +251,7 @@ /** * Gets a property as a privileged action. */ - private static String getPriveledgedString(final String property) { + private static String getPriviledgedString(final String property) { return (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty(property); @@ -315,4 +315,4 @@ } file.delete(); } -} \ No newline at end of file +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2006-07-02 22:01:27 UTC (rev 2415) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2006-07-02 22:41:59 UTC (rev 2416) @@ -75,7 +75,7 @@ private boolean privilegedLockAndInitHandle(final Canvas canvas) throws LWJGLException { // Workaround for Sun JDK bug 4796548 which still exists in java for OS X - // We need to elevate priveleges because of an AWT bug. Please see + // We need to elevate privileges because of an AWT bug. Please see // http://192.18.37.44/forums/index.php?topic=10572 for a discussion. // It is only needed on first call, so we avoid it on all subsequent calls // due to performance. @@ -103,4 +103,4 @@ } private static native void nUnlock(ByteBuffer lock_buffer) throws LWJGLException; -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-02 22:46:05
|
Revision: 2417 Author: elias_naur Date: 2006-07-02 15:45:56 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2417&view=rev Log Message: ----------- Reverted Display.getPrivilegedBoolean access modifier change - package private is alright Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-02 22:41:59 UTC (rev 2416) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-02 22:45:56 UTC (rev 2417) @@ -711,7 +711,7 @@ /** * Gets a boolean property as a privileged action. */ - private static boolean getPrivilegedBoolean(final String property_name) { + static boolean getPrivilegedBoolean(final String property_name) { Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return new Boolean(Boolean.getBoolean(property_name)); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2006-07-02 22:41:59 UTC (rev 2416) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2006-07-02 22:45:56 UTC (rev 2417) @@ -48,7 +48,6 @@ import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; @@ -73,7 +72,7 @@ addComponentListener(this); canvas = new MacOSXGLCanvas(); add(canvas, BorderLayout.CENTER); - boolean undecorated = getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); + boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated"); setUndecorated(fullscreen || undecorated); if ( fullscreen ) { try { @@ -213,16 +212,4 @@ } return result; } - - /** - * Gets a boolean property as a privileged action. - */ - private static boolean getPrivilegedBoolean(final String property_name) { - Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return new Boolean(Boolean.getBoolean(property_name)); - } - }); - return value.booleanValue(); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-03 18:56:26
|
Revision: 2428 Author: elias_naur Date: 2006-07-03 11:56:15 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2428&view=rev Log Message: ----------- Fixed comment Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 18:33:25 UTC (rev 2427) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/EventQueue.java 2006-07-03 18:56:15 UTC (rev 2428) @@ -33,7 +33,6 @@ /** * A java implementation of a LWJGL compatible event queue. - * Currently only used by the Mac OS X implementation. * @author elias_naur */ Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:33:25 UTC (rev 2427) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-03 18:56:15 UTC (rev 2428) @@ -54,7 +54,6 @@ private final static int AutoRepeatModeOn = 1; private final static int AutoRepeatModeDefault = 2; - /** Window mode enum */ private static final int FULLSCREEN_LEGACY = 1; private static final int FULLSCREEN_NETWM = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-03 21:53:26
|
Revision: 2432 Author: elias_naur Date: 2006-07-03 14:53:10 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2432&view=rev Log Message: ----------- Removed svn:executable properties on windows java files Property Changed: ---------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput3.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput8.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice3.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice8.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDeviceObjectCallback.java ___________________________________________________________________ Name: svn:executable - * Property changes on: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java ___________________________________________________________________ Name: svn:executable - * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-04 17:46:45
|
Revision: 2446 Author: elias_naur Date: 2006-07-04 10:46:33 -0700 (Tue, 04 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2446&view=rev Log Message: ----------- Windows: Use data size constant for input devices instead of hard coded size Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-04 17:07:13 UTC (rev 2445) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-07-04 17:46:33 UTC (rev 2446) @@ -70,7 +70,7 @@ throw e; } keyboard.acquire(); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*2); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); keyboard_state = BufferUtils.createByteBuffer(256); unicode_buffer = BufferUtils.createCharBuffer(BUFFER_SIZE); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-04 17:07:13 UTC (rev 2445) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-07-04 17:46:33 UTC (rev 2446) @@ -100,7 +100,7 @@ this.mouse_button_count = Math.min(enumerator.getButtonCount(), 4); this.has_wheel = enumerator.hasWheel(); mouse_state = BufferUtils.createByteBuffer(3*4 + 4); - temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*2); + temp_data_buffer = BufferUtils.createIntBuffer(BUFFER_SIZE*WindowsDirectInputDevice.DATA_SIZE); } public boolean hasWheel() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-21 20:36:00
|
Revision: 2532 Author: elias_naur Date: 2006-07-21 13:35:27 -0700 (Fri, 21 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2532&view=rev Log Message: ----------- Windows: Ingore DI_POLLEDDEVICE when setting buffer size of a directinput device Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java 2006-07-17 23:27:29 UTC (rev 2531) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInput.java 2006-07-21 20:35:27 UTC (rev 2532) @@ -46,6 +46,7 @@ public final static int DI_OK = 0x00000000; public final static int DI_NOEFFECT = 0x00000001; public final static int DI_PROPNOEFFECT = 0x00000001; + public final static int DI_POLLEDDEVICE = 0x00000002; public final static int DI_DOWNLOADSKIPPED = 0x00000003; public final static int DI_EFFECTRESTARTED = 0x00000004; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-07-17 23:27:29 UTC (rev 2531) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-07-21 20:35:27 UTC (rev 2532) @@ -94,7 +94,7 @@ public void setBufferSize(int buffer_size) throws LWJGLException { int ret = setBufferSize(di_device, buffer_size); - if (ret != WindowsDirectInput.DI_OK) + if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_PROPNOEFFECT && ret != WindowsDirectInput.DI_POLLEDDEVICE) throw new LWJGLException("Failed to set buffer size (" + ret + ")"); int event_buffer_size = getEventSize()*buffer_size; event_buffer = BufferUtils.createByteBuffer(event_buffer_size); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-22 21:31:04
|
Revision: 2535 Author: elias_naur Date: 2006-07-22 14:30:31 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2535&view=rev Log Message: ----------- Linux: Remove 32x32 icons size check, since other sizes seem to work alright. Document the fact that Display.setIcon use the icons from the icon array in order of decreasing preference Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-22 15:05:36 UTC (rev 2534) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-07-22 21:30:31 UTC (rev 2535) @@ -273,7 +273,7 @@ if(cached_icons != null) { setIcon(cached_icons); } else { - setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon16x16, LWJGLUtil.LWJGLIcon32x32 }); + setIcon(new ByteBuffer[] { LWJGLUtil.LWJGLIcon32x32, LWJGLUtil.LWJGLIcon16x16 }); } } @@ -879,7 +879,7 @@ * of recreating the icons when you go back and forth fullscreen mode. You therefore only need to * set the icon once per instance. * - * @param icons Array of icons in RGBA mode + * @param icons Array of icons in RGBA mode. Pass the icons in order of preference. * @return number of icons used, or 0 if display hasn't been created */ public static int setIcon(ByteBuffer[] icons) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-22 15:05:36 UTC (rev 2534) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-07-22 21:30:31 UTC (rev 2535) @@ -949,11 +949,9 @@ for (int i=0;i<icons.length;i++) { int size = icons[i].limit() / 4; int dimension = (int)Math.sqrt(size); - if (dimension == 32) { - ByteBuffer icon = convertIcon(icons[i], dimension, dimension); - nSetWindowIcon(icon, icon.capacity(), dimension, dimension); - return 1; - } + ByteBuffer icon = convertIcon(icons[i], dimension, dimension); + nSetWindowIcon(icon, icon.capacity(), dimension, dimension); + return 1; } return 0; } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-31 22:38:06
|
Revision: 2538 Author: elias_naur Date: 2006-07-31 15:37:31 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2538&view=rev Log Message: ----------- ReferencesStack now clears references when popping to avoid keeping buffer references around too long Modified Paths: -------------- trunk/LWJGL/src/generated/org/lwjgl/opengl/References.java trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java Modified: trunk/LWJGL/src/generated/org/lwjgl/opengl/References.java =================================================================== --- trunk/LWJGL/src/generated/org/lwjgl/opengl/References.java 2006-07-31 01:22:33 UTC (rev 2537) +++ trunk/LWJGL/src/generated/org/lwjgl/opengl/References.java 2006-07-31 22:37:31 UTC (rev 2538) @@ -42,4 +42,24 @@ this.GL20_glVertexAttribPointer_buffer = references.GL20_glVertexAttribPointer_buffer; this.NV_vertex_program_glVertexAttribPointerNV_buffer = references.NV_vertex_program_glVertexAttribPointerNV_buffer; } + void clear() { + this.ARB_matrix_palette_glMatrixIndexPointerARB_pPointer = null; + this.ARB_vertex_blend_glWeightPointerARB_pPointer = null; + this.ARB_vertex_program_glVertexAttribPointerARB_buffer = null; + this.ARB_vertex_shader_glVertexAttribPointerARB_buffer = null; + this.ATI_element_array_glElementPointerATI_pPointer = null; + this.EXT_fog_coord_glFogCoordPointerEXT_data = null; + this.EXT_secondary_color_glSecondaryColorPointerEXT_pPointer = null; + this.EXT_vertex_shader_glVariantPointerEXT_pAddr = null; + this.EXT_vertex_weighting_glVertexWeightPointerEXT_pPointer = null; + this.GL11_glColorPointer_pointer = null; + this.GL11_glEdgeFlagPointer_pointer = null; + this.GL11_glNormalPointer_pointer = null; + this.GL11_glSelectBuffer_buffer = null; + this.GL11_glVertexPointer_pointer = null; + this.GL11_glTexCoordPointer_pointer = null; + this.GL14_glFogCoordPointer_data = null; + this.GL20_glVertexAttribPointer_buffer = null; + this.NV_vertex_program_glVertexAttribPointerNV_buffer = null; + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2006-07-31 01:22:33 UTC (rev 2537) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2006-07-31 22:37:31 UTC (rev 2538) @@ -46,6 +46,7 @@ public References popState() { References result = references_stack[stack_pos]; + references_stack[stack_pos].clear(); stack_pos--; return result; } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2006-07-31 01:22:33 UTC (rev 2537) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/ReferencesGeneratorProcessorFactory.java 2006-07-31 22:37:31 UTC (rev 2538) @@ -105,6 +105,17 @@ } } + private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { + for (ParameterDeclaration param : method.getParameters()) { + CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); + if (cached_reference_annotation != null) { + Class nio_type = Utils.getNIOBufferType(param.getType()); + String reference_name = Utils.getReferenceName(interface_decl, method, param); + writer.println("\t\tthis." + reference_name + " = null;"); + } + } + } + private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class); @@ -117,6 +128,12 @@ } } + private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { + for (MethodDeclaration method : interface_decl.getMethods()) { + generateClearsFromParameters(writer, interface_decl, method); + } + } + private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) { for (MethodDeclaration method : interface_decl.getMethods()) { generateCopiesFromParameters(writer, interface_decl, method); @@ -163,6 +180,12 @@ generateCopiesFromMethods(writer, interface_decl); } writer.println("\t}"); + writer.println("\tvoid clear() {"); + for (TypeDeclaration typedecl : interface_decls) { + InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl; + generateClearsFromMethods(writer, interface_decl); + } + writer.println("\t}"); writer.println("}"); writer.close(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-07-31 22:54:29
|
Revision: 2539 Author: elias_naur Date: 2006-07-31 15:54:21 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2539&view=rev Log Message: ----------- Don't trust GL_MAX_CLIENT_ATTRIB_STACK_DEPTH since it is 0 on Xgl in linux. Instead make sure the state trackers are sized according to demand Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2006-07-31 22:37:31 UTC (rev 2538) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2006-07-31 22:54:21 UTC (rev 2539) @@ -32,7 +32,7 @@ package org.lwjgl.opengl; class ReferencesStack { - private final References[] references_stack; + private References[] references_stack; private int stack_pos; public References getReferences() { @@ -41,6 +41,12 @@ public void pushState() { stack_pos++; + if (stack_pos == references_stack.length) { + References[] new_references_stack = new References[references_stack.length + 1]; + System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); + references_stack = new_references_stack; + references_stack[references_stack.length - 1] = new References(); + } references_stack[stack_pos].copy(references_stack[stack_pos - 1]); } @@ -51,8 +57,8 @@ return result; } - ReferencesStack(int stack_size) { - references_stack = new References[stack_size]; + ReferencesStack() { + references_stack = new References[1]; stack_pos = 0; for (int i = 0; i < references_stack.length; i++) references_stack[i] = new References(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2006-07-31 22:37:31 UTC (rev 2538) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2006-07-31 22:54:21 UTC (rev 2539) @@ -32,9 +32,7 @@ package org.lwjgl.opengl; class StateStack { - - /** Only int state is tracked */ - private final int[] state_stack; + private int[] state_stack; private int stack_pos; public int getState() { @@ -47,6 +45,11 @@ public void pushState() { stack_pos++; + if (stack_pos == state_stack.length) { + int[] new_state_stack = new int[state_stack.length + 1]; + System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); + state_stack = new_state_stack; + } state_stack[stack_pos] = state_stack[stack_pos - 1]; } @@ -56,8 +59,8 @@ return result; } - StateStack(int stack_size, int initial_value) { - state_stack = new int[stack_size]; + StateStack(int initial_value) { + state_stack = new int[1]; stack_pos = 0; state_stack[stack_pos] = initial_value; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2006-07-31 22:37:31 UTC (rev 2538) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2006-07-31 22:54:21 UTC (rev 2539) @@ -31,19 +31,14 @@ */ package org.lwjgl.opengl; - -/** Track Vertex Buffer Objects by context. */ final class StateTracker { private final ReferencesStack references_stack; private final StateStack attrib_stack; StateTracker() { - int stack_size = Math.max(1, Util.glGetInteger(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH)); - - references_stack = new ReferencesStack(stack_size); - - attrib_stack = new StateStack(stack_size, 0); + references_stack = new ReferencesStack(); + attrib_stack = new StateStack(0); } static void popAttrib() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-23 10:24:13
|
Revision: 2590 http://svn.sourceforge.net/java-game-lib/?rev=2590&view=rev Author: elias_naur Date: 2006-10-23 03:24:03 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Linux: Simplified LinuxMouse Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-20 12:55:01 UTC (rev 2589) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 10:24:03 UTC (rev 2590) @@ -718,12 +718,16 @@ if (new_grab != grab) { grab = new_grab; updateInputGrab(); - mouse.changeGrabbed(grab, pointer_grabbed, shouldGrab()); + mouse.changeGrabbed(grab, shouldWarpPointer()); } } finally { unlockAWT(); } } + + private boolean shouldWarpPointer() { + return pointer_grabbed && shouldGrab(); + } public int getNativeCursorCapabilities() { lockAWT(); @@ -980,7 +984,7 @@ private void handlePointerMotionEvent(long millis, long root_window, int x_root, int y_root, int x, int y, int state) { if (mouse != null) - mouse.handlePointerMotion(grab, pointer_grabbed, shouldGrab(), millis, root_window, x_root, y_root, x, y); + mouse.handlePointerMotion(grab, shouldWarpPointer(), millis, root_window, x_root, y_root, x, y); } private void handleWarpEvent(int x, int y) { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-20 12:55:01 UTC (rev 2589) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-23 10:24:03 UTC (rev 2590) @@ -135,9 +135,9 @@ } private static native void nSendWarpEvent(long display, long window, int center_x, int center_y); - private void doHandlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) { + private void doHandlePointerMotion(boolean grab, boolean warp_pointer, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) { setCursorPos(grab, win_x, win_y, nanos); - if (!pointer_grabbed || !should_grab) + if (!warp_pointer) return; int root_window_height = nGetWindowHeight(display, root_window); int root_window_width = nGetWindowWidth(display, root_window); @@ -165,10 +165,10 @@ } } - public void changeGrabbed(boolean grab, boolean pointer_grabbed, boolean should_grab) { + public void changeGrabbed(boolean grab, boolean warp_pointer) { reset(); long root_window = nQueryPointer(display, window, query_pointer_buffer); - doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3), last_event_nanos); + doHandlePointerMotion(grab, warp_pointer, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3), last_event_nanos); } public int getButtonCount() { @@ -188,8 +188,8 @@ } private static native void nWarpCursor(long display, long window, int x, int y); - public void handlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long millis, long root_window, int x_root, int y_root, int x, int y) { - doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, x_root, y_root, x, y, millis*1000000); + public void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) { + doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000); } private void handleButton(boolean grab, int button, byte state, long nanos) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-24 10:39:24
|
Revision: 2601 http://svn.sourceforge.net/java-game-lib/?rev=2601&view=rev Author: elias_naur Date: 2006-10-24 03:39:14 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Linux: Moved input event processing to LinuxKeyboard and LinuxMouse Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:59:00 UTC (rev 2600) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:39:14 UTC (rev 2601) @@ -638,16 +638,13 @@ while (LinuxEvent.getPending(getDisplay()) > 0) { event_buffer.nextEvent(getDisplay()); long event_window = event_buffer.getWindow(); - if (event_window != getWindow()) + if (event_window != getWindow() || event_buffer.filterEvent(event_window) || + (mouse != null && mouse.filterEvent(grab, shouldWarpPointer(), event_buffer)) || + (keyboard != null && keyboard.filterEvent(event_buffer))) continue; - if (event_buffer.filterEvent(event_window)) - continue; switch (event_buffer.getType()) { case LinuxEvent.ClientMessage: - if (event_buffer.getClientMessageType() == warp_atom) { - if (mouse != null) - mouse.handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1)); - } else if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom)) + if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom)) close_requested = true; break; case LinuxEvent.MapNotify: @@ -661,20 +658,6 @@ case LinuxEvent.Expose: dirty = true; break; - case LinuxEvent.ButtonPress: /* Fall through */ - case LinuxEvent.ButtonRelease: - if (mouse != null) - mouse.handleButtonEvent(grab, event_buffer.getButtonTime(), event_buffer.getButtonType(), (byte)event_buffer.getButtonButton()); - break; - case LinuxEvent.MotionNotify: - if (mouse != null) - mouse.handlePointerMotion(grab, shouldWarpPointer(), event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY()); - break; - case LinuxEvent.KeyPress: /* Fall through */ - case LinuxEvent.KeyRelease: - if (keyboard != null) - keyboard.handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState()); - break; default: break; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-10-24 09:59:00 UTC (rev 2600) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-10-24 10:39:14 UTC (rev 2601) @@ -296,10 +296,22 @@ } } - public void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) { + private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) { int keycode = getKeycode(event_ptr, event_state); byte key_state = getKeyState(event_type); key_down_buffer[keycode] = key_state; translateEvent(event_ptr, event_type, keycode, key_state, millis*1000000); } + + public boolean filterEvent(LinuxEvent event) { + switch (event.getType()) { + case LinuxEvent.KeyPress: /* Fall through */ + case LinuxEvent.KeyRelease: + handleKeyEvent(event.getKeyAddress(), event.getKeyTime(), event.getKeyType(), event.getKeyKeyCode(), event.getKeyState()); + return true; + default: + break; + } + return false; + } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 09:59:00 UTC (rev 2600) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:39:14 UTC (rev 2601) @@ -190,7 +190,7 @@ } private static native void nWarpCursor(long display, long window, int x, int y); - public void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) { + private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) { doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000); } @@ -239,7 +239,7 @@ } } - public void handleButtonEvent(boolean grab, long millis, int type, byte button) { + private void handleButtonEvent(boolean grab, long millis, int type, byte button) { long nanos = millis*1000000; switch (type) { case ButtonRelease: @@ -258,7 +258,28 @@ last_y = transformY(y); } - public void handleWarpEvent(int x, int y) { + private void handleWarpEvent(int x, int y) { resetCursor(x, y); } + + public boolean filterEvent(boolean grab, boolean warp_pointer, LinuxEvent event) { + switch (event.getType()) { + case LinuxEvent.ClientMessage: + if (event.getClientMessageType() == warp_atom) { + handleWarpEvent(event.getClientData(0), event.getClientData(1)); + return true; + } + break; + case LinuxEvent.ButtonPress: /* Fall through */ + case LinuxEvent.ButtonRelease: + handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton()); + return true; + case LinuxEvent.MotionNotify: + handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY()); + return true; + default: + break; + } + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-24 10:43:58
|
Revision: 2602 http://svn.sourceforge.net/java-game-lib/?rev=2602&view=rev Author: elias_naur Date: 2006-10-24 03:43:52 -0700 (Tue, 24 Oct 2006) Log Message: ----------- Linux: Moved warp Atom from LinuxDisplay to LinuxMouse Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:39:14 UTC (rev 2601) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:43:52 UTC (rev 2602) @@ -89,7 +89,6 @@ private int current_displaymode_extension = NONE; /** Atom used for the pointer warp messages */ - private long warp_atom; private long delete_atom; private PeerInfo peer_info; @@ -461,10 +460,6 @@ } private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException; - static long getWarpAtom() throws LWJGLException { - return internAtom("_LWJGL", false); - } - private static long internAtom(String atom_name, boolean only_if_exists) throws LWJGLException { incDisplay(); try { @@ -473,7 +468,7 @@ decDisplay(); } } - private static native long nInternAtom(long display, String atom_name, boolean only_if_exists); + static native long nInternAtom(long display, String atom_name, boolean only_if_exists); public void resetDisplayMode() { lockAWT(); @@ -555,7 +550,6 @@ public DisplayMode init() throws LWJGLException { lockAWT(); try { - warp_atom = getWarpAtom(); delete_atom = internAtom("WM_DELETE_WINDOW", false); current_displaymode_extension = getBestDisplayModeExtension(); if (current_displaymode_extension == NONE) @@ -709,10 +703,10 @@ return mouse.getButtonCount(); } - public void createMouse() { + public void createMouse() throws LWJGLException { lockAWT(); try { - mouse = new LinuxMouse(getDisplay(), getWindow(), warp_atom); + mouse = new LinuxMouse(getDisplay(), getWindow()); } finally { unlockAWT(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:39:14 UTC (rev 2601) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:43:52 UTC (rev 2602) @@ -40,6 +40,7 @@ import java.nio.CharBuffer; import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; import org.lwjgl.input.Mouse; import java.nio.charset.CharsetDecoder; @@ -76,10 +77,10 @@ private EventQueue event_queue; private long last_event_nanos; - public LinuxMouse(long display, long window, long warp_atom) { + public LinuxMouse(long display, long window) throws LWJGLException { this.display = display; this.window = window; - this.warp_atom = warp_atom; + this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false); reset(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-26 14:47:12
|
Revision: 2606 http://svn.sourceforge.net/java-game-lib/?rev=2606&view=rev Author: elias_naur Date: 2006-10-26 07:47:02 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Mac OS X: Moved AWT input handling to separate AWTUtil.java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-26 14:47:02 UTC (rev 2606) @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * @author elias_naur + */ + +import java.awt.Cursor; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.BufferUtils; +import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; +import org.lwjgl.input.Keyboard; + +final class AWTUtil { + public static boolean hasWheel() { + return true; + } + + public static int getButtonCount() { + return MouseEventQueue.NUM_BUTTONS; + } + + public static int getNativeCursorCapabilities() { + if (LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX || LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) { + int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors(); + boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0; + int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0; + return caps; + } else { + /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with + minimal test case): + 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a + Componennt, it is reset to the default pointer cursor when the window is de- + activated and the re-activated. The Cursor can not be reset to the custom cursor, + with another setCursor. + 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen + mode, no mouse moved events are reported, even though mouse pressed/released and dragged + events are reported + */ + return 0; + } + } + + public static void setCursorPosition(final Component component, int x, int y) { + try { + Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return new Robot(component.getGraphicsConfiguration().getDevice()); + } + }); + int transformed_x = component.getX() + x; + int transformed_y = component.getY() + component.getHeight() - 1 - y; + robot.mouseMove(transformed_x, transformed_y); + } catch (PrivilegedActionException e) { + LWJGLUtil.log("Got exception while setting mouse cursor position: " + e); + } + } + + public static int getMinCursorSize() { + Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0); + return Math.max(min_size.width, min_size.height); + } + + public static int getMaxCursorSize() { + Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000); + return Math.min(max_size.width, max_size.height); + } + + /** Native cursor handles */ + public static Cursor createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + int[] pixels = new int[images.remaining()]; + int old_position = images.position(); + images.get(pixels); + images.position(old_position); + cursor_image.setRGB(0, 0, width, height, pixels, 0, width); + return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor"); + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 12:15:46 UTC (rev 2605) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 14:47:02 UTC (rev 2606) @@ -294,11 +294,11 @@ /* Mouse */ public boolean hasWheel() { - return true; + return AWTUtil.hasWheel(); } public int getButtonCount() { - return MouseEventQueue.NUM_BUTTONS; + return AWTUtil.getButtonCount(); } public void createMouse() throws LWJGLException { @@ -336,39 +336,11 @@ private native void nGrabMouse(boolean grab); public int getNativeCursorCapabilities() { - if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) { - int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors(); - boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0; - int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0; - return caps; - } else { - /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with - minimal test case): - 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a - Componennt, it is reset to the default pointer cursor when the window is de- - activated and the re-activated. The Cursor can not be reset to the custom cursor, - with another setCursor. - 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen - mode, no mouse moved events are reported, even though mouse pressed/released and dragged - events are reported - */ - return 0; - } + return AWTUtil.getNativeCursorCapabilities(); } public void setCursorPosition(int x, int y) { - try { - Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - return new Robot(frame.getGraphicsConfiguration().getDevice()); - } - }); - int transformed_x = frame.getX() + x; - int transformed_y = frame.getY() + frame.getHeight() - 1 - y; - robot.mouseMove(transformed_x, transformed_y); - } catch (PrivilegedActionException e) { - LWJGLUtil.log("Got exception while setting mouse cursor position: " + e); - } + AWTUtil.setCursorPosition(frame, x, y); } public void setNativeCursor(Object handle) throws LWJGLException { @@ -377,13 +349,11 @@ } public int getMinCursorSize() { - Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0); - return Math.max(min_size.width, min_size.height); + return AWTUtil.getMinCursorSize(); } public int getMaxCursorSize() { - Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000); - return Math.min(max_size.width, max_size.height); + return AWTUtil.getMaxCursorSize(); } /* Keyboard */ @@ -437,13 +407,7 @@ */ /** Native cursor handles */ public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { - BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - int[] pixels = new int[images.remaining()]; - int old_position = images.position(); - images.get(pixels); - images.position(old_position); - cursor_image.setRGB(0, 0, width, height, pixels, 0, width); - return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor"); + return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays); } public void destroyCursor(Object cursor_handle) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-26 15:03:55
|
Revision: 2607 http://svn.sourceforge.net/java-game-lib/?rev=2607&view=rev Author: elias_naur Date: 2006-10-26 08:03:47 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Mac OS X: Moved registering and unregistering of AWT listeners from MacOSXDisplay to the input handlers Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 14:47:02 UTC (rev 2606) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 15:03:47 UTC (rev 2607) @@ -39,6 +39,7 @@ import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.Component; import java.nio.ByteBuffer; import org.lwjgl.input.Keyboard; @@ -51,6 +52,8 @@ /** Event scratch array */ private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE); + private final Component component; + static { KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0; KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1; @@ -238,10 +241,23 @@ KEY_MAP[KeyEvent.VK_Z] = Keyboard.KEY_Z; } - public KeyboardEventQueue() { + public KeyboardEventQueue(Component component) { super(Keyboard.EVENT_SIZE); + this.component = component; } + public void register() { + component.addKeyListener(this); + } + + public void unregister() { + /* + * This line is commented out to work around AWT bug 4867453: + * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453 + */ + //component.removeKeyListener(this); + } + private void putKeyboardEvent(int key_code, byte state, int character, long nanos) { event.clear(); event.putInt(key_code).put(state).putInt(character).putLong(nanos); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 14:47:02 UTC (rev 2606) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 15:03:47 UTC (rev 2607) @@ -303,17 +303,13 @@ public void createMouse() throws LWJGLException { MacOSXGLCanvas canvas = frame.getCanvas(); - this.mouse_queue = new MouseEventQueue(canvas.getWidth(), canvas.getHeight()); - canvas.addMouseListener(mouse_queue); - canvas.addMouseMotionListener(mouse_queue); - canvas.addMouseWheelListener(mouse_queue); + this.mouse_queue = new MouseEventQueue(canvas); + mouse_queue.register(); } public void destroyMouse() { - MacOSXGLCanvas canvas = frame.getCanvas(); - canvas.removeMouseListener(mouse_queue); - canvas.removeMouseWheelListener(mouse_queue); - canvas.removeMouseMotionListener(mouse_queue); + if (mouse_queue != null) + mouse_queue.unregister(); this.mouse_queue = null; } @@ -359,17 +355,13 @@ /* Keyboard */ public void createKeyboard() throws LWJGLException { MacOSXGLCanvas canvas = frame.getCanvas(); - this.keyboard_queue = new KeyboardEventQueue(); - canvas.addKeyListener(keyboard_queue); + this.keyboard_queue = new KeyboardEventQueue(canvas); + keyboard_queue.register(); } public void destroyKeyboard() { - /* - * This line is commented out to work around AWT bug 4867453: - * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453 - */ -// frame.getCanvas().removeKeyListener(keyboard_queue); - + if (keyboard_queue != null) + keyboard_queue.unregister(); this.keyboard_queue = null; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 14:47:02 UTC (rev 2606) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 15:03:47 UTC (rev 2607) @@ -32,8 +32,7 @@ package org.lwjgl.opengl; /** - * A java implementation of a LWJGL compatible Mouse event queue. - * Currently only used by the Mac OS X implementation. + * An AWT implementation of a LWJGL compatible Mouse event queue. * @author elias_naur */ @@ -42,6 +41,7 @@ import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import java.awt.Component; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -52,8 +52,7 @@ private static final int WHEEL_SCALE = 120; public static final int NUM_BUTTONS = 3; - private final int width; - private final int height; + private final Component component; private boolean grabbed; @@ -77,13 +76,24 @@ /** Buttons array */ private final byte[] buttons = new byte[NUM_BUTTONS]; - MouseEventQueue(int width, int height) { + MouseEventQueue(Component component) { super(Mouse.EVENT_SIZE); - this.width = width; - this.height = height; + this.component = component; resetCursorToCenter(); } + public void register() { + component.addMouseListener(this); + component.addMouseMotionListener(this); + component.addMouseWheelListener(this); + } + + public void unregister() { + component.removeMouseListener(this); + component.removeMouseMotionListener(this); + component.removeMouseWheelListener(this); + } + public synchronized void setGrabbed(boolean grabbed) { this.grabbed = grabbed; resetCursorToCenter(); @@ -94,7 +104,7 @@ } private int transformY(int y) { - return height - 1 - y; + return component.getHeight() - 1 - y; } private void resetCursorToCenter() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-26 21:39:48
|
Revision: 2613 http://svn.sourceforge.net/java-game-lib/?rev=2613&view=rev Author: elias_naur Date: 2006-10-26 14:39:37 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Mac OS X: Implemented AWTInputAdapter Modified Paths: -------------- 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/MacOSXCanvasImplementation.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:15:50 UTC (rev 2612) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613) @@ -37,7 +37,6 @@ import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLUtil; -import java.awt.event.FocusListener; import java.awt.Cursor; /** @@ -49,16 +48,18 @@ abstract class AbstractAWTInput implements AWTCanvasInputImplementation { private AWTGLCanvas canvas; - private volatile int current_height; - private volatile int current_width; private KeyboardEventQueue keyboard_queue; private MouseEventQueue mouse_queue; private volatile boolean grab; - protected AbstractAWTInput(AWTGLCanvas canvas) throws LWJGLException { + protected AbstractAWTInput(AWTGLCanvas canvas) { this.canvas = canvas; } + protected synchronized MouseEventQueue getMouseEventQueue() { + return mouse_queue; + } + public synchronized void grabMouse(boolean grab) { this.grab = grab; if (mouse_queue != null) @@ -83,18 +84,13 @@ } public final int getWidth() { - return current_width; + return canvas.getWidth(); } public final int getHeight() { - return current_height; + return canvas.getHeight(); } - public synchronized void processInput(PeerInfo peer_info) { - current_width = canvas.getWidth(); - current_height = canvas.getHeight(); - } - public boolean hasWheel() { return AWTUtil.hasWheel(); } @@ -104,10 +100,14 @@ } public void createMouse() throws LWJGLException { - mouse_queue = new MouseEventQueue(canvas); + mouse_queue = createMouseQueue(); mouse_queue.register(); } + protected MouseEventQueue createMouseQueue() { + return new MouseEventQueue(getCanvas()); + } + public void destroyMouse() { mouse_queue.unregister(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 21:15:50 UTC (rev 2612) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613) @@ -113,7 +113,6 @@ } public synchronized void processInput(PeerInfo peer_info) { - super.processInput(peer_info); LinuxDisplay.lockAWT(); try { LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info; Added: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613) @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +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 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 void destroy() { + } + + public void update() { + } +} Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 21:15:50 UTC (rev 2612) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 21:39:37 UTC (rev 2613) @@ -64,6 +64,6 @@ } public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException { - throw new UnsupportedOperationException(); + return new MacOSXAWTInput(canvas); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-27 06:05:03
|
Revision: 2614 http://svn.sourceforge.net/java-game-lib/?rev=2614&view=rev Author: elias_naur Date: 2006-10-26 23:04:55 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Made the AWT setCursorPosition garbage free Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-26 21:39:37 UTC (rev 2613) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-27 06:04:55 UTC (rev 2614) @@ -92,18 +92,25 @@ } } - public static void setCursorPosition(final Component component, int x, int y) { + public static Robot createRobot(final Component component) { try { Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return new Robot(component.getGraphicsConfiguration().getDevice()); } }); + return robot; + } catch (PrivilegedActionException e) { + LWJGLUtil.log("Got exception while creating robot: " + e.getCause()); + return null; + } + } + + public static void setCursorPosition(Component component, Robot robot, int x, int y) { + if (robot != null) { int transformed_x = component.getX() + x; int transformed_y = component.getY() + component.getHeight() - 1 - y; robot.mouseMove(transformed_x, transformed_y); - } catch (PrivilegedActionException e) { - LWJGLUtil.log("Got exception while setting mouse cursor position: " + e); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-27 06:04:55 UTC (rev 2614) @@ -38,6 +38,7 @@ import org.lwjgl.LWJGLUtil; import java.awt.Cursor; +import java.awt.Robot; /** * @@ -47,6 +48,7 @@ */ abstract class AbstractAWTInput implements AWTCanvasInputImplementation { private AWTGLCanvas canvas; + private Robot robot; private KeyboardEventQueue keyboard_queue; private MouseEventQueue mouse_queue; @@ -54,6 +56,7 @@ protected AbstractAWTInput(AWTGLCanvas canvas) { this.canvas = canvas; + this.robot = AWTUtil.createRobot(canvas); } protected synchronized MouseEventQueue getMouseEventQueue() { @@ -117,7 +120,7 @@ } public void setCursorPosition(int x, int y) { - AWTUtil.setCursorPosition(canvas, x, y); + AWTUtil.setCursorPosition(canvas, robot, x, y); } public void setNativeCursor(Object handle) throws LWJGLException { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 21:39:37 UTC (rev 2613) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-27 06:04:55 UTC (rev 2614) @@ -69,6 +69,7 @@ private static final int GAMMA_LENGTH = 256; private MacOSXFrame frame; + private Robot robot; private MacOSXMouseEventQueue mouse_queue; private KeyboardEventQueue keyboard_queue; private java.awt.DisplayMode requested_mode; @@ -85,6 +86,7 @@ close_requested = false; try { frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y); + robot = AWTUtil.createRobot(frame); } catch (LWJGLException e) { destroyWindow(); throw e; @@ -319,7 +321,7 @@ } public void setCursorPosition(int x, int y) { - AWTUtil.setCursorPosition(frame, x, y); + AWTUtil.setCursorPosition(frame, robot, x, y); } public void setNativeCursor(Object handle) throws LWJGLException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-10-28 22:06:37
|
Revision: 2617 http://svn.sourceforge.net/java-game-lib/?rev=2617&view=rev Author: elias_naur Date: 2006-10-28 15:06:24 -0700 (Sat, 28 Oct 2006) Log Message: ----------- Fixed AWTUtil.setCursorPosition. Added check to LinuxAWTInput. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-27 08:15:31 UTC (rev 2616) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-28 22:06:24 UTC (rev 2617) @@ -108,8 +108,9 @@ public static void setCursorPosition(Component component, Robot robot, int x, int y) { if (robot != null) { - int transformed_x = component.getX() + x; - int transformed_y = component.getY() + component.getHeight() - 1 - y; + Point location = component.getLocationOnScreen(); + int transformed_x = location.x + x; + int transformed_y = location.y + component.getHeight() - 1 - y; robot.mouseMove(transformed_x, transformed_y); } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-27 08:15:31 UTC (rev 2616) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-28 22:06:24 UTC (rev 2617) @@ -117,7 +117,7 @@ try { LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info; long new_window = linux_peer_info.getDrawable(); - if (new_window != cached_window) { + if (cached_mouse == null || new_window != cached_window) { ungrabInput(); cached_window = new_window; try { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-27 08:15:31 UTC (rev 2616) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-28 22:06:24 UTC (rev 2617) @@ -321,7 +321,7 @@ } public void setCursorPosition(int x, int y) { - AWTUtil.setCursorPosition(frame, robot, x, y); + AWTUtil.setCursorPosition(frame.getCanvas(), robot, x, y); } public void setNativeCursor(Object handle) throws LWJGLException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-11-19 21:16:02
|
Revision: 2664 http://svn.sourceforge.net/java-game-lib/?rev=2664&view=rev Author: elias_naur Date: 2006-11-19 13:15:51 -0800 (Sun, 19 Nov 2006) Log Message: ----------- AWTInputAdapter: unregister event listeners on destroy() Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-11-19 16:24:18 UTC (rev 2663) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-11-19 21:15:51 UTC (rev 2664) @@ -84,6 +84,10 @@ public synchronized void destroy() { canvas.setInput(null); canvas = null; + if (mouse_queue != null) + mouse_queue.unregister(); + if (keyboard_queue != null) + keyboard_queue.unregister(); } public final int getWidth() { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2006-11-19 16:24:18 UTC (rev 2663) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2006-11-19 21:15:51 UTC (rev 2664) @@ -60,7 +60,4 @@ ((MacOSXMouseEventQueue)getMouseEventQueue()).warpCursor(); had_focus = has_focus; } - - public void destroy() { - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2006-11-19 23:02:27
|
Revision: 2669 http://svn.sourceforge.net/java-game-lib/?rev=2669&view=rev Author: elias_naur Date: 2006-11-19 15:02:25 -0800 (Sun, 19 Nov 2006) Log Message: ----------- Windows: Make sure AWTInputAdapter is not reporting events twice after a grab change Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-11-19 22:06:46 UTC (rev 2668) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-11-19 23:02:25 UTC (rev 2669) @@ -59,10 +59,14 @@ this.robot = AWTUtil.createRobot(canvas); } - protected synchronized MouseEventQueue getMouseEventQueue() { + 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) Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2006-11-19 22:06:46 UTC (rev 2668) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2006-11-19 23:02:25 UTC (rev 2669) @@ -115,9 +115,15 @@ private void grab(boolean grab) { if (has_grabbed != grab) { cached_mouse.grab(grab); + cached_keyboard.grab(grab); has_grabbed = grab; - if (!grab) + cached_mouse.flush(); + cached_keyboard.flush(); + getMouseEventQueue().clearEvents(); + getKeyboardEventQueue().clearEvents(); + if (!grab) { getCanvas().setCursor(cached_cursor); + } } } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-11-19 22:06:46 UTC (rev 2668) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2006-11-19 23:02:25 UTC (rev 2669) @@ -47,6 +47,7 @@ final class WindowsKeyboard { private final static int BUFFER_SIZE = 50; + private final long hwnd; private final WindowsDirectInput dinput; private final WindowsDirectInputDevice keyboard; private final IntBuffer temp_data_buffer; @@ -55,14 +56,17 @@ private final CharBuffer unicode_buffer; private final ByteBuffer ascii_buffer; + private boolean grabbed; + public WindowsKeyboard(WindowsDirectInput dinput, long hwnd) throws LWJGLException { + this.hwnd = hwnd; this.dinput = dinput; try { keyboard = dinput.createDevice(WindowsDirectInput.KEYBOARD_TYPE); try { - keyboard.setCooperateLevel(hwnd, WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND); keyboard.setDataFormat(WindowsDirectInput.KEYBOARD_TYPE); keyboard.setBufferSize(BUFFER_SIZE); + acquireNonExclusive(); } catch (LWJGLException e) { keyboard.release(); throw e; @@ -84,15 +88,48 @@ ascii_buffer = BufferUtils.createByteBuffer(2); } } - private static native boolean isWindowsNT(); + private boolean acquire(int flags) { + try { + keyboard.setCooperateLevel(hwnd, flags); + keyboard.acquire(); + return true; + } catch (LWJGLException e) { + LWJGLUtil.log("Failed to acquire keyboard: " + e); + return false; + } + } + + private boolean acquireNonExclusive() { + return acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND) || + acquire(WindowsDirectInputDevice.DISCL_NONEXCLUSIVE | WindowsDirectInputDevice.DISCL_BACKGROUND); + } + public void destroy() { keyboard.unacquire(); keyboard.release(); dinput.release(); } + public void grab(boolean grab) { + if(grab) { + if (!grabbed) { + flush(); + grabbed = true; + keyboard.unacquire(); + if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) + LWJGLUtil.log("Failed to reset cooperative mode"); + } + } else { + if (grabbed) { + grabbed = false; + keyboard.unacquire(); + acquireNonExclusive(); + } + } + } + public void poll(ByteBuffer keyDownBuffer) { int ret = keyboard.acquire(); if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) @@ -181,7 +218,12 @@ private static native int ToAscii(int wVirtKey, int wScanCode, ByteBuffer lpKeyState, ByteBuffer lpChar, int flags); private static native int GetKeyboardState(ByteBuffer lpKeyState); - public void read(ByteBuffer buffer) { + public void flush() { + processEvents(); + temp_data_buffer.clear(); + } + + private void processEvents() { int ret = keyboard.acquire(); if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_NOEFFECT) return; @@ -202,6 +244,10 @@ LWJGLUtil.log("Failed to read keyboard (0x" + Integer.toHexString(ret) + ")"); break; } + } + + public void read(ByteBuffer buffer) { + processEvents(); temp_data_buffer.flip(); translateData(temp_data_buffer, buffer); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-11-19 22:06:46 UTC (rev 2668) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsMouse.java 2006-11-19 23:02:25 UTC (rev 2669) @@ -246,32 +246,42 @@ temp_data_buffer.clear(); ret = mouse.getDeviceData(temp_data_buffer); - if (ret == WindowsDirectInput.DI_OK) { - if (mouse_grabbed) { - temp_data_buffer.flip(); - copyDXEvents(temp_data_buffer); - } - } else if (ret == WindowsDirectInput.DI_BUFFEROVERFLOW) { - LWJGLUtil.log("Mouse buffer overflowed"); - } else if (ret == WindowsDirectInput.DIERR_INPUTLOST) { - LWJGLUtil.log("Mouse input lost"); - } else if (ret == WindowsDirectInput.DIERR_NOTACQUIRED) { - LWJGLUtil.log("Mouse not acquired"); - } else { - LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); + switch (ret) { + case WindowsDirectInput.DI_OK: + break; + case WindowsDirectInput.DI_BUFFEROVERFLOW: + LWJGLUtil.log("Mouse buffer overflowed"); + break; + case WindowsDirectInput.DIERR_INPUTLOST: + LWJGLUtil.log("Mouse input lost"); + break; + case WindowsDirectInput.DIERR_NOTACQUIRED: + LWJGLUtil.log("Mouse not acquired"); + break; + default: + LWJGLUtil.log("unknown mouse error (" + Integer.toHexString(ret) + ")"); + break; } } + public final void flush() { + readDXBuffer(); + temp_data_buffer.clear(); + } + public void read(ByteBuffer buffer) { readDXBuffer(); + if (mouse_grabbed) { + temp_data_buffer.flip(); + copyDXEvents(temp_data_buffer); + } event_queue.copyEvents(buffer); } public void grab(boolean grab) { if(grab) { if (!mouse_grabbed) { - // flush DX event buffer - readDXBuffer(); + flush(); mouse_grabbed = true; mouse.unacquire(); if (!acquire(WindowsDirectInputDevice.DISCL_EXCLUSIVE | WindowsDirectInputDevice.DISCL_FOREGROUND)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-01-30 13:08:55
|
Revision: 2734 http://svn.sourceforge.net/java-game-lib/?rev=2734&view=rev Author: elias_naur Date: 2007-01-30 05:08:51 -0800 (Tue, 30 Jan 2007) Log Message: ----------- Windows AWTInput: Make sure the cursor is contained within the window when the Mouse is grabbed. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-01-23 19:55:46 UTC (rev 2733) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2007-01-30 13:08:51 UTC (rev 2734) @@ -99,15 +99,24 @@ cached_mouse = new WindowsMouse(dinput, hwnd); // cached_keyboard = new WindowsKeyboard(dinput, hwnd); } - if (isGrabbed() && getCanvas().getCursor() != blank_cursor) { - cached_cursor = getCanvas().getCursor(); + if (isGrabbed()) { /** - * 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 + * 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. */ - getCanvas().setCursor(blank_cursor); - } + WindowsDisplay.setupCursorClipping(hwnd); + 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); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-01-23 19:55:46 UTC (rev 2733) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2007-01-30 13:08:51 UTC (rev 2734) @@ -145,8 +145,8 @@ resetCursorClipping(); } private static native void nDestroyWindow(); - private static native void resetCursorClipping(); - private static native void setupCursorClipping(long hwnd) throws LWJGLException; + static native void resetCursorClipping(); + static native void setupCursorClipping(long hwnd) throws LWJGLException; public void switchDisplayMode(DisplayMode mode) throws LWJGLException { nSwitchDisplayMode(mode); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-22 21:29:29
|
Revision: 2795 http://svn.sourceforge.net/java-game-lib/?rev=2795&view=rev Author: elias_naur Date: 2007-04-22 14:29:28 -0700 (Sun, 22 Apr 2007) Log Message: ----------- Inline optimizations to state trackers by MatthiasM Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -40,23 +40,26 @@ } public void pushState() { - stack_pos++; - if (stack_pos == references_stack.length) { - References[] new_references_stack = new References[references_stack.length + 1]; - System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); - references_stack = new_references_stack; - references_stack[references_stack.length - 1] = new References(); + int pos = ++stack_pos; + if (pos == references_stack.length) { + growStack(); } - references_stack[stack_pos].copy(references_stack[stack_pos - 1]); + references_stack[pos].copy(references_stack[pos - 1]); } public References popState() { - References result = references_stack[stack_pos]; - references_stack[stack_pos].clear(); - stack_pos--; + References result = references_stack[stack_pos--]; + result.clear(); return result; } + private void growStack() { + References[] new_references_stack = new References[references_stack.length + 1]; + System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length); + references_stack = new_references_stack; + references_stack[references_stack.length - 1] = new References(); + } + ReferencesStack() { references_stack = new References[1]; stack_pos = 0; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateStack.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -39,26 +39,24 @@ return state_stack[stack_pos]; } - public void setState(int new_state) { - state_stack[stack_pos] = new_state; - } - - public void pushState() { - stack_pos++; - if (stack_pos == state_stack.length) { - int[] new_state_stack = new int[state_stack.length + 1]; - System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); - state_stack = new_state_stack; + public void pushState(int new_state) { + int pos = ++stack_pos; + if (pos == state_stack.length) { + growState(); } - state_stack[stack_pos] = state_stack[stack_pos - 1]; + state_stack[pos] = new_state; } public int popState() { - int result = state_stack[stack_pos]; - stack_pos--; - return result; + return state_stack[stack_pos--]; } + public void growState() { + int[] new_state_stack = new int[state_stack.length + 1]; + System.arraycopy(state_stack, 0, new_state_stack, 0, state_stack.length); + state_stack = new_state_stack; + } + StateStack(int initial_value) { state_stack = new int[1]; stack_pos = 0; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-19 23:13:52 UTC (rev 2794) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java 2007-04-22 21:29:28 UTC (rev 2795) @@ -49,14 +49,13 @@ references_stack.popState(); } } - + static void pushAttrib(ContextCapabilities caps, int mask) { caps.tracker.doPushAttrib(mask); } private void doPushAttrib(int mask) { - attrib_stack.pushState(); - attrib_stack.setState(mask); + attrib_stack.pushState(mask); if ((mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) { references_stack.pushState(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-04-24 13:41:32
|
Revision: 2802 http://svn.sourceforge.net/java-game-lib/?rev=2802&view=rev Author: elias_naur Date: 2007-04-24 06:41:31 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Removed debug output Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-24 13:40:13 UTC (rev 2801) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2007-04-24 13:41:31 UTC (rev 2802) @@ -297,7 +297,7 @@ private static void switchDisplayMode() throws LWJGLException { if (!current_mode.isFullscreen()) { - System.out.println("Switching to "+initial_mode); + LWJGLUtil.log("Switching to "+initial_mode); setDisplayMode(initial_mode); } display_impl.switchDisplayMode(current_mode); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:40:13 UTC (rev 2801) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java 2007-04-24 13:41:31 UTC (rev 2802) @@ -153,7 +153,6 @@ private void putEvent(int virt_key, byte state, int ch, long nanos) { int keycode = WindowsKeycodes.mapVirtualKeyToLWJGLCode(virt_key); -System.out.println("virt_key = " + Integer.toHexString(virt_key) + " = " + virt_key + " | keycode = " + Keyboard.getKeyName(keycode)); if (keycode < key_down_buffer.length) key_down_buffer[keycode] = state; tmp_event.clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eli...@us...> - 2007-05-13 20:13:38
|
Revision: 2816 http://svn.sourceforge.net/java-game-lib/?rev=2816&view=rev Author: elias_naur Date: 2007-05-13 13:13:37 -0700 (Sun, 13 May 2007) Log Message: ----------- use timestamp matching hack to detect key repeat events instead of globally disabling keyboard repeating Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-05-01 18:13:29 UTC (rev 2815) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2007-05-13 20:13:37 UTC (rev 2816) @@ -404,7 +404,6 @@ minimized = false; dirty = true; updateInputGrab(); - nSetRepeatMode(getDisplay(), AutoRepeatModeOff); } finally { peer_info.unlock(); } @@ -435,7 +434,6 @@ blank_cursor = None; ungrabKeyboard(); nDestroyWindow(getDisplay(), getWindow()); - nSetRepeatMode(getDisplay(), AutoRepeatModeDefault); decDisplay(); } finally { unlockAWT(); @@ -764,7 +762,6 @@ if (isLegacyFullscreen() || input_released) return; input_released = true; - nSetRepeatMode(getDisplay(), AutoRepeatModeDefault); updateInputGrab(); if (current_window_mode == FULLSCREEN_NETWM) { nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen()); @@ -782,7 +779,6 @@ if (isLegacyFullscreen() || !input_released) return; input_released = false; - nSetRepeatMode(getDisplay(), AutoRepeatModeOff); updateInputGrab(); if (current_window_mode == FULLSCREEN_NETWM) { try { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2007-05-01 18:13:29 UTC (rev 2815) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2007-05-13 20:13:37 UTC (rev 2816) @@ -47,8 +47,6 @@ final class LinuxKeyboard { private static final int LockMapIndex = 1; - private static final int KeyPress = 2; - private static final int KeyRelease = 3; private static final long NoSymbol = 0; private static final long ShiftMask = 1 << 0; private static final long LockMask = 1 << 1; @@ -76,6 +74,13 @@ private final CharsetDecoder utf8_decoder = Charset.forName("UTF-8").newDecoder(); private final CharBuffer char_buffer = CharBuffer.allocate(KEYBOARD_BUFFER_SIZE); + // Deferred key released event, to detect key repeat + private boolean has_deferred_event = true; + private int deferred_keycode; + private int deferred_event_keycode; + private long deferred_nanos; + private byte deferred_key_state; + public LinuxKeyboard(long display, long window) { long modifier_map = getModifierMapping(display); int tmp_numlock_mask = 0; @@ -153,10 +158,12 @@ private static native void closeIM(long xim); public void read(ByteBuffer buffer) { + flushDeferredEvent(); event_queue.copyEvents(buffer); } public void poll(ByteBuffer keyDownBuffer) { + flushDeferredEvent(); int old_position = keyDownBuffer.position(); keyDownBuffer.put(key_down_buffer); keyDownBuffer.position(old_position); @@ -204,14 +211,10 @@ return lookupStringISO88591(event_ptr, translation_buffer); } - private void translateEvent(long event_ptr, int event_type, int keycode, byte key_state, long nanos) { + private void translateEvent(long event_ptr, int keycode, byte key_state, long nanos) { int num_chars, i; int ch; - if (event_type == KeyRelease) { - putKeyboardEvent(keycode, key_state, 0, nanos); - return; - } num_chars = lookupString(event_ptr, temp_translation_buffer); if (num_chars > 0) { ch = temp_translation_buffer[0]; @@ -287,9 +290,9 @@ private byte getKeyState(int event_type) { switch (event_type) { - case KeyPress: + case LinuxEvent.KeyPress: return 1; - case KeyRelease: + case LinuxEvent.KeyRelease: return 0; default: throw new IllegalArgumentException("Unknown event_type: " + event_type); @@ -300,9 +303,33 @@ int keycode = getKeycode(event_ptr, event_state); byte key_state = getKeyState(event_type); key_down_buffer[keycode] = key_state; - translateEvent(event_ptr, event_type, keycode, key_state, millis*1000000); + long nanos = millis*1000000; + if (event_type == LinuxEvent.KeyPress) { + if (has_deferred_event) { + if (nanos == deferred_nanos && event_keycode == deferred_event_keycode) { + has_deferred_event = false; + return; // Repeated event, ignore it + } + flushDeferredEvent(); + } + translateEvent(event_ptr, keycode, key_state, nanos); + } else { + flushDeferredEvent(); + has_deferred_event = true; + deferred_keycode = keycode; + deferred_event_keycode = event_keycode; + deferred_nanos = nanos; + deferred_key_state = key_state; + } } + private void flushDeferredEvent() { + if (has_deferred_event) { + putKeyboardEvent(deferred_keycode, deferred_key_state, 0, deferred_nanos); + has_deferred_event = false; + } + } + public boolean filterEvent(LinuxEvent event) { switch (event.getType()) { case LinuxEvent.KeyPress: /* Fall through */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |