From: <eli...@us...> - 2007-05-31 22:09:52
|
Revision: 2838 http://svn.sourceforge.net/java-game-lib/?rev=2838&view=rev Author: elias_naur Date: 2007-05-31 15:09:46 -0700 (Thu, 31 May 2007) Log Message: ----------- Mac OS X: When grabbing the mouse, skip the next event to avoid bogus deltas Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2007-05-31 21:11:34 UTC (rev 2837) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2007-05-31 22:09:46 UTC (rev 2838) @@ -53,6 +53,7 @@ final class MacOSXMouseEventQueue extends MouseEventQueue { private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2); + private boolean skip_event; private static boolean is_grabbed; MacOSXMouseEventQueue(Component component) { @@ -84,6 +85,10 @@ getMouseDeltas(delta_buffer); int dx = delta_buffer.get(0); int dy = -delta_buffer.get(1); + if (skip_event) { + skip_event = false; + return; + } if ( dx != 0 || dy != 0 ) { putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos); addDelta(dx, dy); @@ -92,6 +97,10 @@ } void warpCursor() { + synchronized (this) { + // If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values + skip_event = isGrabbed(); + } if (isGrabbed()) { Rectangle bounds = getComponent().getBounds(); Point location_on_screen = getComponent().getLocationOnScreen(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |