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
This commit is contained in:
Bastien Nocera 2020-04-28 17:24:06 +02:00 committed by Florian Müllner
parent bf8b9cecf5
commit 49605c7b00

View File

@ -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,
g_bus_watch_name (G_BUS_TYPE_SYSTEM,
"net.hadess.SwitcherooControl",
"/net/hadess/SwitcherooControl",
global->switcheroo_cancellable,
switcheroo_control_ready_cb,
global);
G_BUS_NAME_WATCHER_FLAGS_NONE,
switcheroo_appeared_cb,
switcheroo_vanished_cb,
global,
NULL);
}
static void