Windows AWTInput: Make sure the cursor is contained within the window when the Mouse is grabbed.
This commit is contained in:
parent
e8d032973f
commit
46ce5679c8
|
@ -99,15 +99,24 @@ final class WindowsAWTInput extends AbstractAWTInput {
|
|||
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);
|
||||
|
|
|
@ -145,8 +145,8 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue