Expected High DPI behavior on Ubuntu (X11)


#1

Hi,

I am creating a window using the most recent SDL (compiled from source) using the SDL_WINDOW_ALLOW_HIGHDPI flag. On OSX with a retina display I get a window with a size of 800x600 (which is what SDL_GetWindowSize reports) and a framebuffer size of twice that (as reported by SDL_GL_GetDrawableSize). On Ubuntu 18.10 with a hidpi display I get a small window of 800x600 which makes me wonder what the expected behavior on x11 based platforms is. Wouldn’t it be desirable to have the same behavior on all platforms or is that just not possible (or a good idea)?

Either way, I’d at least be able to detect if I am on a hidpi display so I can scale things accordingly myself. Is there a way to get that information on ubuntu using sdl? Or possibly to detect the content scaling factor that is specified on a screen?

Thank you!!


#2

sorry for bump, i’d still like to hear back about this! Thanks!


#3

unfortunately I don’t know the answer and in my project I had to use xdpyinfo.
So, “+1” for the question :wink:


#4

Hello,

Not sure this will answer, but this blog entry helped me with my own application (SDL2 + Dear ImGui + OpenGL + OpenCV and some other APIs) :

HTH


#5

Thanks. My problem is linux specific. RIght now, SDL seems to do whatever is the “default” behavior on each platform. I think it might be worth considering doing something that is consistent across platforms instead or at least give people the means to gather all the information needed.

As of now, AFAIK, there is no way to detect the content scale set in the display settings on linux (x11, gnome) which would be a great thing to add in order to even detect if you are on a hidpi display. Adding a function to get the content scale on either patform (possibly per display) would be amazing.


#6

HighDPI support is not currently implemented in SDL’s x11 backend. I think the Wayland backend does have support for it, however.

If someone were to contribute an x11 implementation of highdpi support similar to the Wayland implementation, that would be very much welcome.


#7

slime, do you know what the wayland behavior is right now? Is it similar to OSX in the sense that it creates a hidpi window based on the content scaling factor of a screen? (i.e. if you create a 800x600 window on osx with hidpi, it creates a 1600x1200 back buffer)


#8

I don’t use wayland (or Linux), but looking at the commit which added highdpi support for Wayland I believe that’s the case, yeah: https://hg.libsdl.org/SDL/rev/d92b5fbb5ac0


#9

Okay cool, looking at the commit it appears to me like that is what it is doing, too. I’ll try to see if that works on my machine and if so, will possibly try to commit a patch that does something similar using x11. (I will have to freshen up my mercurial skills o_o)