[mutter] context: Add :unsafe-mode property
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] context: Add :unsafe-mode property
- Date: Thu, 2 Sep 2021 17:30:27 +0000 (UTC)
commit c62e86cb23d84dc1344cc72568b357272cd21647
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Sep 1 21:12:03 2021 +0200
context: Add :unsafe-mode property
We are going to restrict several sensitive D-Bus APIs to a set
of allowed callers (like Settings or portal implementations).
Add an :unsafe-mode property to the context to allow turning off
those restrictions temporarily, in order to not get in the way
of development/debugging.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
src/core/meta-context-private.h | 4 ++++
src/core/meta-context.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
---
diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h
index a3b7f9b4b7..87f5261f54 100644
--- a/src/core/meta-context-private.h
+++ b/src/core/meta-context-private.h
@@ -55,6 +55,10 @@ const char * meta_context_get_name (MetaContext *context);
const char * meta_context_get_gnome_wm_keybindings (MetaContext *context);
+gboolean meta_context_get_unsafe_mode (MetaContext *context);
+void meta_context_set_unsafe_mode (MetaContext *context,
+ gboolean enable);
+
META_EXPORT_TEST
MetaWaylandCompositor * meta_context_get_wayland_compositor (MetaContext *context);
diff --git a/src/core/meta-context.c b/src/core/meta-context.c
index 7bb0e5f460..8c3b03e7fc 100644
--- a/src/core/meta-context.c
+++ b/src/core/meta-context.c
@@ -39,6 +39,7 @@ enum
PROP_0,
PROP_NAME,
+ PROP_UNSAFE_MODE,
N_PROPS
};
@@ -62,6 +63,8 @@ typedef struct _MetaContextPrivate
GType plugin_gtype;
char *gnome_wm_keybindings;
+ gboolean unsafe_mode;
+
MetaContextState state;
GOptionContext *option_context;
@@ -441,6 +444,27 @@ meta_context_destroy (MetaContext *context)
g_object_unref (context);
}
+gboolean
+meta_context_get_unsafe_mode (MetaContext *context)
+{
+ MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+ return priv->unsafe_mode;
+}
+
+void
+meta_context_set_unsafe_mode (MetaContext *context,
+ gboolean enable)
+{
+ MetaContextPrivate *priv = meta_context_get_instance_private (context);
+
+ if (priv->unsafe_mode == enable)
+ return;
+
+ priv->unsafe_mode = enable;
+ g_object_notify_by_pspec (G_OBJECT (context), obj_props[PROP_UNSAFE_MODE]);
+}
+
static void
meta_context_get_property (GObject *object,
guint prop_id,
@@ -455,6 +479,9 @@ meta_context_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
+ case PROP_UNSAFE_MODE:
+ g_value_set_boolean (value, priv->unsafe_mode);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -475,6 +502,10 @@ meta_context_set_property (GObject *object,
case PROP_NAME:
priv->name = g_value_dup_string (value);
break;
+ case PROP_UNSAFE_MODE:
+ meta_context_set_unsafe_mode (META_CONTEXT (object),
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -545,6 +576,14 @@ meta_context_class_init (MetaContextClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ obj_props[PROP_UNSAFE_MODE] =
+ g_param_spec_boolean ("unsafe-mode",
+ "unsafe mode",
+ "Unsafe mode",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]