Do not reset cursor clipping when releasing mouse grab in fullscreen mode. Fix #106
Also refactored and optimized cursor handling.
This commit is contained in:
parent
ae4606c53f
commit
e4b098c5e2
|
@ -379,16 +379,13 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
setFocus(getHwnd());
|
||||
redoMakeContextCurrent = true;
|
||||
if (Display.isFullscreen())
|
||||
updateClipping();
|
||||
} else {
|
||||
if ( keyboard != null )
|
||||
keyboard.releaseAll(millis);
|
||||
if ( Display.isFullscreen() ) {
|
||||
showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
|
||||
resetDisplayMode();
|
||||
} else
|
||||
updateClipping();
|
||||
}
|
||||
}
|
||||
updateCursor();
|
||||
inAppActivate = false;
|
||||
|
@ -610,7 +607,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void grabMouse(boolean grab) {
|
||||
mouse.grab(grab, shouldGrab());
|
||||
mouse.grab(grab);
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
|
@ -634,13 +631,15 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
private void updateCursor() {
|
||||
try {
|
||||
if (mouse != null && shouldGrab())
|
||||
if (mouse != null && shouldGrab()) {
|
||||
centerCursor(hwnd);
|
||||
nSetNativeCursor(getHwnd(), mouse.getBlankCursor());
|
||||
else
|
||||
} else
|
||||
nSetNativeCursor(getHwnd(), current_cursor);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to update cursor: " + e);
|
||||
}
|
||||
updateClipping();
|
||||
}
|
||||
static native void nSetNativeCursor(long hwnd, Object handle) throws LWJGLException;
|
||||
|
||||
|
@ -981,16 +980,6 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
resized = true;
|
||||
updateWidthAndHeight();
|
||||
break;
|
||||
case WM_SETCURSOR:
|
||||
if((lParam & 0xFFFF) == HTCLIENT) {
|
||||
// if the cursor is inside the client area, reset it
|
||||
// to the current LWJGL-cursor
|
||||
updateCursor();
|
||||
return -1; //TRUE
|
||||
} else {
|
||||
// let Windows handle cursors outside the client area for resizing, etc.
|
||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
case WM_KILLFOCUS:
|
||||
appActivate(false, millis);
|
||||
return 0L;
|
||||
|
@ -1012,7 +1001,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
}
|
||||
if ( !mouseInside ) {
|
||||
mouseInside = true;
|
||||
updateClipping();
|
||||
updateCursor();
|
||||
nTrackMouseEvent(hwnd);
|
||||
}
|
||||
return 0L;
|
||||
|
|
|
@ -105,7 +105,7 @@ final class WindowsMouse {
|
|||
coord_buffer.put(coord_buffer.position() + 1, accum_dy);
|
||||
|
||||
if ( display.isActive() && display.isVisible() && (accum_dx != 0 || accum_dy != 0) )
|
||||
centerCursor();
|
||||
WindowsDisplay.centerCursor(hwnd);
|
||||
} else {
|
||||
coord_buffer.put(coord_buffer.position() + 0, last_x);
|
||||
coord_buffer.put(coord_buffer.position() + 1, last_y);
|
||||
|
@ -135,25 +135,8 @@ final class WindowsMouse {
|
|||
return blank_cursor;
|
||||
}
|
||||
|
||||
public void grab(boolean grab, boolean should_center) {
|
||||
if (grab) {
|
||||
if (!mouse_grabbed) {
|
||||
mouse_grabbed = true;
|
||||
if (should_center) {
|
||||
try {
|
||||
WindowsDisplay.setupCursorClipping(hwnd);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to setup cursor clipping: " + e);
|
||||
}
|
||||
centerCursor();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mouse_grabbed) {
|
||||
mouse_grabbed = false;
|
||||
WindowsDisplay.resetCursorClipping();
|
||||
}
|
||||
}
|
||||
public void grab(boolean grab) {
|
||||
mouse_grabbed = grab;
|
||||
event_queue.clearEvents();
|
||||
}
|
||||
|
||||
|
@ -162,10 +145,6 @@ final class WindowsMouse {
|
|||
putMouseEvent((byte)-1, (byte)0, event_dwheel, millis*1000000);
|
||||
}
|
||||
|
||||
private void centerCursor() {
|
||||
WindowsDisplay.centerCursor(hwnd);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.last_x = x;
|
||||
this.last_y = y;
|
||||
|
|
Loading…
Reference in New Issue