x11: fix refresh rate reported as 0 for high pixel-clock modes#15888
Open
francisdb wants to merge 1 commit into
Open
x11: fix refresh rate reported as 0 for high pixel-clock modes#15888francisdb wants to merge 1 commit into
francisdb wants to merge 1 commit into
Conversation
CalculateXRandRRefreshRate assigned the XRandR mode's dotClock (unsigned long) directly into the int numerator. For high pixel-clock modes (e.g. 4K@240Hz the pixel clock exceeds INT_MAX) the numerator overflowed to a negative value, so SDL_GetDesktopDisplayMode reported a refresh rate of 0. Compute the fraction in 64-bit and scale it down to fit the int numerator and denominator while preserving the ratio.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
, including code generated by a Large Language Model ("AI")If the AI code completion part is a problem consider this an issue an let somebody else come up with a fix.
Description
On X11,
SDL_GetDesktopDisplayMode()reports a refresh rate of0for high pixel-clock modes such as 4K@240Hz, while lower-clock modes on the same machine (4K@60, 1080p) are fine.The X11 refresh-rate calculation overflows for those high pixel clocks and falls back to 0. It is a regression from when the calculation moved to the numerator/denominator representation, which dropped the wide-integer handling the earlier path had (#8933).
Testing
Reproduced with a small program calling
SDL_GetDesktopDisplayMode()per display on a dual-monitor setup (a 4K@240Hz DP-1 and a 4K@60Hz portrait DP-4), and cross-checked againstxrandr:0.000(num=0)239.980(num=1626625000)239.98240.00059.98059.98059.9860.000Note: this surfaced while running an SDL app under Xwayland, but it is not Xwayland-specific - the same overflow applies to any high pixel-clock mode on a native X server.