diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 71bf8a232..bdf106f4c 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -205,7 +205,9 @@ append_monitor (MetaMonitorManager *manager, crtc->all_transforms = ALL_TRANSFORMS; *crtcs = g_list_append (*crtcs, crtc); - output = g_object_new (META_TYPE_OUTPUT, NULL); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", gpu, + NULL); output_dummy = g_new0 (MetaOutputDummy, 1); *output_dummy = (MetaOutputDummy) { @@ -214,7 +216,6 @@ append_monitor (MetaMonitorManager *manager, number = g_list_length (*outputs) + 1; - output->gpu = gpu; output->winsys_id = number; output->name = g_strdup_printf ("LVDS%d", number); output->vendor = g_strdup ("MetaProducts Inc."); @@ -319,9 +320,10 @@ append_tiled_monitor (MetaMonitorManager *manager, preferred_mode = g_list_last (*modes)->data; - output = g_object_new (META_TYPE_OUTPUT, NULL); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", gpu, + NULL); - output->gpu = gpu; output->winsys_id = number; output->name = g_strdup_printf ("LVDS%d", number); output->vendor = g_strdup ("MetaProducts Inc."); diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index 5c13c3503..5a814c61d 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -21,8 +21,21 @@ #include "backends/meta-output.h" +enum +{ + PROP_0, + + PROP_GPU, + + N_PROPS +}; + +static GParamSpec *obj_props[N_PROPS]; + typedef struct _MetaOutputPrivate { + MetaGpu *gpu; + /* The CRTC driving this output, NULL if the output is not enabled */ MetaCrtc *crtc; } MetaOutputPrivate; @@ -32,7 +45,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT) MetaGpu * meta_output_get_gpu (MetaOutput *output) { - return output->gpu; + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + + return priv->gpu; } const char * @@ -91,6 +106,44 @@ meta_output_crtc_to_logical_transform (MetaOutput *output, inverted_panel_orientation_transform); } +static void +meta_output_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MetaOutput *output = META_OUTPUT (object); + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + + switch (prop_id) + { + case PROP_GPU: + priv->gpu = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +meta_output_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MetaOutput *output = META_OUTPUT (object); + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + + switch (prop_id) + { + case PROP_GPU: + g_value_set_object (value, priv->gpu); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + static void meta_output_dispose (GObject *object) { @@ -131,6 +184,18 @@ meta_output_class_init (MetaOutputClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->set_property = meta_output_set_property; + object_class->get_property = meta_output_get_property; object_class->dispose = meta_output_dispose; object_class->finalize = meta_output_finalize; + + obj_props[PROP_GPU] = + g_param_spec_object ("gpu", + "gpu", + "MetaGpu", + META_TYPE_GPU, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, N_PROPS, obj_props); } diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index 24a10cf04..d2701f92d 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -64,8 +64,6 @@ struct _MetaOutput { GObject parent; - MetaGpu *gpu; - /* The low-level ID of this output, used to apply back configuration */ uint64_t winsys_id; char *name; diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index e552113c0..b4097946f 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -302,13 +302,14 @@ meta_create_kms_output (MetaGpuKms *gpu_kms, GList *l; uint32_t gpu_id; - output = g_object_new (META_TYPE_OUTPUT, NULL); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", gpu, + NULL); output_kms = g_slice_new0 (MetaOutputKms); output->driver_private = output_kms; output->driver_notify = (GDestroyNotify) meta_output_destroy_notify; - output->gpu = gpu; output->name = g_strdup (meta_kms_connector_get_name (kms_connector)); gpu_id = meta_gpu_kms_get_id (gpu_kms); diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c index 869a39eef..78370bf1f 100644 --- a/src/backends/x11/meta-output-xrandr.c +++ b/src/backends/x11/meta-output-xrandr.c @@ -770,8 +770,9 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr, GBytes *edid; unsigned int i; - output = g_object_new (META_TYPE_OUTPUT, NULL); - output->gpu = META_GPU (gpu_xrandr); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", gpu_xrandr, + NULL); output->winsys_id = output_id; output->name = g_strdup (xrandr_output->name); diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c index 2b49c3646..d6d4f96b1 100644 --- a/src/tests/headless-start-test.c +++ b/src/tests/headless-start-test.c @@ -151,7 +151,9 @@ meta_test_headless_monitor_connect (void) possible_crtcs = g_new0 (MetaCrtc *, 1); possible_crtcs[0] = g_list_first (test_setup->crtcs)->data; - output = g_object_new (META_TYPE_OUTPUT, NULL); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", gpu, + NULL); output->winsys_id = 1; output->name = g_strdup ("DP-1"); output->vendor = g_strdup ("MetaProduct's Inc."); diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index 3717af42b..71fffda29 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -88,13 +88,9 @@ meta_monitor_manager_test_read_current (MetaMonitorManager *manager) MetaBackend *backend = meta_monitor_manager_get_backend (manager); MetaBackendTest *backend_test = META_BACKEND_TEST (backend); MetaGpu *gpu = meta_backend_test_get_gpu (backend_test); - GList *l; g_assert (manager_test->test_setup); - for (l = manager_test->test_setup->outputs; l; l = l->next) - META_OUTPUT (l->data)->gpu = gpu; - meta_gpu_take_modes (gpu, manager_test->test_setup->modes); meta_gpu_take_crtcs (gpu, manager_test->test_setup->crtcs); meta_gpu_take_outputs (gpu, manager_test->test_setup->outputs); diff --git a/src/tests/monitor-test-utils.c b/src/tests/monitor-test-utils.c index 7b36122d6..f1b566589 100644 --- a/src/tests/monitor-test-utils.c +++ b/src/tests/monitor-test-utils.c @@ -649,7 +649,9 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup, if (!serial) serial = "0x123456"; - output = g_object_new (META_TYPE_OUTPUT, NULL); + output = g_object_new (META_TYPE_OUTPUT, + "gpu", test_get_gpu (), + NULL); if (crtc) meta_output_assign_crtc (output, crtc);