mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-02-01 21:34:36 +01:00
Make sure that Mouse.destroy ungrabs the cursor
This commit is contained in:
parent
3fc91a641c
commit
d2de70f2d9
|
|
@ -296,7 +296,7 @@ public class Mouse {
|
|||
created = false;
|
||||
buttons = null;
|
||||
coord_buffer = null;
|
||||
|
||||
|
||||
implementation.destroyMouse();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,10 +84,6 @@ abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
|
|||
public synchronized void destroy() {
|
||||
canvas.setInput(null);
|
||||
canvas = null;
|
||||
if (mouse_queue != null)
|
||||
mouse_queue.unregister();
|
||||
if (keyboard_queue != null)
|
||||
keyboard_queue.unregister();
|
||||
}
|
||||
|
||||
public final int getWidth() {
|
||||
|
|
@ -115,8 +111,11 @@ abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
|
|||
return new MouseEventQueue(getCanvas());
|
||||
}
|
||||
|
||||
public void destroyMouse() {
|
||||
mouse_queue.unregister();
|
||||
public synchronized void destroyMouse() {
|
||||
if (mouse_queue != null) {
|
||||
mouse_queue.unregister();
|
||||
mouse_queue = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getNativeCursorCapabilities() {
|
||||
|
|
@ -145,8 +144,10 @@ abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
|
|||
}
|
||||
|
||||
public synchronized void destroyKeyboard() {
|
||||
if (keyboard_queue != null)
|
||||
if (keyboard_queue != null) {
|
||||
keyboard_queue.unregister();
|
||||
keyboard_queue = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,11 @@ final class LinuxAWTInput extends AbstractAWTInput {
|
|||
LinuxDisplay.unlockAWT();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyMouse() {
|
||||
ungrabInputLocked();
|
||||
super.destroyMouse();
|
||||
}
|
||||
|
||||
private void checkFocus() {
|
||||
if (getCanvas().isFocusOwner()) {
|
||||
|
|
@ -148,7 +153,7 @@ final class LinuxAWTInput extends AbstractAWTInput {
|
|||
}
|
||||
|
||||
private boolean shouldGrab() {
|
||||
return !input_released && isGrabbed();
|
||||
return !input_released && isGrabbed() && getMouseEventQueue() != null;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
private boolean shouldGrab() {
|
||||
return !input_released && grab;
|
||||
return !input_released && grab && mouse != null;
|
||||
}
|
||||
|
||||
private void updatePointerGrab() {
|
||||
|
|
@ -715,6 +715,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
|
||||
public void destroyMouse() {
|
||||
mouse = null;
|
||||
updateInputGrab();
|
||||
}
|
||||
|
||||
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ final class LinuxMouse {
|
|||
private static native void nWarpCursor(long display, long window, int x, int y);
|
||||
|
||||
private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) {
|
||||
doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000);
|
||||
doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000);
|
||||
}
|
||||
|
||||
private void handleButton(boolean grab, int button, byte state, long nanos) {
|
||||
|
|
@ -256,7 +256,7 @@ final class LinuxMouse {
|
|||
}
|
||||
}
|
||||
|
||||
private void resetCursor(int x, int y) {
|
||||
private void resetCursor(int x, int y) {
|
||||
last_x = x;
|
||||
last_y = transformY(y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,10 @@ final class MacOSXAWTInput extends AbstractAWTInput {
|
|||
((MacOSXMouseEventQueue)getMouseEventQueue()).warpCursor();
|
||||
had_focus = has_focus;
|
||||
}
|
||||
|
||||
public synchronized void destroyMouse() {
|
||||
if (getMouseEventQueue() != null)
|
||||
getMouseEventQueue().setGrabbed(false);
|
||||
super.destroyMouse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,8 +299,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void destroyMouse() {
|
||||
if (mouse_queue != null)
|
||||
if (mouse_queue != null) {
|
||||
mouse_queue.setGrabbed(false);
|
||||
mouse_queue.unregister();
|
||||
}
|
||||
this.mouse_queue = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ final class WindowsAWTInput extends AbstractAWTInput {
|
|||
blank_cursor = AWTUtil.createCursor(w, h, 0, 0, 1, BufferUtils.createIntBuffer(w*h), null);
|
||||
}
|
||||
|
||||
public synchronized void destroy() {
|
||||
super.destroy();
|
||||
public synchronized void destroyMouse() {
|
||||
if (cached_mouse != null) {
|
||||
grab(false);
|
||||
cached_mouse.destroy();
|
||||
}
|
||||
super.destroyMouse();
|
||||
}
|
||||
|
||||
public synchronized void processInput(PeerInfo peer_info) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue