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:
Marco Trevisan (Treviño) 2017-06-10 10:10:57 -04:00
parent d561d300b6
commit 67eb60c19a
10 changed files with 83 additions and 48 deletions

View File

@ -700,6 +700,7 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
scale = primary_logical_monitor_config->scale; scale = primary_logical_monitor_config->scale;
else else
scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager, scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
layout_mode,
monitor, monitor,
mode); mode);
@ -1087,6 +1088,7 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
GList *l; GList *l;
MetaMonitorsConfig *monitors_config; MetaMonitorsConfig *monitors_config;
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
monitors = meta_monitor_manager_get_monitors (monitor_manager); monitors = meta_monitor_manager_get_monitors (monitor_manager);
monitor = monitors->data; monitor = monitors->data;
modes = meta_monitor_get_modes (monitor); modes = meta_monitor_get_modes (monitor);
@ -1159,7 +1161,9 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
if (!mode) if (!mode)
continue; 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); best_scale = MAX (best_scale, scale);
monitor_configs = g_list_prepend (monitor_configs, create_monitor_config (monitor, mode)); 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); 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, monitors_config = meta_monitors_config_new (monitor_manager,
logical_monitor_configs, logical_monitor_configs,
layout_mode, layout_mode,

View File

@ -1190,6 +1190,9 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
MetaMonitorConfigStore *config_store = MetaMonitorConfigStore *config_store =
meta_monitor_config_manager_get_store (config_manager); meta_monitor_config_manager_get_store (config_manager);
GList *l; 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) for (l = config->logical_monitor_configs; l; l = l->next)
{ {
@ -1199,7 +1202,6 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
MetaMonitor *monitor; MetaMonitor *monitor;
MetaMonitorModeSpec *monitor_mode_spec; MetaMonitorModeSpec *monitor_mode_spec;
MetaMonitorMode *monitor_mode; MetaMonitorMode *monitor_mode;
float scale;
monitor_config = logical_monitor_config->monitor_configs->data; monitor_config = logical_monitor_config->monitor_configs->data;
monitor_spec = monitor_config->monitor_spec; monitor_spec = monitor_config->monitor_spec;
@ -1215,13 +1217,14 @@ meta_finish_monitors_config_migration (MetaMonitorManager *monitor_manager,
return FALSE; return FALSE;
} }
scale = meta_monitor_calculate_mode_scale (monitor, monitor_mode); logical_monitor_config->scale =
meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
logical_monitor_config->scale = scale; layout_mode,
monitor,
monitor_mode);
} }
config->layout_mode = config->layout_mode = layout_mode;
meta_monitor_manager_get_default_layout_mode (monitor_manager);
config->flags &= ~META_MONITORS_CONFIG_FLAG_MIGRATED; config->flags &= ~META_MONITORS_CONFIG_FLAG_MIGRATED;
if (!meta_verify_monitors_config (config, monitor_manager, error)) if (!meta_verify_monitors_config (config, monitor_manager, error))

View File

@ -638,9 +638,10 @@ meta_monitor_manager_dummy_is_transform_handled (MetaMonitorManager *manager,
} }
static float static float
meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *manager, meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_mode) MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{ {
MetaOutput *output; MetaOutput *output;
MetaOutputDummy *output_dummy; MetaOutputDummy *output_dummy;

View File

@ -241,9 +241,10 @@ struct _MetaMonitorManagerClass
MetaCrtc *crtc, MetaCrtc *crtc,
MetaMonitorTransform transform); MetaMonitorTransform transform);
float (* calculate_monitor_mode_scale) (MetaMonitorManager *manager, float (* calculate_monitor_mode_scale) (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_mode); MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float * (* calculate_supported_scales) (MetaMonitorManager *manager, float * (* calculate_supported_scales) (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode, MetaLogicalMonitorLayoutMode layout_mode,
@ -366,9 +367,10 @@ void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManage
gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager); gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager);
float meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager, float meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_mode); MetaMonitor *monitor,
MetaMonitorMode *monitor_mode);
float * meta_monitor_manager_calculate_supported_scales (MetaMonitorManager *, float * meta_monitor_manager_calculate_supported_scales (MetaMonitorManager *,
MetaLogicalMonitorLayoutMode , MetaLogicalMonitorLayoutMode ,

View File

@ -230,6 +230,7 @@ calculate_monitor_scale (MetaMonitorManager *manager,
monitor_mode = meta_monitor_get_current_mode (monitor); monitor_mode = meta_monitor_get_current_mode (monitor);
return meta_monitor_manager_calculate_monitor_mode_scale (manager, return meta_monitor_manager_calculate_monitor_mode_scale (manager,
manager->layout_mode,
monitor, monitor,
monitor_mode); monitor_mode);
} }
@ -432,14 +433,16 @@ meta_monitor_manager_is_headless (MetaMonitorManager *manager)
} }
float float
meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager, meta_monitor_manager_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_mode) MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{ {
MetaMonitorManagerClass *manager_class = MetaMonitorManagerClass *manager_class =
META_MONITOR_MANAGER_GET_CLASS (manager); META_MONITOR_MANAGER_GET_CLASS (manager);
return manager_class->calculate_monitor_mode_scale (manager, return manager_class->calculate_monitor_mode_scale (manager,
layout_mode,
monitor, monitor,
monitor_mode); monitor_mode);
} }
@ -1562,6 +1565,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
preferred_scale = preferred_scale =
meta_monitor_manager_calculate_monitor_mode_scale (manager, meta_monitor_manager_calculate_monitor_mode_scale (manager,
manager->layout_mode,
monitor, monitor,
monitor_mode); monitor_mode);

View File

@ -1657,8 +1657,9 @@ meta_monitor_calculate_crtc_pos (MetaMonitor *monitor,
#define SMALLEST_4K_WIDTH 3656 #define SMALLEST_4K_WIDTH 3656
static float static float
calculate_scale (MetaMonitor *monitor, calculate_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode) MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints)
{ {
int resolution_width, resolution_height; int resolution_width, resolution_height;
int width_mm, height_mm; int width_mm, height_mm;
@ -1714,8 +1715,9 @@ out:
} }
float float
meta_monitor_calculate_mode_scale (MetaMonitor *monitor, meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode) MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints)
{ {
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
MetaSettings *settings = meta_backend_get_settings (backend); MetaSettings *settings = meta_backend_get_settings (backend);
@ -1725,7 +1727,7 @@ meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
&global_scaling_factor)) &global_scaling_factor))
return global_scaling_factor; return global_scaling_factor;
return calculate_scale (monitor, monitor_mode); return calculate_scale (monitor, monitor_mode, constraints);
} }
static gboolean static gboolean

View File

@ -211,8 +211,9 @@ void meta_monitor_calculate_crtc_pos (MetaMonitor *monitor,
int *out_y); int *out_y);
META_EXPORT_TEST META_EXPORT_TEST
float meta_monitor_calculate_mode_scale (MetaMonitor *monitor, float meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
MetaMonitorMode *monitor_mode); MetaMonitorMode *monitor_mode,
MetaMonitorScalesConstraint constraints);
META_EXPORT_TEST META_EXPORT_TEST
float * meta_monitor_calculate_supported_scales (MetaMonitor *monitor, float * meta_monitor_calculate_supported_scales (MetaMonitor *monitor,

View File

@ -34,6 +34,7 @@
* See also #MetaMonitorManagerXrandr for an implementation using XRandR. * See also #MetaMonitorManagerXrandr for an implementation using XRandR.
*/ */
#include "backends/meta-monitor.h"
#include "config.h" #include "config.h"
#include "backends/native/meta-monitor-manager-native.h" #include "backends/native/meta-monitor-manager-native.h"
@ -571,20 +572,8 @@ meta_monitor_manager_native_is_transform_handled (MetaMonitorManager *manager,
transform); transform);
} }
static float static MetaMonitorScalesConstraint
meta_monitor_manager_native_calculate_monitor_mode_scale (MetaMonitorManager *manager, get_monitor_scale_constraints_from_layout_mode (MetaLogicalMonitorLayoutMode layout_mode)
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)
{ {
MetaMonitorScalesConstraint constraints = MetaMonitorScalesConstraint constraints =
META_MONITOR_SCALES_CONSTRAINT_NONE; META_MONITOR_SCALES_CONSTRAINT_NONE;
@ -598,6 +587,31 @@ meta_monitor_manager_native_calculate_supported_scales (MetaMonitorManager
break; 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, return meta_monitor_calculate_supported_scales (monitor, monitor_mode,
constraints, constraints,
n_supported_scales); n_supported_scales);

View File

@ -880,11 +880,15 @@ meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager,
} }
static float static float
meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *manager, meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_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 static void

View File

@ -291,9 +291,10 @@ meta_monitor_manager_test_is_transform_handled (MetaMonitorManager *manager,
} }
static float static float
meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *manager, meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *manager,
MetaMonitor *monitor, MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitorMode *monitor_mode) MetaMonitor *monitor,
MetaMonitorMode *monitor_mode)
{ {
MetaOutput *output; MetaOutput *output;
MetaOutputTest *output_test; MetaOutputTest *output_test;