From b2ba653dd9d3d08eb1c8906e31ee512f83177569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 23 Jun 2022 12:41:22 +0200 Subject: [PATCH] monitor-config-manager: Put logical monitor size scaling into helper Part-of: --- src/backends/meta-monitor-config-manager.c | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c index da3f1dd54..eafc6c6b6 100644 --- a/src/backends/meta-monitor-config-manager.c +++ b/src/backends/meta-monitor-config-manager.c @@ -716,6 +716,29 @@ get_monitor_transform (MetaMonitorManager *monitor_manager, return meta_monitor_transform_from_orientation (orientation); } +static void +scale_logical_monitor_width (MetaLogicalMonitorLayoutMode layout_mode, + float scale, + int mode_width, + int mode_height, + int *width, + int *height) +{ + switch (layout_mode) + { + case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL: + *width = (int) roundf (mode_width / scale); + *height = (int) roundf (mode_height / scale); + return; + case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL: + *width = mode_width; + *height = mode_height; + return; + } + + g_assert_not_reached (); +} + static MetaLogicalMonitorConfig * create_preferred_logical_monitor_config (MetaMonitorManager *monitor_manager, MetaMonitor *monitor, @@ -732,16 +755,8 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma mode = meta_monitor_get_preferred_mode (monitor); meta_monitor_mode_get_resolution (mode, &width, &height); - - switch (layout_mode) - { - case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL: - width = (int) roundf (width / scale); - height = (int) roundf (height / scale); - break; - case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL: - break; - } + scale_logical_monitor_width (layout_mode, scale, + width, height, &width, &height); monitor_config = create_monitor_config (monitor, mode);