[gnome-shell/wip/hadess/PrefersNonDefaultGPU: 8/13] shell/global: Watch for switcheroo-control appearing
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/hadess/PrefersNonDefaultGPU: 8/13] shell/global: Watch for switcheroo-control appearing
- Date: Mon, 4 May 2020 14:29:06 +0000 (UTC)
commit 49605c7b000c06e68cdeab3bab079d5a25d208f3
Author: Bastien Nocera <hadess hadess net>
Date: Tue Apr 28 17:24:06 2020 +0200
shell/global: Watch for switcheroo-control appearing
Rather than staticly expecting switcheroo-control to already be running
on the system, wait for it appearing and disappearing.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1226
src/shell-global.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 6ad7a6673a..0488c3c441 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -299,6 +299,35 @@ shell_global_get_property(GObject *object,
}
}
+static void
+switcheroo_appeared_cb (GDBusConnection *connection,
+ const char *name,
+ const char *name_owner,
+ gpointer user_data)
+{
+ ShellGlobal *global = user_data;
+
+ g_debug ("switcheroo-control appeared");
+ shell_net_hadess_switcheroo_control_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "net.hadess.SwitcherooControl",
+ "/net/hadess/SwitcherooControl",
+ global->switcheroo_cancellable,
+ switcheroo_control_ready_cb,
+ global);
+}
+
+static void
+switcheroo_vanished_cb (GDBusConnection *connection,
+ const char *name,
+ gpointer user_data)
+{
+ ShellGlobal *global = user_data;
+
+ g_debug ("switcheroo-control vanished");
+ g_clear_object (&global->switcheroo_control);
+}
+
static void
shell_global_init (ShellGlobal *global)
{
@@ -394,13 +423,13 @@ shell_global_init (ShellGlobal *global)
g_object_unref, g_object_unref);
global->switcheroo_cancellable = g_cancellable_new ();
- shell_net_hadess_switcheroo_control_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "net.hadess.SwitcherooControl",
- "/net/hadess/SwitcherooControl",
- global->switcheroo_cancellable,
- switcheroo_control_ready_cb,
- global);
+ g_bus_watch_name (G_BUS_TYPE_SYSTEM,
+ "net.hadess.SwitcherooControl",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ switcheroo_appeared_cb,
+ switcheroo_vanished_cb,
+ global,
+ NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]