diff options
author | Michael Natterer <mitch@gimp.org> | 2013-01-18 15:47:29 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2013-07-03 12:27:10 +0200 |
commit | 8ad851f7251dabf217378235ebb9f3ec0e72e93d (patch) | |
tree | b9d5a82e4393bc1e78dd5a4c97a870658ece1a2e /gdk/gdkscreen.c | |
parent | 995a7e95b9ff03ae42ca59f1f7df61595e7137f9 (diff) | |
download | gtk+-8ad851f7251dabf217378235ebb9f3ec0e72e93d.tar.gz |
add gdk_screen_ and gdk_window_get_scale_factor()
These report the internal scaling factor, mapping from UI pixels
to hardware pixels.
Diffstat (limited to 'gdk/gdkscreen.c')
-rw-r--r-- | gdk/gdkscreen.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c index 93fef6d06a..9a71b98b80 100644 --- a/gdk/gdkscreen.c +++ b/gdk/gdkscreen.c @@ -1048,3 +1048,37 @@ gdk_screen_get_setting (GdkScreen *screen, return GDK_SCREEN_GET_CLASS (screen)->get_setting (screen, name, value); } + +/** + * gdk_screen_get_monitor_scale_factor: + * @screen: screen to get scale factor for + * @monitor_num: number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) + * + * Returns the internal scale factor that maps from monitor coordiantes + * to the actual device pixels. On traditional systems this is 1, but + * on very high density outputs this can be a higher value (often 2). + * + * This can be used if you want to create pixel based data for a + * particula monitor, but most of the time you're drawing to a window + * where it is better to use gdk_window_get_scale_factor() instead. + * + * Since: 3.10 + * Return value: the scale factor + */ +gint +gdk_screen_get_monitor_scale_factor (GdkScreen *screen, + gint monitor_num) +{ + GdkScreenClass *screen_class; + + g_return_val_if_fail (GDK_IS_SCREEN (screen), 1); + g_return_val_if_fail (monitor_num >= 0, 1); + g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), 1); + + screen_class = GDK_SCREEN_GET_CLASS (screen); + + if (screen_class->get_monitor_scale_factor) + return screen_class->get_monitor_scale_factor (screen, monitor_num); + + return 1.0; +} |