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

GLFW: Fix Relative Scale to account for Fractional Scaling on Wayland compositors #20

Merged

Conversation

Morxemplum
Copy link
Contributor

This pull request fixes a bug that is present on the GLFW implementation.

Normally, when you have a HiDPI monitor (e.g. Apple Retina Display or almost any 4K monitor), you need to scale up the monitor's content so that the content isn't too small to view. On X11, usually this only has integer scaling (1x, 2x, 3x), and X11 only measures physical pixels. This leads to an issue where 1x may be too small, but 2x is too big. Wayland uses logical pixels instead. With this in mind, Wayland has something called "Fractional Scaling", so instead of going from 1x to 2x, you can settle for somewhere in between, like 1.25x or 1.5x.

However, the relative scale implementation for GLFW completely fails to take into account fractional scaling. In the current implementation, it truncates any scale to an integer. While that may work in X11, this will not fly by with Wayland. In my case, I have a monitor with 150% scaling, but this implementation truncates that to 100% as 150% is not an integer (1.5x).

This leads to some horrible bugs, the most notable one being the application's cursor position being completely misaligned with the OS's cursor. By making relative scale a double instead of an integer, relative scale can now take fractional scaling into account and fix these bugs.

Copy link
Member

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ChristopherHX ChristopherHX merged commit feea8c0 into minecraft-linux:master Dec 5, 2024
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

Successfully merging this pull request may close these issues.

2 participants