Commit 0390a924 authored by Marco Trevisan's avatar Marco Trevisan 🎺

monitor-manager: Check if all monitor scales are matching in global mode

When global scaling is set we need to ensure that all the requested scale
configurations are matching, otherwise we'd end up in a mixed setup that
we don't support in this scenario.

Fixes GNOME/mutter#407
GNOME/mutter!336
parent f5dcca6b
......@@ -107,6 +107,10 @@ meta_monitor_manager_is_config_complete (MetaMonitorManager *manager,
static MetaMonitor *
meta_monitor_manager_get_active_monitor (MetaMonitorManager *manager);
static gboolean
is_global_scale_matching_in_config (MetaMonitorsConfig *config,
float scale);
MetaBackend *
meta_monitor_manager_get_backend (MetaMonitorManager *manager)
{
......@@ -1594,6 +1598,43 @@ meta_monitor_manager_is_scale_supported (MetaMonitorManager *manager,
return FALSE;
}
static gboolean
is_global_scale_matching_in_config (MetaMonitorsConfig *config,
float scale)
{
GList *l;
for (l = config->logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
if (logical_monitor_config->scale != scale)
return FALSE;
}
return TRUE;
}
static gboolean
meta_monitor_manager_is_scale_supported_for_config (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale)
{
if (meta_monitor_manager_is_scale_supported (manager, config->layout_mode,
monitor, monitor_mode, scale))
{
if (meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED)
return is_global_scale_matching_in_config (config, scale);
return TRUE;
}
return FALSE;
}
static gboolean
meta_monitor_manager_is_config_applicable (MetaMonitorManager *manager,
MetaMonitorsConfig *config,
......@@ -1632,11 +1673,11 @@ meta_monitor_manager_is_config_applicable (MetaMonitorManager *manager,
return FALSE;
}
if (!meta_monitor_manager_is_scale_supported (manager,
config->layout_mode,
monitor,
monitor_mode,
scale))
if (!meta_monitor_manager_is_scale_supported_for_config (manager,
config,
monitor,
monitor_mode,
scale))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Scale not supported by backend");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment