linux: Make system D-Bus connection available (in addition to session).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c
index b435b5c..e6676f7 100644
--- a/src/core/linux/SDL_dbus.c
+++ b/src/core/linux/SDL_dbus.c
@@ -112,14 +112,15 @@ SDL_DBus_Init(void)
DBusError err;
dbus.error_init(&err);
dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err);
+ if (!dbus.error_is_set(&err)) {
+ dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err);
+ }
if (dbus.error_is_set(&err)) {
dbus.error_free(&err);
- if (dbus.session_conn) {
- dbus.connection_unref(dbus.session_conn);
- dbus.session_conn = NULL;
- }
+ SDL_DBus_Quit();
return; /* oh well */
}
+ dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0);
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
}
}
@@ -127,12 +128,18 @@ SDL_DBus_Init(void)
void
SDL_DBus_Quit(void)
{
+ if (dbus.system_conn) {
+ dbus.connection_close(dbus.system_conn);
+ dbus.connection_unref(dbus.system_conn);
+ }
if (dbus.session_conn) {
dbus.connection_close(dbus.session_conn);
dbus.connection_unref(dbus.session_conn);
+ }
+ if (dbus.shutdown) {
dbus.shutdown();
- SDL_memset(&dbus, 0, sizeof(dbus));
}
+ SDL_zero(dbus);
UnloadDBUSLibrary();
}
diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h
index ab9e4d6..ee568e8 100644
--- a/src/core/linux/SDL_dbus.h
+++ b/src/core/linux/SDL_dbus.h
@@ -32,6 +32,7 @@
typedef struct SDL_DBusContext {
DBusConnection *session_conn;
+ DBusConnection *system_conn;
DBusConnection *(*bus_get_private)(DBusBusType, DBusError *);
dbus_bool_t (*bus_register)(DBusConnection *, DBusError *);