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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
This commit is contained in:
parent
d561d300b6
commit
67eb60c19a
@ -700,6 +700,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,
|
||||
layout_mode,
|
||||
monitor,
|
||||
mode);
|
||||
|
||||
@ -1087,6 +1088,7 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
|
||||
GList *l;
|
||||
MetaMonitorsConfig *monitors_config;
|
||||
|
||||
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
|
||||
monitors = meta_monitor_manager_get_monitors (monitor_manager);
|
||||
monitor = monitors->data;
|
||||
modes = meta_monitor_get_modes (monitor);
|
||||
@ -1159,7 +1161,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,
|
||||
layout_mode,
|
||||
monitor, mode);
|
||||
best_scale = MAX (best_scale, scale);
|
||||
monitor_configs = g_list_prepend (monitor_configs, create_monitor_config (monitor, mode));
|
||||
}
|
||||
@ -1177,7 +1181,6 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
|
||||
};
|
||||
|
||||
logical_monitor_configs = g_list_append (NULL, logical_monitor_config);
|
||||
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
|
||||
monitors_config = meta_monitors_config_new (monitor_manager,
|
||||
logical_monitor_configs,
|
||||
layout_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))
|
||||
|
@ -638,9 +638,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;
|
||||
|
@ -241,9 +241,10 @@ struct _MetaMonitorManagerClass
|
||||
MetaCrtc *crtc,
|
||||
MetaMonitorTransform transform);
|
||||
|
||||
float (* calculate_monitor_mode_scale) (MetaMonitorManager *manager,
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode);
|
||||
float (* calculate_monitor_mode_scale) (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitorLayoutMode layout_mode,
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode);
|
||||
|
||||
float * (* calculate_supported_scales) (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitorLayoutMode layout_mode,
|
||||
@ -366,9 +367,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 ,
|
||||
|
@ -230,6 +230,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);
|
||||
}
|
||||
@ -432,14 +433,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);
|
||||
}
|
||||
@ -1562,6 +1565,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);
|
||||
|
||||
|
@ -1657,8 +1657,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;
|
||||
@ -1714,8 +1715,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);
|
||||
@ -1725,7 +1727,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
|
||||
|
@ -211,8 +211,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,
|
||||
|
@ -34,6 +34,7 @@
|
||||
* See also #MetaMonitorManagerXrandr for an implementation using XRandR.
|
||||
*/
|
||||
|
||||
#include "backends/meta-monitor.h"
|
||||
#include "config.h"
|
||||
|
||||
#include "backends/native/meta-monitor-manager-native.h"
|
||||
@ -571,20 +572,8 @@ meta_monitor_manager_native_is_transform_handled (MetaMonitorManager *manager,
|
||||
transform);
|
||||
}
|
||||
|
||||
static float
|
||||
meta_monitor_manager_native_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_native_calculate_supported_scales (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitorLayoutMode layout_mode,
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode,
|
||||
int *n_supported_scales)
|
||||
static MetaMonitorScalesConstraint
|
||||
get_monitor_scale_constraints_from_layout_mode (MetaLogicalMonitorLayoutMode layout_mode)
|
||||
{
|
||||
MetaMonitorScalesConstraint constraints =
|
||||
META_MONITOR_SCALES_CONSTRAINT_NONE;
|
||||
@ -598,6 +587,31 @@ meta_monitor_manager_native_calculate_supported_scales (MetaMonitorManager
|
||||
break;
|
||||
}
|
||||
|
||||
return constraints;
|
||||
}
|
||||
|
||||
static float
|
||||
meta_monitor_manager_native_calculate_monitor_mode_scale (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitorLayoutMode layout_mode,
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode)
|
||||
{
|
||||
MetaMonitorScalesConstraint constraints =
|
||||
get_monitor_scale_constraints_from_layout_mode (layout_mode);
|
||||
|
||||
return meta_monitor_calculate_mode_scale (monitor, monitor_mode, constraints);
|
||||
}
|
||||
|
||||
static float *
|
||||
meta_monitor_manager_native_calculate_supported_scales (MetaMonitorManager *manager,
|
||||
MetaLogicalMonitorLayoutMode layout_mode,
|
||||
MetaMonitor *monitor,
|
||||
MetaMonitorMode *monitor_mode,
|
||||
int *n_supported_scales)
|
||||
{
|
||||
MetaMonitorScalesConstraint constraints =
|
||||
get_monitor_scale_constraints_from_layout_mode (layout_mode);
|
||||
|
||||
return meta_monitor_calculate_supported_scales (monitor, monitor_mode,
|
||||
constraints,
|
||||
n_supported_scales);
|
||||
|
@ -880,11 +880,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
|
||||
|
@ -291,9 +291,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;
|
||||
|
Loading…
Reference in New Issue
Block a user