From 0ac2eba4d38af2edcd8eb2f6b421548f3b2362a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 21 Mar 2017 14:29:32 +0800 Subject: [PATCH] DisplayConfig: Add logical monitor transforms Add the transform as a logical monitor parameter, both when getting the current state and applying a new configuration. The transform is defined to be identical to MetaMonitorTransform. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-monitor-manager.c | 43 ++++++++++++++++++-------- src/org.gnome.Mutter.DisplayConfig.xml | 16 ++++++++-- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index fcdff8fe9..31fb67864 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1304,7 +1304,7 @@ meta_monitor_manager_legacy_handle_apply_configuration (MetaDBusDisplayConfig * #define MONITORS_FORMAT "a" MONITOR_FORMAT #define LOGICAL_MONITOR_MONITORS_FORMAT "a" MONITOR_SPEC_FORMAT -#define LOGICAL_MONITOR_FORMAT "(iidb" LOGICAL_MONITOR_MONITORS_FORMAT "a{sv})" +#define LOGICAL_MONITOR_FORMAT "(iidub" LOGICAL_MONITOR_MONITORS_FORMAT "a{sv})" #define LOGICAL_MONITORS_FORMAT "a" LOGICAL_MONITOR_FORMAT static gboolean @@ -1422,6 +1422,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton, logical_monitor->rect.x, logical_monitor->rect.y, (double) logical_monitor->scale, + logical_monitor->transform, logical_monitor->is_primary, &logical_monitor_monitors_builder, NULL); @@ -1583,7 +1584,7 @@ find_monitor_spec (MetaMonitorManager *manager, #define MONITOR_CONFIG_FORMAT "(s" MONITOR_MODE_SPEC_FORMAT "a{sv})" #define MONITOR_CONFIGS_FORMAT "a" MONITOR_CONFIG_FORMAT -#define LOGICAL_MONITOR_CONFIG_FORMAT "(iidb" MONITOR_CONFIGS_FORMAT ")" +#define LOGICAL_MONITOR_CONFIG_FORMAT "(iidub" MONITOR_CONFIGS_FORMAT ")" static MetaMonitorConfig * create_monitor_config_from_variant (MetaMonitorManager *manager, @@ -1647,13 +1648,15 @@ create_monitor_config_from_variant (MetaMonitorManager *manager, static gboolean derive_logical_monitor_size (GList *monitor_configs, - int *width, - int *height, + int *out_width, + int *out_height, double scale, + MetaMonitorTransform transform, MetaLogicalMonitorLayoutMode layout_mode, GError **error) { MetaMonitorConfig *monitor_config; + int width, height; if (!monitor_configs) { @@ -1664,19 +1667,31 @@ derive_logical_monitor_size (GList *monitor_configs, monitor_config = monitor_configs->data; + if (meta_monitor_transform_is_rotated (transform)) + { + width = monitor_config->mode_spec->height; + height = monitor_config->mode_spec->width; + } + else + { + width = monitor_config->mode_spec->width; + height = monitor_config->mode_spec->height; + } + switch (layout_mode) { case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL: - *width = monitor_config->mode_spec->width / scale; - *height = monitor_config->mode_spec->height / scale; - return TRUE; + width /= scale; + height /= scale; + break; case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL: - *width = monitor_config->mode_spec->width; - *height = monitor_config->mode_spec->height; - return TRUE; + break; } - g_assert_not_reached (); + *out_width = width; + *out_height = height; + + return TRUE; } static MetaLogicalMonitorConfig * @@ -1688,6 +1703,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager MetaLogicalMonitorConfig *logical_monitor_config; int x, y, width, height; double scale; + MetaMonitorTransform transform; gboolean is_primary; GVariantIter *monitor_configs_iter; GList *monitor_configs = NULL; @@ -1696,6 +1712,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager &x, &y, &scale, + &transform, &is_primary, &monitor_configs_iter); @@ -1725,7 +1742,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager g_variant_iter_free (monitor_configs_iter); if (!derive_logical_monitor_size (monitor_configs, &width, &height, - scale, layout_mode, error)) + scale, transform, layout_mode, error)) goto err; logical_monitor_config = g_new0 (MetaLogicalMonitorConfig, 1); @@ -1736,7 +1753,7 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager .width = width, .height = height }, - .transform = META_MONITOR_TRANSFORM_NORMAL, + .transform = transform, .scale = (int) scale, .is_primary = is_primary, .monitor_configs = monitor_configs diff --git a/src/org.gnome.Mutter.DisplayConfig.xml b/src/org.gnome.Mutter.DisplayConfig.xml index 74c1d27b6..961ed0306 100644 --- a/src/org.gnome.Mutter.DisplayConfig.xml +++ b/src/org.gnome.Mutter.DisplayConfig.xml @@ -342,6 +342,7 @@ * i x: x position * i y: y position * d scale: scale + * u transform: transform (see below) * b primary: true if this is the primary logical monitor * a(sss) monitors: monitors displaying this logical monitor * connector: name of the connector (e.g. DP-1, eDP-1 etc) @@ -350,6 +351,16 @@ * serial: product serial * a{sv} properties: possibly other properties + Posisble transform values: + 0: normal + 1: 90° + 2: 180° + 3: 270° + 4: flipped + 5: 90° flipped + 6: 180° flipped + 7: 270° flipped + @supported_scales is an ordered list of floating point numbers representing scale factors of logical monitors supported by the display server. @@ -387,7 +398,7 @@ - + @@ -412,6 +423,7 @@ * i: layout x position * i: layout y position * d: scale + * u: transform (see GetCurrentState) * b primary: true if this is the primary logical monitor * a(siida{sv}): a list of monitors, each consisting of: * s: connector @@ -432,7 +444,7 @@ - +