From 7215b0d88c5d8cd974cdf9039f238325441fa2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 8 Oct 2020 17:34:57 +0200 Subject: [PATCH] output: Tie the output to the monitor it's part of Outputs correspond to active connectors, that we translate into monitors. Make this association more real by adding a pointer back to the monitor from the output. Part-of: --- src/backends/meta-monitor.c | 4 ++++ src/backends/meta-output.c | 23 +++++++++++++++++++++++ src/backends/meta-output.h | 6 ++++++ src/tests/monitor-test-utils.c | 2 ++ 4 files changed, 35 insertions(+) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index ae7816a3b..07c574de2 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -675,6 +675,8 @@ meta_monitor_normal_new (MetaGpu *gpu, monitor_priv->gpu = gpu; monitor_priv->outputs = g_list_append (NULL, g_object_ref (output)); + meta_output_set_monitor (output, monitor); + monitor_priv->winsys_id = meta_output_get_id (output); meta_monitor_generate_spec (monitor); @@ -802,6 +804,8 @@ add_tiled_monitor_outputs (MetaGpu *gpu, monitor_priv->outputs = g_list_append (monitor_priv->outputs, g_object_ref (output)); + + meta_output_set_monitor (output, META_MONITOR (monitor_tiled)); } } diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index f8ce8655e..c903110a6 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -45,6 +45,8 @@ typedef struct _MetaOutputPrivate MetaOutputInfo *info; + MetaMonitor *monitor; + /* The CRTC driving this output, NULL if the output is not enabled */ MetaCrtc *crtc; @@ -112,6 +114,27 @@ meta_output_get_gpu (MetaOutput *output) return priv->gpu; } +MetaMonitor * +meta_output_get_monitor (MetaOutput *output) +{ + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + + g_warn_if_fail (priv->monitor); + + return priv->monitor; +} + +void +meta_output_set_monitor (MetaOutput *output, + MetaMonitor *monitor) +{ + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + + g_warn_if_fail (!priv->monitor); + + priv->monitor = monitor; +} + const char * meta_output_get_name (MetaOutput *output) { diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index c54d4206b..ea2cf8878 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -139,6 +139,12 @@ uint64_t meta_output_get_id (MetaOutput *output); META_EXPORT_TEST MetaGpu * meta_output_get_gpu (MetaOutput *output); +META_EXPORT_TEST +MetaMonitor * meta_output_get_monitor (MetaOutput *output); + +void meta_output_set_monitor (MetaOutput *output, + MetaMonitor *monitor); + const char * meta_output_get_name (MetaOutput *output); META_EXPORT_TEST diff --git a/src/tests/monitor-test-utils.c b/src/tests/monitor-test-utils.c index a2a0b08a1..8a18e012a 100644 --- a/src/tests/monitor-test-utils.c +++ b/src/tests/monitor-test-utils.c @@ -289,6 +289,8 @@ check_logical_monitor (MetaMonitorManager *monitor_manager, MetaOutput *output = l_output->data; MetaCrtc *crtc; + g_assert (meta_output_get_monitor (output) == monitor); + if (meta_output_is_primary (output)) { g_assert_null (primary_output);