[gnome-flashback] monitor-manager: add config relationships and use it for orientation events
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-manager: add config relationships and use it for orientation events
- Date: Sat, 23 Oct 2021 18:48:45 +0000 (UTC)
commit 4663fe7aa585b95e74e5eec019325a9fb164335b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Sep 13 14:21:27 2021 +0300
monitor-manager: add config relationships and use it for orientation events
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/f803c0ee0a4a
backends/gf-monitor-config-manager.c | 46 ++++++++++++++++++++++++++++++++---
backends/gf-monitor-manager.c | 17 +++++++++++++
backends/gf-monitors-config-private.h | 5 ++++
backends/gf-monitors-config.c | 12 +++++++++
4 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/backends/gf-monitor-config-manager.c b/backends/gf-monitor-config-manager.c
index 6f23469..57ab52d 100644
--- a/backends/gf-monitor-config-manager.c
+++ b/backends/gf-monitor-config-manager.c
@@ -65,6 +65,22 @@ struct _GfMonitorConfigManager
G_DEFINE_TYPE (GfMonitorConfigManager, gf_monitor_config_manager, G_TYPE_OBJECT)
+static GfMonitorsConfig *
+get_root_config (GfMonitorsConfig *config)
+{
+ if (config->parent_config == NULL)
+ return config;
+
+ return get_root_config (config->parent_config);
+}
+
+static gboolean
+has_same_root_config (GfMonitorsConfig *config_a,
+ GfMonitorsConfig *config_b)
+{
+ return get_root_config (config_a) == get_root_config (config_b);
+}
+
static void
history_unref (gpointer data,
gpointer user_data)
@@ -567,6 +583,7 @@ create_for_builtin_display_rotation (GfMonitorConfigManager *config_manager,
GfMonitorManager *monitor_manager = config_manager->monitor_manager;
GfLogicalMonitorConfig *logical_monitor_config;
GfLogicalMonitorConfig *current_logical_monitor_config;
+ GfMonitorsConfig *config;
GList *logical_monitor_configs;
GList *current_configs;
GfLogicalMonitorLayoutMode layout_mode;
@@ -619,8 +636,14 @@ create_for_builtin_display_rotation (GfMonitorConfigManager *config_manager,
layout_mode = base_config->layout_mode;
- return gf_monitors_config_new (monitor_manager, logical_monitor_configs,
- layout_mode, GF_MONITORS_CONFIG_FLAG_NONE);
+ config = gf_monitors_config_new (monitor_manager,
+ logical_monitor_configs,
+ layout_mode,
+ GF_MONITORS_CONFIG_FLAG_NONE);
+
+ gf_monitors_config_set_parent_config (config, base_config);
+
+ return config;
}
static gboolean
@@ -1331,6 +1354,9 @@ gf_monitor_config_manager_create_for_builtin_orientation (GfMonitorConfigManager
GfMonitorsConfig *
gf_monitor_config_manager_create_for_rotate_monitor (GfMonitorConfigManager *config_manager)
{
+ if (config_manager->current_config == NULL)
+ return NULL;
+
return create_for_builtin_display_rotation (config_manager,
config_manager->current_config,
TRUE,
@@ -1381,7 +1407,21 @@ void
gf_monitor_config_manager_set_current (GfMonitorConfigManager *config_manager,
GfMonitorsConfig *config)
{
- if (config_manager->current_config)
+ GfMonitorsConfig *current_config;
+ gboolean overrides_current;
+
+ current_config = config_manager->current_config;
+ overrides_current = FALSE;
+
+ if (config != NULL &&
+ current_config != NULL &&
+ has_same_root_config (config, current_config))
+ {
+ overrides_current = gf_monitors_config_key_equal (config->key,
+ current_config->key);
+ }
+
+ if (current_config != NULL && !overrides_current)
{
g_queue_push_head (&config_manager->config_history,
g_object_ref (config_manager->current_config));
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index 0d2e9da..3c1b1ca 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -642,6 +642,9 @@ handle_orientation_change (GfOrientationManager *orientation_manager,
return;
current_config = gf_monitor_config_manager_get_current (manager->config_manager);
+ if (current_config == NULL)
+ return;
+
config = gf_monitor_config_manager_create_for_orientation (manager->config_manager,
current_config,
transform);
@@ -2756,7 +2759,21 @@ gf_monitor_manager_ensure_configured (GfMonitorManager *manager)
config = gf_monitor_config_manager_get_previous (manager->config_manager);
if (config)
{
+ GfMonitorsConfig *oriented_config;
+
+ oriented_config = NULL;
+
+ if (manager->panel_orientation_managed)
+ {
+ oriented_config = gf_monitor_config_manager_create_for_builtin_orientation
(manager->config_manager,
+ config);
+
+ if (oriented_config != NULL)
+ config = oriented_config;
+ }
+
config = g_object_ref (config);
+ g_clear_object (&oriented_config);
if (gf_monitor_manager_is_config_complete (manager, config))
{
diff --git a/backends/gf-monitors-config-private.h b/backends/gf-monitors-config-private.h
index f4f8551..ffe2b43 100644
--- a/backends/gf-monitors-config-private.h
+++ b/backends/gf-monitors-config-private.h
@@ -42,6 +42,8 @@ struct _GfMonitorsConfig
{
GObject parent;
+ GfMonitorsConfig *parent_config;
+
GfMonitorsConfigKey *key;
GList *logical_monitor_configs;
@@ -68,6 +70,9 @@ GfMonitorsConfig *gf_monitors_config_new (GfMonitorManage
GfLogicalMonitorLayoutMode layout_mode,
GfMonitorsConfigFlag flags);
+void gf_monitors_config_set_parent_config (GfMonitorsConfig *config,
+ GfMonitorsConfig *parent_config);
+
GfMonitorSwitchConfigType gf_monitors_config_get_switch_config (GfMonitorsConfig *config);
void gf_monitors_config_set_switch_config (GfMonitorsConfig *config,
diff --git a/backends/gf-monitors-config.c b/backends/gf-monitors-config.c
index 7e668ca..21f736e 100644
--- a/backends/gf-monitors-config.c
+++ b/backends/gf-monitors-config.c
@@ -120,6 +120,8 @@ gf_monitors_config_finalize (GObject *object)
config = GF_MONITORS_CONFIG (object);
+ g_clear_object (&config->parent_config);
+
gf_monitors_config_key_free (config->key);
g_list_free_full (config->logical_monitor_configs,
(GDestroyNotify) gf_logical_monitor_config_free);
@@ -199,6 +201,16 @@ gf_monitors_config_new (GfMonitorManager *monitor_manager,
layout_mode, flags);
}
+void
+gf_monitors_config_set_parent_config (GfMonitorsConfig *config,
+ GfMonitorsConfig *parent_config)
+{
+ g_assert (config != parent_config);
+ g_assert (parent_config == NULL || parent_config->parent_config != config);
+
+ g_set_object (&config->parent_config, parent_config);
+}
+
GfMonitorSwitchConfigType
gf_monitors_config_get_switch_config (GfMonitorsConfig *config)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]