Commit 0472a6f5 authored by Marco Trevisan's avatar Marco Trevisan 🎺

monitor-manager: Only derive global scales supported by all monitors

When deriving the global scale from current monitor, we were just checking the
supported value by the primary monitor, without considering weather the current
scale was supported by other monitors.

Resolve this, by checking if the picked global scale is valid for all active
monitors, and if it's not the case, use a fallback strategy by just picking the
maximum scale level supported by everyone.

Fixes GNOME/mutter#407
GNOME/mutter!336
parent 3b83459d
......@@ -104,9 +104,6 @@ static gboolean
meta_monitor_manager_is_config_complete (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
static MetaMonitor *
meta_monitor_manager_get_active_monitor (MetaMonitorManager *manager);
static gboolean
is_global_scale_matching_in_config (MetaMonitorsConfig *config,
float scale);
......@@ -224,20 +221,65 @@ calculate_monitor_scale (MetaMonitorManager *manager,
monitor_mode);
}
static gboolean
meta_monitor_manager_is_scale_supported_by_other_monitors (MetaMonitorManager *manager,
MetaMonitor *not_this_one,
float scale)
{
GList *l;
for (l = manager->monitors; l; l = l->next)
{
MetaMonitor *monitor = l->data;
MetaMonitorMode *mode;
if (monitor == not_this_one || !meta_monitor_is_active (monitor))
continue;
mode = meta_monitor_get_current_mode (monitor);
if (!meta_monitor_manager_is_scale_supported (manager, manager->layout_mode,
monitor, mode, scale))
return FALSE;
}
return TRUE;
}
static float
derive_calculated_global_scale (MetaMonitorManager *manager)
{
MetaMonitor *monitor = NULL;
float scale;
GList *l;
scale = 1.0f;
monitor = meta_monitor_manager_get_primary_monitor (manager);
if (!monitor || !meta_monitor_is_active (monitor))
monitor = meta_monitor_manager_get_active_monitor (manager);
if (monitor)
{
scale = calculate_monitor_scale (manager, monitor);
if (meta_monitor_manager_is_scale_supported_by_other_monitors (manager,
monitor,
scale))
return scale;
}
if (!monitor)
return 1.0;
for (l = manager->monitors; l; l = l->next)
{
MetaMonitor *other_monitor = l->data;
float monitor_scale;
return calculate_monitor_scale (manager, monitor);
if (other_monitor == monitor || !meta_monitor_is_active (other_monitor))
continue;
monitor_scale = calculate_monitor_scale (manager, other_monitor);
if (meta_monitor_manager_is_scale_supported_by_other_monitors (manager,
other_monitor,
monitor_scale))
scale = MAX (scale, monitor_scale);
}
return scale;
}
static float
......@@ -2548,12 +2590,6 @@ meta_monitor_manager_get_laptop_panel (MetaMonitorManager *manager)
return find_monitor (manager, meta_monitor_is_laptop_panel);
}
static MetaMonitor *
meta_monitor_manager_get_active_monitor (MetaMonitorManager *manager)
{
return find_monitor (manager, meta_monitor_is_active);
}
MetaMonitor *
meta_monitor_manager_get_monitor_from_connector (MetaMonitorManager *manager,
const char *connector)
......
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