diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 760de54c4..3b951c64c 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -385,4 +385,6 @@ void meta_monitor_manager_clear_output (MetaOutput *output); void meta_monitor_manager_clear_mode (MetaCrtcMode *mode); void meta_monitor_manager_clear_crtc (MetaCrtc *crtc); +gboolean meta_monitor_has_aspect_as_size (MetaMonitor *monitor); + #endif /* META_MONITOR_MANAGER_PRIVATE_H */ diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 61333b4e5..02cb1619f 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -921,33 +921,62 @@ diagonal_to_str (double d) return g_strdup_printf ("%d\"", (int) (d + 0.5)); } +gboolean +meta_monitor_has_aspect_as_size (MetaMonitor *monitor) +{ + int width_mm; + int height_mm; + + meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm); + + return (width_mm == 160 && height_mm == 90) || + (width_mm == 160 && height_mm == 100) || + (width_mm == 16 && height_mm == 9) || + (width_mm == 16 && height_mm == 10); +} + static char * make_display_name (MetaMonitorManager *manager, - MetaOutput *output) + MetaMonitor *monitor) { g_autofree char *inches = NULL; g_autofree char *vendor_name = NULL; + const char *vendor = NULL; + const char *product_name = NULL; + int width_mm; + int height_mm; - if (meta_output_is_laptop (output)) + meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm); + + if (meta_monitor_is_laptop_panel (monitor)) return g_strdup (_("Built-in display")); - if (output->width_mm > 0 && output->height_mm > 0) + if (width_mm > 0 && height_mm > 0) { - double d = sqrt (output->width_mm * output->width_mm + - output->height_mm * output->height_mm); - inches = diagonal_to_str (d / 25.4); + if (!meta_monitor_has_aspect_as_size (monitor)) + { + double d = sqrt (width_mm * width_mm + + height_mm * height_mm); + inches = diagonal_to_str (d / 25.4); + } + else + { + product_name = meta_monitor_get_product (monitor); + } } - if (g_strcmp0 (output->vendor, "unknown") != 0) + vendor = meta_monitor_get_vendor (monitor); + + if (g_strcmp0 (vendor, "unknown") != 0) { if (!manager->pnp_ids) manager->pnp_ids = gnome_pnp_ids_new (); vendor_name = gnome_pnp_ids_get_pnp_id (manager->pnp_ids, - output->vendor); + vendor); if (!vendor_name) - vendor_name = g_strdup (output->vendor); + vendor_name = g_strdup (vendor); } else { @@ -964,6 +993,14 @@ make_display_name (MetaMonitorManager *manager, */ return g_strdup_printf (_("%s %s"), vendor_name, inches); } + else if (product_name != NULL) + { + /* Translators: this is a monitor vendor name followed by + * product/model name where size in inches could not be calculated, + * e.g. Dell U2414H + */ + return g_strdup_printf (_("%s %s"), vendor_name, product_name); + } else { return g_strdup (vendor_name); @@ -1318,7 +1355,6 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton, GVariantBuilder monitor_properties_builder; GList *k; gboolean is_builtin; - MetaOutput *main_output; char *display_name; current_mode = meta_monitor_get_current_mode (monitor); @@ -1408,8 +1444,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton, "is-builtin", g_variant_new_boolean (is_builtin)); - main_output = meta_monitor_get_main_output (monitor); - display_name = make_display_name (manager, main_output); + display_name = make_display_name (manager, monitor); g_variant_builder_add (&monitor_properties_builder, "{sv}", "display-name", g_variant_new_take_string (display_name)); diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 9f32354de..e35da7d70 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -1523,10 +1523,7 @@ calculate_scale (MetaMonitor *monitor, * Somebody encoded the aspect ratio (16/9 or 16/10) instead of the physical * size. */ - if ((width_mm == 160 && height_mm == 90) || - (width_mm == 160 && height_mm == 100) || - (width_mm == 16 && height_mm == 9) || - (width_mm == 16 && height_mm == 10)) + if (meta_monitor_has_aspect_as_size (monitor)) goto out; if (width_mm > 0 && height_mm > 0)