libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.41k stars 1.75k forks source link

SDL_GetDisplayDPI does not return 96 at 100% scale on linux #5647

Closed Etaash-mathamsetty closed 2 years ago

Etaash-mathamsetty commented 2 years ago

is there any way to fix it, I have been looking for hours at this point, seems to work for everyone else but me :(

Etaash-mathamsetty commented 2 years ago

why the hell is it reporting a lower dpi for 200% scale vs 100%?????

slime73 commented 2 years ago

SDL has separate APIs for determining DPI scale and pixels versus DPI-scaled units, for what it's worth. (SDL_GetWindowSize for dpi-scaled units, and SDL_GetRendererOutputSize or SDL_GL_GetDrawableSize or SDL_Vulkan_GetDrawableSize or SDL_Metal_GetDrawableSize for raw pixels depending on what API you're using.) Although I believe the x11 backend doesn't support highdpi / DPI scaling awareness.

Etaash-mathamsetty commented 2 years ago

those methods should be used by the getDPI function lol

Etaash-mathamsetty commented 2 years ago

yeah that method works pretty well

slouken commented 2 years ago

Reopened so @icculus can look at what SDL_GetDisplayDPI() is doing on Linux

icculus commented 2 years ago

In theory this got fixed in https://github.com/libsdl-org/SDL/commit/ec0204d2438829b18d5942b93713dfd00682121c ... @Etaash-mathamsetty, can you recheck?

Etaash-mathamsetty commented 2 years ago

In theory this got fixed in ec0204d ... @Etaash-mathamsetty, can you recheck?

I forgot to mention that I was testing on wayland, so it would be nice if you updated it for wayland too

Etaash-mathamsetty commented 2 years ago

In theory this got fixed in ec0204d ... @Etaash-mathamsetty, can you recheck?

unfortunately still broken under xorg and wayland edit: I linked it statickly and SDL2.so does not show up with ldd, so it's probably still broken

icculus commented 2 years ago

I think Wayland has always done this correctly, it was our x11 code that did not.

Perhaps your display is reporting a bogus EDID value...?

icculus commented 2 years ago

Going to add documentation to warn about this function and then I'll close.