Question

Using GTK, how do I query the current screen's dpi settings?

Was it helpful?

Solution

The current accepted answer is for PHPGTK, which feels a bit odd to me. The pure GDK library has this call: gdk_screen_get_resolution(), which sounds like a better match. Haven't worked with it myself, don't know if it's generally reliable.

OTHER TIPS

See http://gtk.php.net/manual/en/gdk.gdkscreen.php. You should be able to compute it using the get_height and get_height_mm or with get_width and get_width_mm.

The resolution height and width returned by screen includes the full multi-monitor sizes (e.g. combined width and length of the displayer buffer used to render multi-monitor setup). I've not check of the mm (millimeter width/height) calls returns the actual physical sizes but if it report combined physical sizes then the dpi computed from dividing one with another would be meaningless, e.g. to draw a box on screen that can be measured using a physical ruler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top