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

[Renderers/Raylib] Faulty high DPI layout and mouse position calculation after resizing #116

Open
xypwn opened this issue Dec 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@xypwn
Copy link

xypwn commented Dec 27, 2024

Layout calculations seem incorrect on my 1440p monitor with FLAG_WINDOW_HIGHDPI.

This is my monitor layout:

+===========+ +===========+
| 2560x1440 | | 1920x1080 |
| (main)    | |           |
+===========+ +===========+

Running the "raylib-sidebar-scrolling-container" example, the layout initially looks normal:
grafik

After resizing, the content is sized larger than the window (this remains true until restarting the program) [mouse cursor calculations are still correct]:
grafik

When pulling the window over to my 1080p monitor, the mouse cursor is offset (see how the mouse cursor is to the right of the element clay/raylib thinks is selected):
grafik

@xypwn xypwn changed the title Faulty high DPI layout and mouse position calculation [raylib] Faulty high DPI layout and mouse position calculation after resizing [raylib] Dec 27, 2024
@nicbarker
Copy link
Owner

nicbarker commented Dec 28, 2024

Interesting - just to clarify, this is raylib 5.5 on windows with high DPI?
Also, what is your OS font scaling set to?

@nicbarker nicbarker changed the title Faulty high DPI layout and mouse position calculation after resizing [raylib] [Renderers/Raylib] Faulty high DPI layout and mouse position calculation after resizing Dec 28, 2024
@nicbarker nicbarker added the bug Something isn't working label Dec 28, 2024
@xypwn
Copy link
Author

xypwn commented Dec 28, 2024

Yeah, sorry for not clarifying - OS is Windows 10, Raylib 5.5, 125% scaling for the main (1440p) monitor and 100% for the 1080p monitor.

@xypwn
Copy link
Author

xypwn commented Dec 28, 2024

Hmm, this seems like a fundamental issue with Raylib: raysan5/raylib#4215. I tried playing around with the code and while I managed to hack together a fix for the scaling issue, I was unable to fix the mouse position issue (the mouse position seems to be erroneously scaled on the second monitor based on the first monitor's scaling, so definitely some very weird and unintended stuff from Raylib's side).

In the mentioned issue, OP says that the HIGH DPI flag does more harm than good and is broken in many use cases. Thus, one approach would be to add High DPI support in Clay directly, which could simply be a factor scaling the elements and text (the user would have to handle font re-rendering on DPI change manually, but that should be possible with Raylib's GetWindowScaleDPI()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants