We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3401 - SDL_GetDisplayDPI returns a wrong value on Linux and FreeBSD (X11)
Summary: SDL_GetDisplayDPI returns a wrong value on Linux and FreeBSD (X11)
Status: ASSIGNED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-01 09:05 UTC by Lena
Modified: 2017-08-11 21:00 UTC (History)
1 user (show)

See Also:


Attachments
X11: a sample code that works and returns the correct DPI (950 bytes, text/x-c++src)
2016-08-01 10:24 UTC, Lena
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lena 2016-08-01 09:05:02 UTC
On my system with Linux 4.6.4 and X11 1.18.4 the function SDL_GetDisplayDPI returns a wrong value. The same happens on FreeBSD 10.2 too.

My physical DPI is 96, while the functions always gives me 129.280685 average. Can I even trust this function on X11 to calculate a proper content scale factor?
Comment 1 Lena 2016-08-01 10:24:20 UTC
Created attachment 2535 [details]
X11: a sample code that works and returns the correct DPI
Comment 2 Philipp Wiesemann 2016-08-01 20:28:25 UTC
Does the program from "test/testdisplayinfo.c" also report a wrong value?

And is XRandR support activated on the two systems and also compiled into SDL?

There are two implementations to get the DPI in SDL (both in "src/video/x11/SDL_x11modes.c"). The older looks similar to the attached sample. It is used if no XRandR support is available.
Comment 3 Lena 2016-08-02 06:43:15 UTC
The test program has the same values as my code had.

INFO:     DPI: ddpi=128.876648; hdpi=128.336838; vdpi=130.628571

This are the X11 libraries my SDL2 build is using: xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode


Maybe a compute issue in the XRandR code?