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 every head.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/407

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
This commit is contained in:
Marco Trevisan (Treviño) 2018-11-29 23:51:55 -05:00
parent 1ab79c79a5
commit 4ca5a97ea8

View File

@ -119,9 +119,6 @@ static gboolean
meta_monitor_manager_is_config_complete (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
static MetaMonitor *
meta_monitor_manager_get_active_monitor (MetaMonitorManager *manager);
static void
meta_monitor_manager_real_read_current_state (MetaMonitorManager *manager);
@ -245,20 +242,66 @@ 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.0;
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 && meta_monitor_is_active (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
@ -2800,12 +2843,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)