Ueda Takeyuki
Ueda Takeyuki

Reputation: 871

How to get screen height and width in pixcels instead of mm?

Before GDK version 3.28, I got screen height and width in pixels by gdk_screen_height() and gdk_screen_width(), but both get deprecated since version 3.22 and the GDK documentation suggests that "Use per-monitor information".

So, instead of directly using deprecated functions, I've got GdkMonitor as follows:

GdkDisplay *display = gdk_display_get_default();
GdkWindow* gdkwindow = gdk_get_default_root_window ();
GdkMonitor* monitor = gdk_display_get_monitor_at_window (display, gdkwindow);

The problem here is that GdkMonitor only has functions that return in mm units like gdk_monitor_get_height_mm() and gdk_monitor_get_height_mm, no functions return in pixels units.

How can I convert these mm units' values to pixel units?
Or, Have I missed something that "Use per-monitor information" suggested by the GDK document?

Upvotes: 0

Views: 174

Answers (0)

Related Questions