monitor: Determine preferred monitor mode

Determine the preferred monitor mode given what the preferred CRTC mode
is, and expose it via the API.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2016-12-17 22:32:05 +08:00
parent 5d9e2d8d2e
commit 2c32d94e1d
2 changed files with 16 additions and 0 deletions

View File

@ -37,6 +37,8 @@ typedef struct _MetaMonitorPrivate
GList *outputs; GList *outputs;
GList *modes; GList *modes;
MetaMonitorMode *preferred_mode;
/* /*
* The primary or first output for this monitor, 0 if we can't figure out. * The primary or first output for this monitor, 0 if we can't figure out.
* It can be matched to a winsys_id of a MetaOutput. * It can be matched to a winsys_id of a MetaOutput.
@ -187,6 +189,9 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
.crtc_mode = crtc_mode .crtc_mode = crtc_mode
}; };
if (crtc_mode == output->preferred_mode)
monitor_priv->preferred_mode = mode;
monitor_priv->modes = g_list_append (monitor_priv->modes, mode); monitor_priv->modes = g_list_append (monitor_priv->modes, mode);
} }
} }
@ -365,6 +370,7 @@ meta_monitor_tiled_generate_modes (MetaMonitorTiled *monitor_tiled)
} }
monitor_priv->modes = g_list_append (monitor_priv->modes, mode); monitor_priv->modes = g_list_append (monitor_priv->modes, mode);
monitor_priv->preferred_mode = mode;
/* TODO: Add single tile modes */ /* TODO: Add single tile modes */
} }
@ -446,6 +452,14 @@ meta_monitor_mode_free (MetaMonitorMode *monitor_mode)
g_free (monitor_mode); g_free (monitor_mode);
} }
MetaMonitorMode *
meta_monitor_get_preferred_mode (MetaMonitor *monitor)
{
MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
return priv->preferred_mode;
}
GList * GList *
meta_monitor_get_modes (MetaMonitor *monitor) meta_monitor_get_modes (MetaMonitor *monitor)
{ {

View File

@ -96,6 +96,8 @@ const char * meta_monitor_get_product (MetaMonitor *monitor);
uint32_t meta_monitor_tiled_get_tile_group_id (MetaMonitorTiled *monitor_tiled); uint32_t meta_monitor_tiled_get_tile_group_id (MetaMonitorTiled *monitor_tiled);
MetaMonitorMode * meta_monitor_get_preferred_mode (MetaMonitor *monitor);
GList * meta_monitor_get_modes (MetaMonitor *monitor); GList * meta_monitor_get_modes (MetaMonitor *monitor);
MetaMonitorModeSpec * meta_monitor_mode_get_spec (MetaMonitorMode *monitor_mode); MetaMonitorModeSpec * meta_monitor_mode_get_spec (MetaMonitorMode *monitor_mode);