Mac OS X: Be less aggressive when grabbing mouse to allow dragging of lwjgl windows with grabbed mouse
This commit is contained in:
parent
ca0023a05d
commit
36d9d31dab
|
@ -283,7 +283,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
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) {
|
||||
if (frame != null && mouse_queue != null) {
|
||||
if (frame.syncShouldReleaseCursor())
|
||||
MacOSXMouseEventQueue.nGrabMouse(false);
|
||||
if (frame.syncShouldWarpCursor())
|
||||
mouse_queue.warpCursor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
|||
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 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
|||
public void windowDeactivated(WindowEvent e) {
|
||||
synchronized ( this ) {
|
||||
active = false;
|
||||
should_release_cursor = true;
|
||||
should_warp_cursor = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,6 +179,7 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
|||
synchronized ( this ) {
|
||||
active = true;
|
||||
should_warp_cursor = true;
|
||||
should_release_cursor = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,6 +208,15 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
|||
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 ) {
|
||||
|
|
|
@ -62,6 +62,7 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
|
|||
private static synchronized void grabMouse(boolean grab) {
|
||||
if (is_grabbed != grab) {
|
||||
is_grabbed = grab;
|
||||
if (!grab)
|
||||
nGrabMouse(grab);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +81,7 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
|
|||
int dy = -delta_buffer.get(1);
|
||||
if (skip_event) {
|
||||
skip_event = false;
|
||||
nGrabMouse(isGrabbed());
|
||||
return;
|
||||
}
|
||||
if ( dx != 0 || dy != 0 ) {
|
||||
|
@ -94,13 +96,13 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
|
|||
// 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);
|
||||
|
|
Loading…
Reference in New Issue