[gnome-shell/benzea/systemd-scopes: 2/3] shell-global: Place launched applications into a systemd scope
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/benzea/systemd-scopes: 2/3] shell-global: Place launched applications into a systemd scope
- Date: Wed, 27 Nov 2019 15:43:32 +0000 (UTC)
commit 522b48cbc68e53bd59159e7b5f9c35c88fdfd9fe
Author: Benjamin Berg <bberg redhat com>
Date: Tue Nov 26 19:45:29 2019 +0100
shell-global: Place launched applications into a systemd scope
This improves separation from the shells service scope for applications
launched using an XDG desktop file.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/863
src/shell-global.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 77e167c107..67c36c7f16 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -43,6 +43,7 @@
#include "shell-perf-log.h"
#include "shell-window-tracker.h"
#include "shell-wm.h"
+#include "shell-util.h"
#include "st.h"
static ShellGlobal *the_object = NULL;
@@ -1308,6 +1309,36 @@ shell_global_get_current_time (ShellGlobal *global)
return clutter_get_current_event_time ();
}
+#ifdef HAVE_SYSTEMD
+static void
+shell_global_app_launched_cb (GAppLaunchContext *context,
+ GAppInfo *info,
+ GVariant *platform_data,
+ gpointer user_data)
+{
+ const gchar *app_id;
+ gint32 pid;
+ g_autoptr(GVariantDict) dict = NULL;
+
+ g_return_if_fail (platform_data != NULL);
+
+ dict = g_variant_dict_new (platform_data);
+
+ g_return_if_fail (g_variant_dict_contains (dict, "pid"));
+
+ if (!g_variant_dict_lookup (dict, "pid", "i", &pid)) {
+ g_critical ("Could not unpack pid from platform data.");
+ return;
+ }
+
+ app_id = g_app_info_get_id (info);
+ if (app_id == NULL)
+ app_id = "anonymous";
+
+ shell_util_start_systemd_scope (app_id, pid, NULL);
+}
+#endif
+
/**
* shell_global_create_app_launch_context:
* @global: A #ShellGlobal
@@ -1343,6 +1374,13 @@ shell_global_create_app_launch_context (ShellGlobal *global,
meta_launch_context_set_workspace (context, ws);
+#ifdef HAVE_SYSTEMD
+ g_signal_connect (context,
+ "launched",
+ G_CALLBACK (shell_global_app_launched_cb),
+ NULL);
+#endif
+
return (GAppLaunchContext *) context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]