From 753e9c65a18d051bf8252b39ce68c614b0bc236e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 19 Jan 2017 17:23:48 +0800 Subject: [PATCH] meta-monitor-config: Pass logical monitor scale via config The default (calculated) scale is derived from the output, but ultimately set via the monitor scale. This will enable config files to override the scale. Yet to be done is handling when a scale is not supported by a backend (i.e. the X11 backend). https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-logical-monitor.c | 2 +- src/backends/meta-monitor-config-manager.c | 4 ++++ src/backends/meta-monitor-config-manager.h | 1 + src/backends/meta-monitor-config-store.c | 10 ++++++++++ src/backends/meta-monitor.c | 10 ++++++++++ src/backends/meta-monitor.h | 2 ++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-logical-monitor.c b/src/backends/meta-logical-monitor.c index e400e0eae..905671898 100644 --- a/src/backends/meta-logical-monitor.c +++ b/src/backends/meta-logical-monitor.c @@ -78,7 +78,7 @@ meta_logical_monitor_new (MetaMonitorManager *monitor_manager, logical_monitor->number = monitor_number; logical_monitor->winsys_id = main_output->winsys_id; - logical_monitor->scale = main_output->scale; + logical_monitor->scale = logical_monitor_config->scale, logical_monitor->in_fullscreen = -1; logical_monitor->rect = logical_monitor_config->layout; diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c index 6eabb8037..824d3f680 100644 --- a/src/backends/meta-monitor-config-manager.c +++ b/src/backends/meta-monitor-config-manager.c @@ -467,11 +467,14 @@ create_preferred_logical_monitor_config (MetaMonitor *monitor, { MetaMonitorMode *mode; int width, height; + int scale; MetaMonitorConfig *monitor_config; MetaLogicalMonitorConfig *logical_monitor_config; mode = meta_monitor_get_preferred_mode (monitor); meta_monitor_mode_get_resolution (mode, &width, &height); + scale = meta_monitor_get_calculated_scale (monitor); + monitor_config = create_monitor_config (monitor, mode); logical_monitor_config = g_new0 (MetaLogicalMonitorConfig, 1); @@ -482,6 +485,7 @@ create_preferred_logical_monitor_config (MetaMonitor *monitor, .width = width, .height = height }, + .scale = scale, .monitor_configs = g_list_append (NULL, monitor_config) }; diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h index 2c5d5ba67..418e7a257 100644 --- a/src/backends/meta-monitor-config-manager.h +++ b/src/backends/meta-monitor-config-manager.h @@ -40,6 +40,7 @@ typedef struct _MetaLogicalMonitorConfig { MetaRectangle layout; GList *monitor_configs; + int scale; gboolean is_primary; gboolean is_presentation; } MetaLogicalMonitorConfig; diff --git a/src/backends/meta-monitor-config-store.c b/src/backends/meta-monitor-config-store.c index 18828c05f..c290d2dcf 100644 --- a/src/backends/meta-monitor-config-store.c +++ b/src/backends/meta-monitor-config-store.c @@ -405,6 +405,14 @@ static gboolean verify_logical_monitor_config (MetaLogicalMonitorConfig *logical_monitor_config, GError **error) { + if (logical_monitor_config->scale < 1) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Invalid logical monitor config scale %d", + logical_monitor_config->scale); + return FALSE; + } + if (logical_monitor_config->layout.x < 0 || logical_monitor_config->layout.y < 0) { @@ -614,6 +622,8 @@ handle_end_element (GMarkupParseContext *context, g_assert (g_str_equal (element_name, "logicalmonitor")); + logical_monitor_config->scale = 1; + if (!verify_logical_monitor_config (logical_monitor_config, error)) return; diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index f6eb2278b..8604ba123 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -196,6 +196,16 @@ meta_monitor_is_underscanning (MetaMonitor *monitor) return output->is_underscanning; } +int +meta_monitor_get_calculated_scale (MetaMonitor *monitor) +{ + MetaOutput *output; + + output = meta_monitor_get_main_output (monitor); + + return output->scale; +} + gboolean meta_monitor_is_laptop_panel (MetaMonitor *monitor) { diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h index 46abe78c7..0ebdb55f7 100644 --- a/src/backends/meta-monitor.h +++ b/src/backends/meta-monitor.h @@ -97,6 +97,8 @@ gboolean meta_monitor_is_underscanning (MetaMonitor *monitor); gboolean meta_monitor_is_laptop_panel (MetaMonitor *monitor); +int meta_monitor_get_calculated_scale (MetaMonitor *monitor); + GList * meta_monitor_get_outputs (MetaMonitor *monitor); void meta_monitor_get_current_resolution (MetaMonitor *monitor,