mutter/inherit-xrandr-metamodes.patch

366 lines
16 KiB
Diff
Raw Normal View History

From 2fd3910c29d2af2a7c64b82f075cd3647d7e4bee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 18 Mar 2019 17:08:11 +0100
Subject: [PATCH 1/2] monitor-config-manager: Use current mode when deriving
current config
Instead of overriding the existing mode with the preferred mode of the monitor,
use the one already configured. Also use the MetaMonitor API for deriving the
position of the monitor in the screen coordinate space.
---
src/backends/meta-monitor-config-manager.c | 77 +++++++++++++---------
1 file changed, 47 insertions(+), 30 deletions(-)
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index c09edbe00..a3387aa0f 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -592,20 +592,19 @@ create_monitor_config (MetaMonitor *monitor,
}
static MetaLogicalMonitorConfig *
-create_preferred_logical_monitor_config (MetaMonitorManager *monitor_manager,
- MetaMonitor *monitor,
- int x,
- int y,
- MetaLogicalMonitorConfig *primary_logical_monitor_config,
- MetaLogicalMonitorLayoutMode layout_mode)
+create_logical_monitor_config (MetaMonitorManager *monitor_manager,
+ MetaMonitor *monitor,
+ MetaMonitorMode *mode,
+ int x,
+ int y,
+ MetaLogicalMonitorConfig *primary_logical_monitor_config,
+ MetaLogicalMonitorLayoutMode layout_mode)
{
- MetaMonitorMode *mode;
int width, height;
float scale;
MetaMonitorConfig *monitor_config;
MetaLogicalMonitorConfig *logical_monitor_config;
- mode = meta_monitor_get_preferred_mode (monitor);
meta_monitor_mode_get_resolution (mode, &width, &height);
if ((meta_monitor_manager_get_capabilities (monitor_manager) &
@@ -645,22 +644,40 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
}
static MetaLogicalMonitorConfig *
-create_logical_monitor_config_from_output (MetaMonitorManager *monitor_manager,
- MetaMonitor *monitor,
- MetaLogicalMonitorConfig *primary_logical_monitor_config,
- MetaLogicalMonitorLayoutMode layout_mode)
+create_preferred_logical_monitor_config (MetaMonitorManager *monitor_manager,
+ MetaMonitor *monitor,
+ int x,
+ int y,
+ MetaLogicalMonitorConfig *primary_logical_monitor_config,
+ MetaLogicalMonitorLayoutMode layout_mode)
{
- MetaOutput *output;
- MetaCrtc *crtc;
+ return create_logical_monitor_config (monitor_manager,
+ monitor,
+ meta_monitor_get_preferred_mode (monitor),
+ x, y,
+ primary_logical_monitor_config,
+ layout_mode);
+}
- output = meta_monitor_get_main_output (monitor);
- crtc = meta_output_get_assigned_crtc (output);
- return create_preferred_logical_monitor_config (monitor_manager,
- monitor,
- crtc->rect.x,
- crtc->rect.y,
- primary_logical_monitor_config,
- layout_mode);
+static MetaLogicalMonitorConfig *
+create_logical_monitor_config_from_monitor (MetaMonitorManager *monitor_manager,
+ MetaMonitor *monitor,
+ MetaLogicalMonitorConfig *primary_logical_monitor_config,
+ MetaLogicalMonitorLayoutMode layout_mode)
+{
+ MetaRectangle monitor_layout;
+ MetaMonitorMode *mode;
+
+ meta_monitor_derive_layout (monitor, &monitor_layout);
+ mode = meta_monitor_get_current_mode (monitor);
+
+ return create_logical_monitor_config (monitor_manager,
+ monitor,
+ mode,
+ monitor_layout.x,
+ monitor_layout.y,
+ primary_logical_monitor_config,
+ layout_mode);
}
MetaMonitorsConfig *
@@ -688,10 +705,10 @@ meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_man
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
primary_logical_monitor_config =
- create_logical_monitor_config_from_output (monitor_manager,
- primary_monitor,
- NULL,
- layout_mode);
+ create_logical_monitor_config_from_monitor (monitor_manager,
+ primary_monitor,
+ NULL,
+ layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
logical_monitor_configs = g_list_append (NULL,
@@ -710,10 +727,10 @@ meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_man
continue;
logical_monitor_config =
- create_logical_monitor_config_from_output (monitor_manager,
- monitor,
- primary_logical_monitor_config,
- layout_mode);
+ create_logical_monitor_config_from_monitor (monitor_manager,
+ monitor,
+ primary_logical_monitor_config,
+ layout_mode);
logical_monitor_configs = g_list_append (logical_monitor_configs,
logical_monitor_config);
--
2.21.0
From d8c34e4cd7e500567e72e0f219295d7c2162dcf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 18 Mar 2019 17:10:37 +0100
Subject: [PATCH 2/2] monitor-manager: Don't try to derive current config on
non-X11
This commit also reworks the initial config state reading some. Appart from
avoiding trying to inherit from backends where it doesn't make sense, it does
the following changes:
* Replace the name "initial" with "inherited", as the initial config in the
context of monitor management is the one used initialization. E.g. if there is
a applicable configuration in monitors.xml, the initial config is taken from
there.
* Don't make "_create_()" functions have side effects. Previously
meta_monitor_config_manager_create_initial() also set state on the config
manager object. Instead, add a meta_monitor_config_manager_ensure_inherited()
and meta_monitor_manager_get_inherited_config() function to make things more
explicit.
* Don't recreate "is-applicable" logic, just use the existing helper.
---
src/backends/meta-monitor-config-manager.c | 39 +++++++++++--------
src/backends/meta-monitor-config-manager.h | 5 +++
src/backends/meta-monitor-manager-private.h | 4 +-
src/backends/meta-monitor-manager.c | 32 ++++++++-------
.../x11/meta-monitor-manager-xrandr.c | 3 +-
5 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index a3387aa0f..bc1a39db8 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -42,7 +42,7 @@ struct _MetaMonitorConfigManager
MetaMonitorConfigStore *config_store;
MetaMonitorsConfig *current_config;
- MetaMonitorsConfig *initial_config;
+ MetaMonitorsConfig *inherited_config;
GQueue config_history;
};
@@ -680,11 +680,10 @@ create_logical_monitor_config_from_monitor (MetaMonitorManager *monito
layout_mode);
}
-MetaMonitorsConfig *
-meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_manager)
+static MetaMonitorsConfig *
+meta_monitor_config_manager_derive_current (MetaMonitorConfigManager *config_manager)
{
MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
- MetaMonitorsConfig *initial_config;
GList *logical_monitor_configs;
MetaMonitor *primary_monitor;
MetaLogicalMonitorLayoutMode layout_mode;
@@ -692,12 +691,6 @@ meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_man
GList *monitors;
GList *l;
- if (config_manager->initial_config != NULL)
- return g_object_ref (config_manager->initial_config);
-
- if (meta_monitor_config_store_get_config_count (config_manager->config_store) > 0)
- return NULL;
-
primary_monitor = find_primary_monitor (monitor_manager);
if (!primary_monitor || !meta_monitor_is_active (primary_monitor))
return NULL;
@@ -736,14 +729,26 @@ meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_man
logical_monitor_config);
}
- initial_config = meta_monitors_config_new (monitor_manager,
- logical_monitor_configs,
- layout_mode,
- META_MONITORS_CONFIG_FLAG_NONE);
+ return meta_monitors_config_new (monitor_manager,
+ logical_monitor_configs,
+ layout_mode,
+ META_MONITORS_CONFIG_FLAG_NONE);
+}
+
+void
+meta_monitor_config_manager_ensure_inherited_config (MetaMonitorConfigManager *config_manager)
+{
+ if (config_manager->inherited_config)
+ return;
- config_manager->initial_config = g_object_ref (initial_config);
+ config_manager->inherited_config =
+ meta_monitor_config_manager_derive_current (config_manager);
+}
- return initial_config;
+MetaMonitorsConfig *
+meta_monitor_config_manager_get_inherited_config (MetaMonitorConfigManager *config_manager)
+{
+ return config_manager->inherited_config;
}
MetaMonitorsConfig *
@@ -1282,7 +1287,7 @@ meta_monitor_config_manager_dispose (GObject *object)
META_MONITOR_CONFIG_MANAGER (object);
g_clear_object (&config_manager->current_config);
- g_clear_object (&config_manager->initial_config);
+ g_clear_object (&config_manager->inherited_config);
meta_monitor_config_manager_clear_history (config_manager);
G_OBJECT_CLASS (meta_monitor_config_manager_parent_class)->dispose (object);
diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h
index 409611bb0..bb847b96e 100644
--- a/src/backends/meta-monitor-config-manager.h
+++ b/src/backends/meta-monitor-config-manager.h
@@ -96,6 +96,11 @@ MetaMonitorsConfig * meta_monitor_config_manager_get_stored (MetaMonitorConfigMa
META_EXPORT_TEST
MetaMonitorsConfig * meta_monitor_config_manager_create_initial (MetaMonitorConfigManager *config_manager);
+
+void meta_monitor_config_manager_ensure_inherited_config (MetaMonitorConfigManager *config_manager);
+
+MetaMonitorsConfig * meta_monitor_config_manager_get_inherited_config (MetaMonitorConfigManager *config_manager);
+
META_EXPORT_TEST
MetaMonitorsConfig * meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_manager);
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index cdb8f4209..223b5dfbd 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -44,7 +44,8 @@ typedef enum _MetaMonitorManagerCapability
META_MONITOR_MANAGER_CAPABILITY_NONE = 0,
META_MONITOR_MANAGER_CAPABILITY_MIRRORING = (1 << 0),
META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE = (1 << 1),
- META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED = (1 << 2)
+ META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED = (1 << 2),
+ META_MONITOR_MANAGER_CAPABILITY_CAN_DERIVE_CURRENT = (1 << 3),
} MetaMonitorManagerCapability;
/* Equivalent to the 'method' enum in org.gnome.Mutter.DisplayConfig */
@@ -133,6 +134,7 @@ struct _MetaMonitorManager
int persistent_timeout_id;
MetaMonitorConfigManager *config_manager;
+ MetaMonitorsConfig *initial_config;
GnomePnpIds *pnp_ids;
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index bb4b44188..076dca8cb 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -531,14 +531,21 @@ should_use_stored_config (MetaMonitorManager *manager)
!meta_monitor_manager_has_hotplug_mode_update (manager));
}
+static gboolean
+can_derive_current_config (MetaMonitorManager *manager)
+{
+ MetaMonitorManagerCapability capabilities;
+
+ capabilities = meta_monitor_manager_get_capabilities (manager);
+ return !!(capabilities & META_MONITOR_MANAGER_CAPABILITY_CAN_DERIVE_CURRENT);
+}
+
MetaMonitorsConfig *
meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
{
- g_autoptr (MetaMonitorsConfig) initial_config = NULL;
MetaMonitorsConfig *config = NULL;
GError *error = NULL;
gboolean use_stored_config;
- MetaMonitorsConfigKey *current_state_key;
MetaMonitorsConfigMethod method;
MetaMonitorsConfigMethod fallback_method =
META_MONITORS_CONFIG_METHOD_TEMPORARY;
@@ -549,17 +556,8 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
else
method = META_MONITORS_CONFIG_METHOD_TEMPORARY;
- initial_config = meta_monitor_config_manager_create_initial (manager->config_manager);
-
- if (initial_config)
- {
- current_state_key = meta_create_monitors_config_key_for_current_state (manager);
-
- /* don't ever reuse initial configuration, if the monitor topology changed
- */
- if (current_state_key && !meta_monitors_config_key_equal (current_state_key, initial_config->key))
- g_clear_object (&initial_config);
- }
+ if (can_derive_current_config (manager))
+ meta_monitor_config_manager_ensure_inherited_config (manager->config_manager);
if (use_stored_config)
{
@@ -628,9 +626,13 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
g_clear_object (&config);
}
- config = g_steal_pointer (&initial_config);
- if (config)
+ config =
+ meta_monitor_config_manager_get_inherited_config (manager->config_manager);
+ if (config &&
+ meta_monitor_manager_is_config_complete (manager, config))
{
+ config = g_object_ref (config);
+
if (!meta_monitor_manager_apply_monitors_config (manager,
config,
method,
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index d60f00325..b8d6342b6 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -999,7 +999,8 @@ static MetaMonitorManagerCapability
meta_monitor_manager_xrandr_get_capabilities (MetaMonitorManager *manager)
{
return (META_MONITOR_MANAGER_CAPABILITY_MIRRORING |
- META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED);
+ META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED |
+ META_MONITOR_MANAGER_CAPABILITY_CAN_DERIVE_CURRENT);
}
static gboolean
--
2.21.0