|
From: <eli...@us...> - 2008-09-11 09:52:31
|
Revision: 3126
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3126&view=rev
Author: elias_naur
Date: 2008-09-11 09:52:23 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Mac OS X: Be less aggressive when grabbing mouse to allow dragging of lwjgl windows with grabbed mouse
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -283,8 +283,11 @@
GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
}
- if (frame != null && frame.syncShouldWarpCursor() && mouse_queue != null) {
- mouse_queue.warpCursor();
+ if (frame != null && mouse_queue != null) {
+ if (frame.syncShouldReleaseCursor())
+ MacOSXMouseEventQueue.nGrabMouse(false);
+ if (frame.syncShouldWarpCursor())
+ mouse_queue.warpCursor();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -65,6 +65,7 @@
private boolean active;
private boolean minimized;
private boolean should_warp_cursor;
+ private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
setResizable(false);
@@ -169,6 +170,8 @@
public void windowDeactivated(WindowEvent e) {
synchronized ( this ) {
active = false;
+ should_release_cursor = true;
+ should_warp_cursor = false;
}
}
@@ -176,6 +179,7 @@
synchronized ( this ) {
active = true;
should_warp_cursor = true;
+ should_release_cursor = false;
}
}
@@ -204,6 +208,15 @@
return canvas;
}
+ public boolean syncShouldReleaseCursor() {
+ boolean result;
+ synchronized ( this ) {
+ result = should_release_cursor;
+ should_release_cursor = false;
+ }
+ return result;
+ }
+
public boolean syncShouldWarpCursor() {
boolean result;
synchronized ( this ) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -62,7 +62,8 @@
private static synchronized void grabMouse(boolean grab) {
if (is_grabbed != grab) {
is_grabbed = grab;
- nGrabMouse(grab);
+ if (!grab)
+ nGrabMouse(grab);
}
}
@@ -80,6 +81,7 @@
int dy = -delta_buffer.get(1);
if (skip_event) {
skip_event = false;
+ nGrabMouse(isGrabbed());
return;
}
if ( dx != 0 || dy != 0 ) {
@@ -94,13 +96,13 @@
// 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()) {
+/* if (isGrabbed()) {
Rectangle bounds = getComponent().getBounds();
Point location_on_screen = getComponent().getLocationOnScreen();
int x = location_on_screen.x + bounds.width/2;
int y = location_on_screen.y + bounds.height/2;
nWarpCursor(x, y);
- }
+ }*/
}
private static native void getMouseDeltas(IntBuffer delta_buffer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|