Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rcore] Current mouse position not updated after window repositioning #4664

Open
rossberg opened this issue Jan 7, 2025 · 3 comments
Open

Comments

@rossberg
Copy link

rossberg commented Jan 7, 2025

Issue description

Raylib's current mouse position is only updated on mouse events. Hence, if the window position is changed (using SetWindowPosition) without mouse movement occurring, then the current mouse position is not adjusted. The values reported by GetMousePosition and GetMouseDelta are incorrect afterwards, until the mouse is moved again.

This was a bit of a headache for a little windowed GUI I implemented.

Since there is no way to directly query the absolute mouse position either, my only workaround was to maintain mirrors of mouse position, delta, and the previous window position. On each frame check for a change in window position co-occurring with a zero mouse delta, and in that case, correct the mirror mouse position and delta by the window movement delta. That seems to work, but of course, it would be preferable if that wasn't necessary.

Environment

Running on MacOS. But deducing from a glance at the Raylib sources, I expect this to occur on other platforms as well.

@rossberg
Copy link
Author

rossberg commented Jan 8, 2025

Update: I just tested it on Windows, where the problem does not occur. So it may be specific to MacOS and its Window manager.

@Peter0x44
Copy link
Contributor

Does SDL or rgfw have this problem?

@rossberg
Copy link
Author

rossberg commented Jan 9, 2025

@Peter0x44, good question. I'm using Raylib through a language binding (OCaml), so I have no access to build options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants