[mutter] Introduce mostly empty MetaContext type



commit e020fdfddf26cd45922473df8b9db65cb693fdef
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 2 09:31:19 2021 +0100

    Introduce mostly empty MetaContext type
    
    This type is intended to replace the scattered functions used to
    configure how the Mutter compositor is run. It currently doesn't do
    anything, and only has a human readable name, intended to be set to e.g.
    "GNOME Shell".
    
    It's an abstract type, and is intended to be used via either a future
    `MetaContextMain` for real display server use cases, and a
    `MetaContextTest` for test cases.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>

 src/core/meta-context-private.h |  31 +++++++++++
 src/core/meta-context.c         | 117 ++++++++++++++++++++++++++++++++++++++++
 src/meson.build                 |   2 +
 src/meta/meson.build            |   1 +
 src/meta/meta-context.h         |  32 +++++++++++
 src/meta/types.h                |   1 +
 6 files changed, 184 insertions(+)
---
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
new file mode 100644
index 0000000000..89675d2644
--- /dev/null
+++ b/src/core/meta-context-private.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 Red Hat Inc.
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#ifndef META_CONTEXT_PRIVATE_H
+#define META_CONTEXT_PRIVATE_H
+
+#include "meta/meta-context.h"
+
+struct _MetaContextClass
+{
+  GObjectClass parent_class;
+};
+
+#endif /* META_CONTEXT_PRIVATE_H */
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
new file mode 100644
index 0000000000..e80b5f3438
--- /dev/null
+++ b/src/core/meta-context.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2019 Red Hat Inc.
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "core/meta-context-private.h"
+
+enum
+{
+  PROP_0,
+
+  PROP_NAME,
+
+  N_PROPS
+};
+
+static GParamSpec *obj_props[N_PROPS];
+
+typedef struct _MetaContextPrivate
+{
+  char *name;
+} MetaContextPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (MetaContext, meta_context, G_TYPE_OBJECT)
+
+static void
+meta_context_get_property (GObject    *object,
+                           guint       prop_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+  MetaContext *context = META_CONTEXT (object);
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  switch (prop_id)
+    {
+    case PROP_NAME:
+      g_value_set_string (value, priv->name);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+meta_context_set_property (GObject      *object,
+                           guint         prop_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+  MetaContext *context = META_CONTEXT (object);
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  switch (prop_id)
+    {
+    case PROP_NAME:
+      priv->name = g_value_dup_string (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+meta_context_finalize (GObject *object)
+{
+  MetaContext *context = META_CONTEXT (object);
+  MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+  g_clear_pointer (&priv->name, g_free);
+
+  G_OBJECT_CLASS (meta_context_parent_class)->finalize (object);
+}
+
+static void
+meta_context_class_init (MetaContextClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = meta_context_get_property;
+  object_class->set_property = meta_context_set_property;
+  object_class->finalize = meta_context_finalize;
+
+  obj_props[PROP_NAME] =
+    g_param_spec_string ("name",
+                         "name",
+                         "Human readable name",
+                         NULL,
+                         G_PARAM_READWRITE |
+                         G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_STATIC_STRINGS);
+  g_object_class_install_properties (object_class, N_PROPS, obj_props);
+}
+
+static void
+meta_context_init (MetaContext *context)
+{
+}
diff --git a/src/meson.build b/src/meson.build
index dd8a8b31b0..817cfa2c3d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -371,6 +371,8 @@ mutter_sources = [
   'core/meta-close-dialog.c',
   'core/meta-close-dialog-default.c',
   'core/meta-close-dialog-default-private.h',
+  'core/meta-context-private.h',
+  'core/meta-context.c',
   'core/meta-fraction.c',
   'core/meta-fraction.h',
   'core/meta-gesture-tracker.c',
diff --git a/src/meta/meson.build b/src/meta/meson.build
index a096ee4dd7..631857e2de 100644
--- a/src/meta/meson.build
+++ b/src/meta/meson.build
@@ -16,6 +16,7 @@ mutter_public_headers = [
   'meta-background-image.h',
   'meta-close-dialog.h',
   'meta-cursor-tracker.h',
+  'meta-context.h',
   'meta-dnd.h',
   'meta-idle-monitor.h',
   'meta-inhibit-shortcuts-dialog.h',
diff --git a/src/meta/meta-context.h b/src/meta/meta-context.h
new file mode 100644
index 0000000000..288eb13871
--- /dev/null
+++ b/src/meta/meta-context.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 Red Hat Inc.
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#ifndef META_CONTEXT_H
+#define META_CONTEXT_H
+
+#include <glib-object.h>
+
+#include "meta/common.h"
+
+#define META_TYPE_CONTEXT (meta_context_get_type ())
+META_EXPORT
+G_DECLARE_DERIVABLE_TYPE (MetaContext, meta_context, META, CONTEXT, GObject)
+
+#endif /* META_CONTEXT_H */
diff --git a/src/meta/types.h b/src/meta/types.h
index 49fb568166..403e62b16e 100644
--- a/src/meta/types.h
+++ b/src/meta/types.h
@@ -25,6 +25,7 @@
  *
  */
 typedef struct _MetaBackend     MetaBackend;
+typedef struct _MetaContext     MetaContext;
 typedef struct _MetaCompositor  MetaCompositor;
 typedef struct _MetaDisplay     MetaDisplay;
 typedef struct _MetaX11Display  MetaX11Display;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]