monitor-manager: Expose output_is_laptop() method

We currently duplicate the heuristics of whether an output is considered
a laptop or not. Avoid this by sharing a small helper method.

https://bugzilla.gnome.org/show_bug.cgi?id=765267
This commit is contained in:
Florian Müllner 2016-04-21 17:29:44 +02:00
parent ff312b6958
commit ab6c008e3e
3 changed files with 17 additions and 22 deletions

View File

@ -916,20 +916,6 @@ key_is_laptop (MetaOutputKey *key)
g_str_has_prefix (key->connector, "eDP");
}
static gboolean
output_is_laptop (MetaOutput *output)
{
/* FIXME: extend with better heuristics */
switch (output->connector_type)
{
case META_CONNECTOR_TYPE_eDP:
case META_CONNECTOR_TYPE_LVDS:
return TRUE;
default:
return FALSE;
}
}
static gboolean
laptop_display_is_on (MetaConfiguration *config)
{
@ -1092,7 +1078,7 @@ find_primary_output (MetaOutput *outputs,
for (i = 0; i < n_outputs; i++)
{
if (output_is_laptop (&outputs[i]))
if (meta_output_is_laptop (&outputs[i]))
return i;
}

View File

@ -398,6 +398,7 @@ void meta_monitor_manager_confirm_configuration (MetaMonitorManag
void meta_output_parse_edid (MetaOutput *output,
GBytes *edid);
gboolean meta_output_is_laptop (MetaOutput *output);
void meta_crtc_info_free (MetaCRTCInfo *info);
void meta_output_info_free (MetaOutputInfo *info);

View File

@ -511,14 +511,8 @@ make_display_name (MetaMonitorManager *manager,
g_autofree char *inches = NULL;
g_autofree char *vendor_name = NULL;
switch (output->connector_type)
{
case META_CONNECTOR_TYPE_LVDS:
case META_CONNECTOR_TYPE_eDP:
if (meta_output_is_laptop (output))
return g_strdup (_("Built-in display"));
default:
break;
}
if (output->width_mm > 0 && output->height_mm > 0)
{
@ -1464,6 +1458,20 @@ meta_output_parse_edid (MetaOutput *meta_output,
meta_output->serial = g_strdup ("unknown");
}
gboolean
meta_output_is_laptop (MetaOutput *output)
{
/* FIXME: extend with better heuristics */
switch (output->connector_type)
{
case META_CONNECTOR_TYPE_eDP:
case META_CONNECTOR_TYPE_LVDS:
return TRUE;
default:
return FALSE;
}
}
void
meta_monitor_manager_on_hotplug (MetaMonitorManager *manager)
{