[gnome-flashback] monitor-manager: use MonitorsConfig to track switch_config
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-manager: use MonitorsConfig to track switch_config
- Date: Thu, 18 Jul 2019 17:30:05 +0000 (UTC)
commit f8bd76c5fe67eba13b1bfdfe5a508de0f123e519
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Jul 16 22:07:19 2019 +0300
monitor-manager: use MonitorsConfig to track switch_config
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/commit/6267732bec97773883ad
backends/gf-monitor-config-manager.c | 23 +++++++++++++++------
backends/gf-monitor-manager.c | 11 +++++++---
backends/gf-monitors-config-private.h | 39 +++++++++++++++++++++--------------
backends/gf-monitors-config.c | 16 +++++++++++++-
4 files changed, 63 insertions(+), 26 deletions(-)
---
diff --git a/backends/gf-monitor-config-manager.c b/backends/gf-monitor-config-manager.c
index 15a6094..931480b 100644
--- a/backends/gf-monitor-config-manager.c
+++ b/backends/gf-monitor-config-manager.c
@@ -994,7 +994,11 @@ GfMonitorsConfig *
gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *config_manager,
GfMonitorSwitchConfigType config_type)
{
- GfMonitorManager *monitor_manager = config_manager->monitor_manager;
+ GfMonitorManager *monitor_manager;
+ GfMonitorsConfig *config;
+
+ monitor_manager = config_manager->monitor_manager;
+ config = NULL;
if (!gf_monitor_manager_can_switch_config (monitor_manager))
return NULL;
@@ -1002,16 +1006,20 @@ gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *c
switch (config_type)
{
case GF_MONITOR_SWITCH_CONFIG_ALL_MIRROR:
- return create_for_switch_config_all_mirror (config_manager);
+ config = create_for_switch_config_all_mirror (config_manager);
+ break;
case GF_MONITOR_SWITCH_CONFIG_ALL_LINEAR:
- return gf_monitor_config_manager_create_linear (config_manager);
+ config = gf_monitor_config_manager_create_linear (config_manager);
+ break;
case GF_MONITOR_SWITCH_CONFIG_EXTERNAL:
- return create_for_switch_config_external (config_manager);
+ config = create_for_switch_config_external (config_manager);
+ break;
case GF_MONITOR_SWITCH_CONFIG_BUILTIN:
- return create_for_switch_config_builtin (config_manager);
+ config = create_for_switch_config_builtin (config_manager);
+ break;
case GF_MONITOR_SWITCH_CONFIG_UNKNOWN:
default:
@@ -1019,7 +1027,10 @@ gf_monitor_config_manager_create_for_switch_config (GfMonitorConfigManager *c
break;
}
- return NULL;
+ if (config)
+ gf_monitors_config_set_switch_config (config, config_type);
+
+ return config;
}
void
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index 5ec40be..ac87c12 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -180,8 +180,6 @@ gf_monitor_manager_notify_monitors_changed (GfMonitorManager *manager)
priv = gf_monitor_manager_get_instance_private (manager);
- manager->current_switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
-
gf_backend_monitors_changed (priv->backend);
g_signal_emit_by_name (manager, "monitors-changed");
@@ -2484,7 +2482,9 @@ gf_monitor_manager_ensure_configured (GfMonitorManager *manager)
g_clear_object (&config);
}
- config = gf_monitor_config_manager_create_linear (manager->config_manager);
+ config = gf_monitor_config_manager_create_for_switch_config (manager->config_manager,
+ GF_MONITOR_SWITCH_CONFIG_ALL_LINEAR);
+
if (config)
{
if (!gf_monitor_manager_apply_monitors_config (manager, config,
@@ -2537,6 +2537,11 @@ void
gf_monitor_manager_update_logical_state_derived (GfMonitorManager *manager,
GfMonitorsConfig *config)
{
+ if (config)
+ manager->current_switch_config = gf_monitors_config_get_switch_config (config);
+ else
+ manager->current_switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
+
manager->layout_mode = GF_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
gf_monitor_manager_rebuild_logical_monitors_derived (manager, config);
diff --git a/backends/gf-monitors-config-private.h b/backends/gf-monitors-config-private.h
index 4070bc0..b294e62 100644
--- a/backends/gf-monitors-config-private.h
+++ b/backends/gf-monitors-config-private.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 Red Hat
- * Copyright (C) 2017 Alberts Muktupāvels
+ * Copyright (C) 2017-2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,32 +49,39 @@ struct _GfMonitorsConfig
GfMonitorsConfigFlag flags;
GfLogicalMonitorLayoutMode layout_mode;
+
+ GfMonitorSwitchConfigType switch_config;
};
#define GF_TYPE_MONITORS_CONFIG (gf_monitors_config_get_type ())
G_DECLARE_FINAL_TYPE (GfMonitorsConfig, gf_monitors_config,
GF, MONITORS_CONFIG, GObject)
-GfMonitorsConfig *gf_monitors_config_new_full (GList *logical_monitor_configs,
- GList *disabled_monitor_specs,
- GfLogicalMonitorLayoutMode layout_mode,
- GfMonitorsConfigFlag flags);
+GfMonitorsConfig *gf_monitors_config_new_full (GList
*logical_monitor_configs,
+ GList
*disabled_monitor_specs,
+ GfLogicalMonitorLayoutMode layout_mode,
+ GfMonitorsConfigFlag flags);
+
+GfMonitorsConfig *gf_monitors_config_new (GfMonitorManager
*monitor_manager,
+ GList
*logical_monitor_configs,
+ GfLogicalMonitorLayoutMode layout_mode,
+ GfMonitorsConfigFlag flags);
+
+GfMonitorSwitchConfigType gf_monitors_config_get_switch_config (GfMonitorsConfig *config);
-GfMonitorsConfig *gf_monitors_config_new (GfMonitorManager *monitor_manager,
- GList *logical_monitor_configs,
- GfLogicalMonitorLayoutMode layout_mode,
- GfMonitorsConfigFlag flags);
+void gf_monitors_config_set_switch_config (GfMonitorsConfig *config,
+ GfMonitorSwitchConfigType switch_config);
-guint gf_monitors_config_key_hash (gconstpointer data);
+guint gf_monitors_config_key_hash (gconstpointer data);
-gboolean gf_monitors_config_key_equal (gconstpointer data_a,
- gconstpointer data_b);
+gboolean gf_monitors_config_key_equal (gconstpointer data_a,
+ gconstpointer data_b);
-void gf_monitors_config_key_free (GfMonitorsConfigKey *config_key);
+void gf_monitors_config_key_free (GfMonitorsConfigKey *config_key);
-gboolean gf_verify_monitors_config (GfMonitorsConfig *config,
- GfMonitorManager *monitor_manager,
- GError **error);
+gboolean gf_verify_monitors_config (GfMonitorsConfig *config,
+ GfMonitorManager
*monitor_manager,
+ GError **error);
G_END_DECLS
diff --git a/backends/gf-monitors-config.c b/backends/gf-monitors-config.c
index b82b555..0ea8bcb 100644
--- a/backends/gf-monitors-config.c
+++ b/backends/gf-monitors-config.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 Red Hat
- * Copyright (C) 2017 Alberts Muktupāvels
+ * Copyright (C) 2017-2019 Alberts Muktupāvels
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -149,6 +149,7 @@ gf_monitors_config_new_full (GList *logical_monitor_configs
disabled_monitor_specs);
config->layout_mode = layout_mode;
config->flags = flags;
+ config->switch_config = GF_MONITOR_SWITCH_CONFIG_UNKNOWN;
return config;
}
@@ -188,6 +189,19 @@ gf_monitors_config_new (GfMonitorManager *monitor_manager,
layout_mode, flags);
}
+GfMonitorSwitchConfigType
+gf_monitors_config_get_switch_config (GfMonitorsConfig *config)
+{
+ return config->switch_config;
+}
+
+void
+gf_monitors_config_set_switch_config (GfMonitorsConfig *config,
+ GfMonitorSwitchConfigType switch_config)
+{
+ config->switch_config = switch_config;
+}
+
guint
gf_monitors_config_key_hash (gconstpointer data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]