[mutter] monitor-config-manager: Computer monitor scale in caller
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-config-manager: Computer monitor scale in caller
- Date: Wed, 4 Aug 2021 14:30:25 +0000 (UTC)
commit e8b84441a413e6dca7f5a914fcb209d5fc522df4
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed Apr 3 16:11:21 2019 +0200
monitor-config-manager: Computer monitor scale in caller
Compute the monitor scaling in a separated function using the primary
monitor (not its config) and pass it to the creation function instead.
This will allow removing the special logic for the primary monitor.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
src/backends/meta-monitor-config-manager.c | 46 +++++++++++++++++++-----------
1 file changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index 46fb050aa0..a05f1425ab 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -726,12 +726,11 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
MetaMonitor *monitor,
int x,
int y,
- MetaLogicalMonitorConfig *primary_logical_monitor_config,
+ float scale,
MetaLogicalMonitorLayoutMode layout_mode)
{
MetaMonitorMode *mode;
int width, height;
- float scale;
MetaMonitorTransform transform;
MetaMonitorConfig *monitor_config;
MetaLogicalMonitorConfig *logical_monitor_config;
@@ -739,16 +738,6 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
mode = meta_monitor_get_preferred_mode (monitor);
meta_monitor_mode_get_resolution (mode, &width, &height);
- if ((meta_monitor_manager_get_capabilities (monitor_manager) &
- META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED) &&
- primary_logical_monitor_config)
- scale = primary_logical_monitor_config->scale;
- else
- scale = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
- layout_mode,
- monitor,
- mode);
-
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
@@ -785,6 +774,29 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
return logical_monitor_config;
}
+static float
+compute_scale_for_monitor (MetaMonitorManager *monitor_manager,
+ MetaMonitor *monitor,
+ MetaMonitor *primary_monitor)
+{
+ MetaMonitor *target_monitor = monitor;
+ MetaLogicalMonitorLayoutMode layout_mode;
+ MetaMonitorMode *monitor_mode;
+
+ if ((meta_monitor_manager_get_capabilities (monitor_manager) &
+ META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED) &&
+ primary_monitor)
+ target_monitor = primary_monitor;
+
+ layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
+ monitor_mode = meta_monitor_get_preferred_mode (target_monitor);
+
+ return meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
+ layout_mode,
+ target_monitor,
+ monitor_mode);
+}
+
typedef enum _MonitorPositioningMode
{
MONITOR_POSITIONING_LINEAR,
@@ -840,6 +852,7 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
MetaLogicalMonitorLayoutMode layout_mode;
MetaLogicalMonitorConfig *primary_logical_monitor_config;
gboolean has_suggested_position;
+ float scale;
GList *l;
int x, y;
@@ -862,11 +875,11 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
break;
}
+ scale = compute_scale_for_monitor (monitor_manager, primary_monitor, NULL);
primary_logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
primary_monitor,
- x, y,
- NULL,
+ x, y, scale,
layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
logical_monitor_configs = g_list_append (NULL,
@@ -895,11 +908,12 @@ create_monitors_config (MetaMonitorConfigManager *config_manager,
break;
}
+ scale = compute_scale_for_monitor (monitor_manager, monitor,
+ primary_monitor);
logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
monitor,
- x, y,
- primary_logical_monitor_config,
+ x, y, scale,
layout_mode);
logical_monitor_configs = g_list_append (logical_monitor_configs,
logical_monitor_config);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]