Ignore one mouse movement event after cursor ungrabbing to prevent a stale cursor position in GUIs.

This commit is contained in:
Raven Szewczyk committed 2023-03-13 16:41:02 +00:00
1 parent c47e58af4c
commit 7aa1195f1e
1 file changed
+7
@@ -47,8 +47,13 @@ public class Mouse {
private static boolean clipPostionToDisplay = true;
private static boolean ignoreNextDelta = false;
private static boolean ignoreNextMove = false;
public static void addMoveEvent(double mouseX, double mouseY) {
if (ignoreNextMove) {
ignoreNextMove = false;
return;
}
latestX = (int) mouseX;
latestY = Display.getHeight() - (int) mouseY;
if (ignoreNextDelta) {
@@ -241,6 +246,8 @@ public class Mouse {
return;
}
GLFW.glfwSetCursorPos(Display.getWindow(), new_x, new_y);
addMoveEvent(new_x, new_y);
ignoreNextMove = true;
}
public static Cursor setNativeCursor(Cursor cursor) throws LWJGLException {