|
39 | 39 | import com.jme3.input.event.MouseMotionEvent; |
40 | 40 | import com.jme3.math.Vector2f; |
41 | 41 | import com.jme3.system.AppSettings; |
| 42 | +import com.jme3.system.JmeSystem; |
42 | 43 | import com.jme3.system.lwjgl.LwjglWindow; |
43 | 44 | import com.jme3.util.BufferUtils; |
44 | 45 | import java.nio.ByteBuffer; |
@@ -94,6 +95,7 @@ public class SdlMouseInput implements MouseInput { |
94 | 95 | private boolean cursorVisible = true; |
95 | 96 | private boolean windowFocused = true; |
96 | 97 | private boolean visibleCursorPositionValid; |
| 98 | + private boolean protonCursorRestorePending; |
97 | 99 | private boolean initialized; |
98 | 100 |
|
99 | 101 | public SdlMouseInput(final LwjglWindow context) { |
@@ -296,6 +298,12 @@ public int getButtonCount() { |
296 | 298 |
|
297 | 299 | @Override |
298 | 300 | public void update() { |
| 301 | + if (protonCursorRestorePending && cursorVisible && windowFocused |
| 302 | + && !SDL_GetWindowRelativeMouseMode(context.getWindowHandle())) { |
| 303 | + protonCursorRestorePending = false; |
| 304 | + restoreVisibleCursorPosition(); |
| 305 | + } |
| 306 | + |
299 | 307 | if (currentCursor != null && currentCursor.length > 1) { |
300 | 308 | long now = SDL_GetTicksNS(); |
301 | 309 | long frameTimeMs = (now - currentCursorFrameStartTimeNs) / 1_000_000L; |
@@ -356,10 +364,12 @@ public void setCursorVisible(boolean visible) { |
356 | 364 | if (!wasVisible) { |
357 | 365 | if (restoreVisibleCursorPosition()) { |
358 | 366 | queueMousePositionSyncEvent(); |
| 367 | + protonCursorRestorePending = JmeSystem.getPlatform().isWineProton(); |
359 | 368 | } |
360 | 369 | } |
361 | 370 | SDL_SetWindowRelativeMouseMode(context.getWindowHandle(), false); |
362 | 371 | } else { |
| 372 | + protonCursorRestorePending = false; |
363 | 373 | if (wasVisible || !visibleCursorPositionValid) { |
364 | 374 | saveVisibleCursorPosition(); |
365 | 375 | } |
|
0 commit comments