gdk: Add private convenience api

Add a function to get the monitor resolution.

We may use this information in the future to make font rendering
decisions.
This commit is contained in:
Matthias Clasen 2024-04-06 15:48:18 +02:00
parent cc8db1805d
commit a63e9d38fb
2 changed files with 9 additions and 0 deletions

View File

@ -744,3 +744,11 @@ gdk_monitor_set_description (GdkMonitor *monitor,
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
}
#define MM_PER_INCH 25.4
double
gdk_monitor_get_dpi (GdkMonitor *monitor)
{
return MAX ((monitor->geometry.width * monitor->scale) / (monitor->width_mm / MM_PER_INCH),
(monitor->geometry.height * monitor->scale) / (monitor->height_mm / MM_PER_INCH));
}

View File

@ -76,6 +76,7 @@ void gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
void gdk_monitor_invalidate (GdkMonitor *monitor);
void gdk_monitor_set_description (GdkMonitor *monitor,
const char *description);
double gdk_monitor_get_dpi (GdkMonitor *monitor);
G_END_DECLS