mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
monitor: improve heuristic to determine display output name
Under some circumstances, for example when the display controller driver doesn't report back the correct EDID, or under VirtualBox, Mutter returns suboptimal strings for an output display name, leading to funny labels like 'Unknown 0"', or '(null) 0"' in the Settings panel. This commit improves our heuristic in three ways: - we now avoid putting inches in the display name if either dimension is zero - we use the vendor name in case we're not able to lookup its PnP id from the database. Previously we would have passed over '(null)' - as a special edge-case, when neither inches nor vendor are known, we use the string 'Unknown Display' Finally, we make the combined vendor + inches string translatable, as different languages might want to move the size part of the string to a position different than the end. https://bugzilla.gnome.org/show_bug.cgi?id=721674
This commit is contained in:
parent
7a4adce44f
commit
7b597b8c62
@ -614,17 +614,24 @@ static char *
|
|||||||
make_display_name (MetaMonitorManager *manager,
|
make_display_name (MetaMonitorManager *manager,
|
||||||
MetaOutput *output)
|
MetaOutput *output)
|
||||||
{
|
{
|
||||||
|
char *inches = NULL;
|
||||||
|
char *vendor_name = NULL;
|
||||||
|
char *ret;
|
||||||
|
gboolean is_unknown = FALSE;
|
||||||
|
|
||||||
if (g_str_has_prefix (output->name, "LVDS") ||
|
if (g_str_has_prefix (output->name, "LVDS") ||
|
||||||
g_str_has_prefix (output->name, "eDP"))
|
g_str_has_prefix (output->name, "eDP"))
|
||||||
return g_strdup (_("Built-in display"));
|
{
|
||||||
|
ret = g_strdup (_("Built-in display"));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (output->width_mm != -1 && output->height_mm != -1)
|
if (output->width_mm > 0 && output->height_mm > 0)
|
||||||
{
|
{
|
||||||
double d = sqrt (output->width_mm * output->width_mm +
|
double d = sqrt (output->width_mm * output->width_mm +
|
||||||
output->height_mm * output->height_mm);
|
output->height_mm * output->height_mm);
|
||||||
char *inches = diagonal_to_str (d / 25.4);
|
inches = diagonal_to_str (d / 25.4);
|
||||||
char *vendor_name;
|
}
|
||||||
char *ret;
|
|
||||||
|
|
||||||
if (g_strcmp0 (output->vendor, "unknown") != 0)
|
if (g_strcmp0 (output->vendor, "unknown") != 0)
|
||||||
{
|
{
|
||||||
@ -634,26 +641,34 @@ make_display_name (MetaMonitorManager *manager,
|
|||||||
vendor_name = gnome_pnp_ids_get_pnp_id (manager->pnp_ids,
|
vendor_name = gnome_pnp_ids_get_pnp_id (manager->pnp_ids,
|
||||||
output->vendor);
|
output->vendor);
|
||||||
|
|
||||||
ret = g_strdup_printf ("%s %s", vendor_name, inches);
|
if (!vendor_name)
|
||||||
|
vendor_name = g_strdup (output->vendor);
|
||||||
g_free (vendor_name);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TRANSLATORS: this is a monitor name (in case we don't know
|
if (inches != NULL)
|
||||||
the vendor), it's Unknown followed by a size in inches,
|
vendor_name = g_strdup (_("Unknown"));
|
||||||
like 'Unknown 15"'
|
else
|
||||||
|
vendor_name = g_strdup (_("Unknown Display"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inches != NULL)
|
||||||
|
{
|
||||||
|
/* TRANSLATORS: this is a monitor vendor name, followed by a
|
||||||
|
* size in inches, like 'Dell 15"'
|
||||||
*/
|
*/
|
||||||
ret = g_strdup_printf (_("Unknown %s"), inches);
|
ret = g_strdup_printf (_("%s %s"), vendor_name, inches);
|
||||||
}
|
|
||||||
|
|
||||||
g_free (inches);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return g_strdup (output->vendor);
|
ret = g_strdup (vendor_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free (inches);
|
||||||
|
g_free (vendor_name);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user