user interface - In GTK/Linux, what's the correct way to get the DPI scale factor? -


Reference: Writing a drawing program that should be cross-platform So I have several front axes that are responsible for providing backend class access to a Kaira reference, basic event handling and widget size information. I recently decided to add the existing UI Scale (for high DPI display) to that last bit, mainly because I want to switch graphics to be sung in a tile cache, so I have the highest support for the display Should know the level.

In the world of my small cross-platforms, I hope the front end adapter for backend class is asking me to work in virtualized pixels to properly configure the reference. I need a scale to limit how much scaling should be used on my tiles.

It was easy on the Epiket: Ask NSSize of 1 Virtual Pixel to Scale in "Supporting Store Coordinates" to provide backend class Apple to provide reference of pre-scaled core graphics Was smart enough so I just have to do that to direct the request to flip and press CGContext in Cairo.

I'm a bit more confused on GTK. To do this, in many ways it seems like GtkWidget's call, gint gtk_widget_get_scale_factor (GtkWidget * widget) which returns an integer value It seems a bit restrictive because you can not deal with the screen, which is in the midst of this kind of scenario, of course. 28 "3840x2160 Monitor I see 1.5x monitor is considered, but everything under GTK will be very small or too big.

Ubuntu also throws its own wrench on the works, because it has its own The DPI scale factor that looks different from everything else, only some applications support it. I increased it to 1.5, Firefox and brackets were not on scale, were on Nautilus and terminal scale, and I The strange thing is, where everything has a conversation text scale, so it is not clear whether the system is also built in wide or GTK ... Blurag.

In addition to this, X11 also receives its DPI information The method that I have heard

I could not find any information about this super-special-terrible unity API, so that the user's specified UI scale can be obtained, though. Jat I'm going to capture my integer scale of K, which I do not think is enough but whatever I would really like to know is how to capture the UI scale parameters owned by the Unity scale parameter, or any other desktop environment, But I think I need to ship a custom priority to configure UI scalves manually for this special frontend. Could.

(For those inquisitive: My code is available - Backend class which I am is in src / canvasview.cpp and examples of front view "View Adapter" Frontend / GTK / SRQ / CanvasVidate CPP And Frontx / APKit / CRC / IKConcansViewMe keep in mind that the code is currently in a broken state because I am busy debugging in tile-based rendering.)

If you call it 'getdpi.c', then

  GCC-wall -daddy = c99 -o getdpi getdpi.c -lx11  

If this helps you, then a vote will be appreciated. : -)

#include & lt; X11 / Xlib.h & gt; # Include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; Stable constant unsigned int FALSE = 0; Constant constant unsigned int TRUE = 1; Typedef unsigned int bool; Int getDpi (display * dpy, int scr, bool xRes) * one inch is 25.4 millimeters * dpi = n pixels / (m millimeter / (25.4 millimeter / 1 inch)) * = n pixels / (m inch / 25.4 ) * = N * 25.4 pixels / m inches * / double ridge = xray? 25.4) / ((Double (Double) DisplayWidM (DPI, Scrap): ((((Double ()) DisplayHigh (DPI, Scrub) * 25.4) / ((Double (Double () (Double (W) (DP, Scrap) ) DisplayHythingMM (dpi, scrap)); Return (int) (res + 0.5);} // print_Screen_info int main (int argc, char * argv []) {display * dpy; / * x connection * / char * displayname = NULL; / * Do you require or require * / dpy = XOpenDisplay (displayname); If (! Dpy) {fprintf (stderr, "xdpi: Unable to open display \"% s \ ". \ N" , XDisplayName (displayname); exit (1);} ("Xdpi:% d, ydpi% d \ n", getDpi (dpi, i, tru), ddpi (dpi, ii) and printf ("xdpi:% d, False));} // main

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -