[mutter] monitor-manager: Apply built-in monitor orientation to previous configurations
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Apply built-in monitor orientation to previous configurations
- Date: Sat, 4 Sep 2021 09:12:41 +0000 (UTC)
commit d773aaf7a91402e9b69ebf6b9fd96208edfad7f6
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri May 1 15:24:34 2020 +0200
monitor-manager: Apply built-in monitor orientation to previous configurations
When we reuse a monitor configuration (from the storage or previously
used), we need to make sure that the built-in monitor rotation matches
with the current sensors status.
So, instead of trying to apply a previously used or stored configuration
with a wrong orientation and fix it later, if orientation is managed by
sensor, try to create another configuration based on the previous one that
uses the current built-in monitor orientation and use it.
Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/592
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/646
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/954
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
src/backends/meta-monitor-config-manager.c | 37 ++++++++++++++----
src/backends/meta-monitor-config-manager.h | 5 +++
src/backends/meta-monitor-manager.c | 60 ++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c
index 15972d1f84..5f8324338d 100644
--- a/src/backends/meta-monitor-config-manager.c
+++ b/src/backends/meta-monitor-config-manager.c
@@ -1031,6 +1031,7 @@ find_logical_config_for_builtin_display_rotation (MetaMonitorConfigManager *conf
static MetaMonitorsConfig *
create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
+ MetaMonitorsConfig *base_config,
gboolean rotate,
MetaMonitorTransform transform)
{
@@ -1040,10 +1041,9 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
GList *logical_monitor_configs, *current_configs;
MetaLogicalMonitorLayoutMode layout_mode;
- if (!config_manager->current_config)
- return NULL;
+ g_return_val_if_fail (base_config, NULL);
- current_configs = config_manager->current_config->logical_monitor_configs;
+ current_configs = base_config->logical_monitor_configs;
current_logical_monitor_config =
find_logical_config_for_builtin_display_rotation (config_manager,
current_configs);
@@ -1071,7 +1071,7 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
return NULL;
logical_monitor_configs =
- clone_logical_monitor_config_list (config_manager->current_config->logical_monitor_configs);
+ clone_logical_monitor_config_list (base_config->logical_monitor_configs);
logical_monitor_config =
find_logical_config_for_builtin_display_rotation (config_manager, logical_monitor_configs);
logical_monitor_config->transform = transform;
@@ -1084,7 +1084,7 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
logical_monitor_config->layout.height = temp;
}
- layout_mode = config_manager->current_config->layout_mode;
+ layout_mode = base_config->layout_mode;
return meta_monitors_config_new (monitor_manager,
logical_monitor_configs,
layout_mode,
@@ -1093,15 +1093,38 @@ create_for_builtin_display_rotation (MetaMonitorConfigManager *config_manager,
MetaMonitorsConfig *
meta_monitor_config_manager_create_for_orientation (MetaMonitorConfigManager *config_manager,
+ MetaMonitorsConfig *base_config,
MetaMonitorTransform transform)
{
- return create_for_builtin_display_rotation (config_manager, FALSE, transform);
+ return create_for_builtin_display_rotation (config_manager, base_config,
+ FALSE, transform);
+}
+
+MetaMonitorsConfig *
+meta_monitor_config_manager_create_for_builtin_orientation (MetaMonitorConfigManager *config_manager,
+ MetaMonitorsConfig *base_config)
+{
+ MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
+ MetaMonitorTransform current_transform;
+ MetaMonitor *laptop_panel;
+
+ g_return_val_if_fail (
+ meta_monitor_manager_get_panel_orientation_managed (monitor_manager), NULL);
+
+ laptop_panel = meta_monitor_manager_get_laptop_panel (monitor_manager);
+ current_transform = get_monitor_transform (monitor_manager, laptop_panel);
+
+ return create_for_builtin_display_rotation (config_manager, base_config,
+ FALSE, current_transform);
}
MetaMonitorsConfig *
meta_monitor_config_manager_create_for_rotate_monitor (MetaMonitorConfigManager *config_manager)
{
- return create_for_builtin_display_rotation (config_manager, TRUE, META_MONITOR_TRANSFORM_NORMAL);
+ return create_for_builtin_display_rotation (config_manager,
+ config_manager->current_config,
+ TRUE,
+ META_MONITOR_TRANSFORM_NORMAL);
}
static MetaMonitorsConfig *
diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h
index 192d915363..0b37665bc7 100644
--- a/src/backends/meta-monitor-config-manager.h
+++ b/src/backends/meta-monitor-config-manager.h
@@ -105,8 +105,13 @@ MetaMonitorsConfig * meta_monitor_config_manager_create_suggested (MetaMonitorCo
META_EXPORT_TEST
MetaMonitorsConfig * meta_monitor_config_manager_create_for_orientation (MetaMonitorConfigManager
*config_manager,
+ MetaMonitorsConfig
*base_config,
MetaMonitorTransform
transform);
+META_EXPORT_TEST
+MetaMonitorsConfig * meta_monitor_config_manager_create_for_builtin_orientation (MetaMonitorConfigManager
*config_manager,
+ MetaMonitorsConfig
*base_config);
+
META_EXPORT_TEST
MetaMonitorsConfig * meta_monitor_config_manager_create_for_rotate_monitor (MetaMonitorConfigManager
*config_manager);
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index cffa8922bd..30fcee9712 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -689,6 +689,17 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
config = meta_monitor_config_manager_get_stored (manager->config_manager);
if (config)
{
+ g_autoptr (MetaMonitorsConfig) oriented_config = NULL;
+
+ if (manager->panel_orientation_managed)
+ {
+ oriented_config = meta_monitor_config_manager_create_for_builtin_orientation (
+ manager->config_manager, config);
+
+ if (oriented_config)
+ config = oriented_config;
+ }
+
if (!meta_monitor_manager_apply_monitors_config (manager,
config,
method,
@@ -707,6 +718,39 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
}
}
+ if (manager->panel_orientation_managed)
+ {
+ MetaMonitorsConfig *current_config =
+ meta_monitor_config_manager_get_current (manager->config_manager);
+
+ if (current_config)
+ {
+ config = meta_monitor_config_manager_create_for_builtin_orientation (
+ manager->config_manager, current_config);
+ }
+ }
+
+ if (config)
+ {
+ if (meta_monitor_manager_is_config_complete (manager, config))
+ {
+ if (!meta_monitor_manager_apply_monitors_config (manager,
+ config,
+ method,
+ &error))
+ {
+ g_clear_object (&config);
+ g_warning ("Failed to use current monitor configuration: %s",
+ error->message);
+ g_clear_error (&error);
+ }
+ else
+ {
+ goto done;
+ }
+ }
+ }
+
config = meta_monitor_config_manager_create_suggested (manager->config_manager);
if (config)
{
@@ -813,6 +857,7 @@ handle_orientation_change (MetaOrientationManager *orientation_manager,
MetaMonitorsConfig *config;
MetaMonitor *laptop_panel;
MetaLogicalMonitor *laptop_logical_monitor;
+ MetaMonitorsConfig *current_config;
laptop_panel = meta_monitor_manager_get_laptop_panel (manager);
g_return_if_fail (laptop_panel);
@@ -844,8 +889,11 @@ handle_orientation_change (MetaOrientationManager *orientation_manager,
if (meta_logical_monitor_get_transform (laptop_logical_monitor) == transform)
return;
+ current_config =
+ meta_monitor_config_manager_get_current (manager->config_manager);
config =
meta_monitor_config_manager_create_for_orientation (manager->config_manager,
+ current_config,
transform);
if (!config)
return;
@@ -1502,6 +1550,18 @@ restore_previous_config (MetaMonitorManager *manager)
{
MetaMonitorsConfigMethod method;
+ if (manager->panel_orientation_managed)
+ {
+ g_autoptr (MetaMonitorsConfig) oriented_config = NULL;
+
+ oriented_config =
+ meta_monitor_config_manager_create_for_builtin_orientation (
+ manager->config_manager, previous_config);
+
+ if (oriented_config)
+ g_set_object (&previous_config, oriented_config);
+ }
+
method = META_MONITORS_CONFIG_METHOD_TEMPORARY;
if (meta_monitor_manager_apply_monitors_config (manager,
previous_config,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]