[mutter] monitor-manager: Pass the Logical mode when computing the monitor scale
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Pass the Logical mode when computing the monitor scale
- Date: Thu, 22 Jul 2021 14:14:13 +0000 (UTC)
commit 67eb60c19a93d8399a691e3788b4c00279825d94
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sat Jun 10 10:10:57 2017 -0400
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>
src/backends/meta-monitor-config-manager.c | 7 ++--
src/backends/meta-monitor-config-migration.c | 15 ++++----
src/backends/meta-monitor-manager-dummy.c | 7 ++--
src/backends/meta-monitor-manager-private.h | 14 ++++----
src/backends/meta-monitor-manager.c | 10 ++++--
src/backends/meta-monitor.c | 12 ++++---
src/backends/meta-monitor.h | 5 +--
src/backends/native/meta-monitor-manager-native.c | 42 +++++++++++++++--------
src/backends/x11/meta-monitor-manager-xrandr.c | 12 ++++---
src/tests/meta-monitor-manager-test.c | 7 ++--
10 files changed, 83 insertions(+), 48 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index 0253e072ff..8b0b9f9b52 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -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,
diff --git a/src/backends/meta-monitor-config-migration.c b/src/backends/meta-monitor-config-migration.c
index d619dc4336..69c426cd73 100644
--- a/src/backends/meta-monitor-config-migration.c
+++ b/src/backends/meta-monitor-config-migration.c
@@ -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))
diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c
index d08fb022bd..66d15bda05 100644
--- a/src/backends/meta-monitor-manager-dummy.c
+++ b/src/backends/meta-monitor-manager-dummy.c
@@ -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;
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 60c1e90821..a05a7231e1 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -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 ,
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index e6d50bd999..1e08f3a824 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -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);
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index e02f8ed459..41f30eeb3c 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -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
diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h
index 341657ae3c..c1b62806e2 100644
--- a/src/backends/meta-monitor.h
+++ b/src/backends/meta-monitor.h
@@ -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,
diff --git a/src/backends/native/meta-monitor-manager-native.c
b/src/backends/native/meta-monitor-manager-native.c
index fd5e7784ff..2d598af12b 100644
--- a/src/backends/native/meta-monitor-manager-native.c
+++ b/src/backends/native/meta-monitor-manager-native.c
@@ -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);
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index 489a9b4241..adf1960791 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -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
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index e3b4f46cf5..efff2361cd 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]