inspector: Better monitor information

Show the fractional scale if we have one, and pixels.

Only Wayland has fractional scales, and for monitors, we have
to derive it from the logical and physical resolution of the
monitor. Not ideal, but it works.
This commit is contained in:
Matthias Clasen
2024-01-30 20:08:44 -05:00
parent 8df8d0bd5d
commit f80989332f

View File

@@ -730,7 +730,7 @@ add_monitor (GtkInspectorGeneral *gen,
GtkListBox *list;
char *value;
GdkRectangle rect;
int scale;
double scale;
char *name;
char *scale_str = NULL;
const char *manufacturer;
@@ -753,9 +753,9 @@ add_monitor (GtkInspectorGeneral *gen,
add_label_row (gen, list, "Connector", gdk_monitor_get_connector (monitor), 10);
gdk_monitor_get_geometry (monitor, &rect);
scale = gdk_monitor_get_scale_factor (monitor);
if (scale != 1)
scale_str = g_strdup_printf ("@%d", scale);
scale = gdk_monitor_get_scale (monitor);
if (scale != 1.0)
scale_str = g_strdup_printf ("@%.2f", scale);
value = g_strdup_printf ("%d×%d%s at %d, %d",
rect.width, rect.height,
@@ -765,6 +765,12 @@ add_monitor (GtkInspectorGeneral *gen,
g_free (value);
g_free (scale_str);
value = g_strdup_printf ("%d × %d",
(int) (rect.width * scale),
(int) (rect.height * scale));
add_label_row (gen, list, "Pixels", value, 10);
g_free (value);
value = g_strdup_printf ("%d×%dmm²",
gdk_monitor_get_width_mm (monitor),
gdk_monitor_get_height_mm (monitor));