Commit 4f09b250 authored by Marco Trevisan's avatar Marco Trevisan 🎺

monitor-manager: Pass the Logical mode when computing the monitor scale

In order to compute proper default scaling value we need to know if the
fractional scaling is enabled or not and thus if we're using a logical
mode or not.

GNOME/mutter!336
parent 056c45fe
......@@ -613,6 +613,7 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
scale = primary_logical_monitor_config->scale;
else
scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
monitor_manager->layout_mode,
monitor,
mode);
......@@ -988,7 +989,9 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
if (!mode)
continue;
scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager, monitor, mode);
scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
monitor_manager->layout_mode,
monitor, mode);
best_scale = MAX (best_scale, scale);
monitor_configs = g_list_prepend (monitor_configs, create_monitor_config (monitor, mode));
}
......
......@@ -1190,6 +1190,9 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
MetaMonitorConfigStore *config_store =
meta_monitor_config_manager_get_store (config_manager);
GList *l;
MetaLogicalMonitorLayoutMode layout_mode;
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
for (l = config->logical_monitor_configs; l; l = l->next)
{
......@@ -1199,7 +1202,6 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
MetaMonitor *monitor;
MetaMonitorModeSpec *monitor_mode_spec;
MetaMonitorMode *monitor_mode;
float scale;
monitor_config = logical_monitor_config->monitor_configs->data;
monitor_spec = monitor_config->monitor_spec;
......@@ -1215,13 +1217,14 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
return FALSE;
}
scale = meta_monitor_calculate_mode_scale (monitor, monitor_mode);
logical_monitor_config->scale = scale;
logical_monitor_config->scale =
meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
layout_mode,
monitor,
monitor_mode);
}
config->layout_mode =
meta_monitor_manager_get_default_layout_mode (monitor_manager);
config->layout_mode = layout_mode;
config->flags &= ~META_MONITORS_CONFIG_FLAG_MIGRATED;
if (!meta_verify_monitors_config (config, monitor_manager, error))
......
......@@ -680,9 +680,10 @@ meta_monitor_manager_dummy_is_transform_handled (MetaMonitorManager *manager,
}
static float
meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
MetaOutput *output;
MetaOutputDummy *output_dummy;
......
......@@ -229,9 +229,10 @@ struct _MetaMonitorManagerClass
MetaCrtc *,
MetaMonitorTransform);
float (*calculate_monitor_mode_scale) (MetaMonitorManager *,
MetaMonitor *,
MetaMonitorMode *);
float (*calculate_monitor_mode_scale) (MetaMonitorManager *,
MetaLogicalMonitorLayoutMode ,
MetaMonitor *,
MetaMonitorMode *);
float * (*calculate_supported_scales) (MetaMonitorManager *,
MetaLogicalMonitorLayoutMode ,
......@@ -350,9 +351,10 @@ void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManage
gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager);
float meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float * meta_monitor_manager_calculate_supported_scales (MetaMonitorManager *,
MetaLogicalMonitorLayoutMode ,
......
......@@ -209,6 +209,7 @@ calculate_monitor_scale (MetaMonitorManager *manager,
monitor_mode = meta_monitor_get_current_mode (monitor);
return meta_monitor_manager_calculate_monitor_mode_scale (manager,
manager->layout_mode,
monitor,
monitor_mode);
}
......@@ -387,14 +388,16 @@ meta_monitor_manager_is_headless (MetaMonitorManager *manager)
}
float
meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
MetaMonitorManagerClass *manager_class =
META_MONITOR_MANAGER_GET_CLASS (manager);
return manager_class->calculate_monitor_mode_scale (manager,
layout_mode,
monitor,
monitor_mode);
}
......@@ -1389,6 +1392,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
preferred_scale =
meta_monitor_manager_calculate_monitor_mode_scale (manager,
manager->layout_mode,
monitor,
monitor_mode);
......
......@@ -1490,8 +1490,9 @@ meta_monitor_calculate_crtc_pos (MetaMonitor *monitor,
#define SMALLEST_4K_WIDTH 3656
static float
calculate_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
calculate_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints)
{
int resolution_width, resolution_height;
int width_mm, height_mm;
......@@ -1547,8 +1548,9 @@ out:
}
float
meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints)
{
MetaBackend *backend = meta_get_backend ();
MetaSettings *settings = meta_backend_get_settings (backend);
......@@ -1558,7 +1560,7 @@ meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
&global_scaling_factor))
return global_scaling_factor;
return calculate_scale (monitor, monitor_mode);
return calculate_scale (monitor, monitor_mode, constraints);
}
static gboolean
......
......@@ -222,8 +222,9 @@ void meta_monitor_calculate_crtc_pos (MetaMonitor *monitor,
int *out_y);
META_EXPORT_TEST
float meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints);
META_EXPORT_TEST
float * meta_monitor_calculate_supported_scales (MetaMonitor *monitor,
......
......@@ -503,20 +503,8 @@ meta_monitor_manager_kms_is_transform_handled (MetaMonitorManager *manager,
return meta_crtc_kms_is_transform_handled (crtc, transform);
}
static float
meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
return meta_monitor_calculate_mode_scale (monitor, monitor_mode);
}
static float *
meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
int *n_supported_scales)
static MetaMonitorScalesConstraint
get_monitor_scale_constraints_per_layout_mode (MetaLogicalMonitorLayoutMode layout_mode)
{
MetaMonitorScalesConstraint constraints =
META_MONITOR_SCALES_CONSTRAINT_NONE;
......@@ -530,6 +518,31 @@ meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager
break;
}
return constraints;
}
static float
meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
MetaMonitorScalesConstraint constraints =
get_monitor_scale_constraints_per_layout_mode (layout_mode);
return meta_monitor_calculate_mode_scale (monitor, monitor_mode, constraints);
}
static float *
meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
int *n_supported_scales)
{
MetaMonitorScalesConstraint constraints =
get_monitor_scale_constraints_per_layout_mode (layout_mode);
return meta_monitor_calculate_supported_scales (monitor, monitor_mode,
constraints,
n_supported_scales);
......
......@@ -850,11 +850,15 @@ meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager,
}
static float
meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
return meta_monitor_calculate_mode_scale (monitor, monitor_mode);
MetaMonitorScalesConstraint constraints;
constraints = META_MONITOR_SCALES_CONSTRAINT_NO_FRAC;
return meta_monitor_calculate_mode_scale (monitor, monitor_mode, constraints);
}
static void
......
......@@ -356,9 +356,10 @@ meta_monitor_manager_test_is_transform_handled (MetaMonitorManager *manager,
}
static float
meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{
MetaOutput *output;
MetaOutputTest *output_test;
......
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