summaryrefslogtreecommitdiff
path: root/src/backends/meta-monitor-manager-dummy.c
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2020-02-26 16:47:03 +0100
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2020-06-10 18:54:51 +0000
commit4a4f2d8264d0f961a8060db38a6d0f51eaefbd28 (patch)
tree4107c5e569f59e269b7c6ca41571013d05d70d82 /src/backends/meta-monitor-manager-dummy.c
parent4920b5064d2240c2d202deeb92a8ad09780a5799 (diff)
downloadmutter-4a4f2d8264d0f961a8060db38a6d0f51eaefbd28.tar.gz
output: Make implementations inherit MetaOutput
Instead of the home baked "inheritance" system, using a gpointer and a GDestroyNotify function to keep the what effectively is sub type details, make MetaOutput an abstract derivable type, and make the implementations inherit it. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
Diffstat (limited to 'src/backends/meta-monitor-manager-dummy.c')
-rw-r--r--src/backends/meta-monitor-manager-dummy.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c
index ae6a99d78..e936654b6 100644
--- a/src/backends/meta-monitor-manager-dummy.c
+++ b/src/backends/meta-monitor-manager-dummy.c
@@ -53,10 +53,14 @@ struct _MetaMonitorManagerDummyClass
MetaMonitorManagerClass parent_class;
};
-typedef struct _MetaOutputDummy
+struct _MetaOutputDummy
{
+ MetaOutput parent;
+
float scale;
-} MetaOutputDummy;
+};
+
+G_DEFINE_TYPE (MetaOutputDummy, meta_output_dummy, META_TYPE_OUTPUT)
G_DEFINE_TYPE (MetaMonitorManagerDummy, meta_monitor_manager_dummy, META_TYPE_MONITOR_MANAGER);
@@ -67,9 +71,6 @@ struct _MetaGpuDummy
G_DEFINE_TYPE (MetaGpuDummy, meta_gpu_dummy, META_TYPE_GPU)
-static void
-meta_output_dummy_notify_destroy (MetaOutput *output);
-
typedef struct _CrtcModeSpec
{
int width;
@@ -229,19 +230,13 @@ append_monitor (MetaMonitorManager *manager,
output_info->possible_crtcs[0] = g_list_last (*crtcs)->data;
output_info->n_possible_crtcs = 1;
- output = g_object_new (META_TYPE_OUTPUT,
+ output = g_object_new (META_TYPE_OUTPUT_DUMMY,
"id", number,
"gpu", gpu,
"info", output_info,
NULL);
-
- output_dummy = g_new0 (MetaOutputDummy, 1);
- *output_dummy = (MetaOutputDummy) {
- .scale = scale
- };
- output->driver_private = output_dummy;
- output->driver_notify =
- (GDestroyNotify) meta_output_dummy_notify_destroy;
+ output_dummy = META_OUTPUT_DUMMY (output);
+ output_dummy->scale = scale;
*outputs = g_list_append (*outputs, output);
}
@@ -307,11 +302,6 @@ append_tiled_monitor (MetaMonitorManager *manager,
g_autoptr (MetaOutputInfo) output_info = NULL;
GList *l;
- output_dummy = g_new0 (MetaOutputDummy, 1);
- *output_dummy = (MetaOutputDummy) {
- .scale = scale
- };
-
/* Arbitrary ID unique for this output */
number = g_list_length (*outputs) + 1;
@@ -359,26 +349,19 @@ append_tiled_monitor (MetaMonitorManager *manager,
}
output_info->n_possible_crtcs = n_tiles;
- output = g_object_new (META_TYPE_OUTPUT,
+ output = g_object_new (META_TYPE_OUTPUT_DUMMY,
"id", number,
"gpu", gpu,
"info", output_info,
NULL);
- output->driver_private = output_dummy;
- output->driver_notify =
- (GDestroyNotify) meta_output_dummy_notify_destroy;
+ output_dummy = META_OUTPUT_DUMMY (output);
+ output_dummy->scale = scale;
*outputs = g_list_append (*outputs, output);
}
}
static void
-meta_output_dummy_notify_destroy (MetaOutput *output)
-{
- g_clear_pointer (&output->driver_private, g_free);
-}
-
-static void
meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
{
MetaGpu *gpu = get_gpu (manager);
@@ -652,7 +635,7 @@ meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *man
MetaOutputDummy *output_dummy;
output = meta_monitor_get_main_output (monitor);
- output_dummy = output->driver_private;
+ output_dummy = META_OUTPUT_DUMMY (output);
return output_dummy->scale;
}
@@ -799,3 +782,14 @@ meta_gpu_dummy_class_init (MetaGpuDummyClass *klass)
gpu_class->read_current = meta_gpu_dummy_read_current;
}
+
+static void
+meta_output_dummy_init (MetaOutputDummy *output_dummy)
+{
+ output_dummy->scale = 1;
+}
+
+static void
+meta_output_dummy_class_init (MetaOutputDummyClass *klass)
+{
+}