From 191f578b574ab84fa8b52278e42eebf7aa80847a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 28 May 2017 07:08:10 -0400 Subject: [PATCH] linux: Make system D-Bus connection available (in addition to session). --- src/core/linux/SDL_dbus.c | 19 +++++++++++++------ src/core/linux/SDL_dbus.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index b435b5cce..e6676f7c8 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); - dbus.shutdown(); - SDL_memset(&dbus, 0, sizeof(dbus)); } + if (dbus.shutdown) { + dbus.shutdown(); + } + SDL_zero(dbus); UnloadDBUSLibrary(); } diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index ab9e4d69c..ee568e818 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 *);