From ee32ca3efe7403179bd741238675bfacf086e054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 19 Jan 2017 17:26:52 +0800 Subject: [PATCH] monitor-store: Support configuring logical monitor scale Add support to configure the logical monitor scale. With this, it becomes possible to override the automatically calculated scaling number per logical monitor. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-monitor-config-store.c | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-monitor-config-store.c b/src/backends/meta-monitor-config-store.c index c290d2dcf..4ce8dbbcf 100644 --- a/src/backends/meta-monitor-config-store.c +++ b/src/backends/meta-monitor-config-store.c @@ -37,6 +37,7 @@ * * 0 * 0 + * 1 * * * LVDS1 @@ -94,6 +95,7 @@ typedef enum STATE_LOGICAL_MONITOR_Y, STATE_LOGICAL_MONITOR_PRIMARY, STATE_LOGICAL_MONITOR_PRESENTATION, + STATE_LOGICAL_MONITOR_SCALE, STATE_MONITOR, STATE_MONITOR_SPEC, STATE_MONITOR_SPEC_CONNECTOR, @@ -206,6 +208,10 @@ handle_start_element (GMarkupParseContext *context, { parser->state = STATE_LOGICAL_MONITOR_Y; } + else if (g_str_equal (element_name, "scale")) + { + parser->state = STATE_LOGICAL_MONITOR_SCALE; + } else if (g_str_equal (element_name, "primary")) { parser->state = STATE_LOGICAL_MONITOR_PRIMARY; @@ -232,6 +238,7 @@ handle_start_element (GMarkupParseContext *context, case STATE_LOGICAL_MONITOR_X: case STATE_LOGICAL_MONITOR_Y: + case STATE_LOGICAL_MONITOR_SCALE: case STATE_LOGICAL_MONITOR_PRIMARY: case STATE_LOGICAL_MONITOR_PRESENTATION: { @@ -533,6 +540,7 @@ handle_end_element (GMarkupParseContext *context, { case STATE_LOGICAL_MONITOR_X: case STATE_LOGICAL_MONITOR_Y: + case STATE_LOGICAL_MONITOR_SCALE: case STATE_LOGICAL_MONITOR_PRIMARY: case STATE_LOGICAL_MONITOR_PRESENTATION: { @@ -622,7 +630,8 @@ handle_end_element (GMarkupParseContext *context, g_assert (g_str_equal (element_name, "logicalmonitor")); - logical_monitor_config->scale = 1; + if (logical_monitor_config->scale == 0) + logical_monitor_config->scale = 1; if (!verify_logical_monitor_config (logical_monitor_config, error)) return; @@ -834,6 +843,23 @@ handle_text (GMarkupParseContext *context, return; } + case STATE_LOGICAL_MONITOR_SCALE: + { + if (!read_int (text, text_len, + &parser->current_logical_monitor_config->scale, error)) + return; + + if (parser->current_logical_monitor_config->scale <= 0) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Logical monitor scale '%d' invalid", + parser->current_logical_monitor_config->scale); + return; + } + + return; + } + case STATE_LOGICAL_MONITOR_PRIMARY: { read_bool (text, text_len,