How do I XPutImage() without Wayland upscaling the image due to a high DPI screen?

55 Views Asked by At

I'm writing a pure X11 application for my phone, and I note that the application is told that the window size is half of what it actually is, and when I call XPutImage, the image is scaled up by a factor of two when displayed. Obviously this is because it's a high-DPI screen and the window is being upscaled, but I'd really rather draw at the screen's actual resolution.

I tried asking ChatGPT a whole lot of questions, but it seems to assume that I can draw at the screen's actual DPI and only need to determine a scaling factor that I should use to enlarge what I draw, perhaps because there is one years-old question here that's related and has only one answer which assumes the same thing.

I also tried a lot of internet searching, but while searching for programming terms like "XPutImage" normally brings up lots of programming examples, throw in terms like "HiDPI" or "high DPI" and all you get are people talking about how they opened up a GUI and turned up the scaling factor, no matter how hard you try to push that search back towards programming results. It's as if no one has ever written a high-DPI-aware X11 application; as if the world decided that the solution is just Wayland scaling up the content, and no one has any real interest in viewing higher-resolution content on their higher-resolution screens. I mean, if they really wanted applications to support high DPI, they'd provide some kind of documented API to tell people how to do that, right?

Like, I should be able to call a couple of functions:

float factor = XGetScaleFactor(); // find how large I should draw things XSetScaleFactor(1.0); // tell X11 I'll be drawing at actual pixel size

It should really be that easy, but as far as I can tell, maybe there's some way GTK or QT can talk to who-knows-what via some undocumented API and tell it to stop upscaling the window, but X11 applications seem to have been left out entirely. Is the X11 API "deprecated" now, and so nobody cares if "pixels" was replaced with "logical units" and there's no way to work with actual pixels anymore? It really seems like that's what happened.

0

There are 0 best solutions below