diff options
author | Mike Gorse <mgorse@suse.com> | 2019-05-20 09:59:22 +0000 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2019-05-20 09:59:22 +0000 |
commit | ffba513d3c4a275fd665c0cbc4fb9e148eb4d258 (patch) | |
tree | a9a23e4a0a85acbd6308ae0602c3620a31b7a530 | |
parent | 218af4ee001d1093c0328a55a00e0ae9e4fc3262 (diff) | |
parent | c52d4c203866551ef1e1a2909c1d5cf47ddfbcd1 (diff) | |
download | at-spi2-core-ffba513d3c4a275fd665c0cbc4fb9e148eb4d258.tar.gz |
Merge branch 'wip/carlosg/x11-session-checks' into 'master'
Check for X11 session before using X11 paths
See merge request GNOME/at-spi2-core!12
-rw-r--r-- | atspi/atspi-misc.c | 2 | ||||
-rw-r--r-- | bus/at-spi-bus-launcher.c | 101 | ||||
-rw-r--r-- | registryd/deviceeventcontroller.c | 2 |
3 files changed, 30 insertions, 75 deletions
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c index f0c8fdc8..8d708496 100644 --- a/atspi/atspi-misc.c +++ b/atspi/atspi-misc.c @@ -1601,7 +1601,7 @@ atspi_get_a11y_bus (void) if (address_env != NULL && *address_env != 0) address = g_strdup (address_env); #ifdef HAVE_X11 - if (!address) + if (!address && g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0) address = get_accessibility_bus_address_x11 (); #endif if (!address) diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index 17f01c02..98f4114c 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -466,20 +466,21 @@ ensure_a11y_bus (A11yBusLauncher *app) #endif #ifdef HAVE_X11 - { - Display *display = XOpenDisplay (NULL); - if (display) - { - Atom bus_address_atom = XInternAtom (display, "AT_SPI_BUS", False); - XChangeProperty (display, - XDefaultRootWindow (display), - bus_address_atom, - XA_STRING, 8, PropModeReplace, - (guchar *) app->a11y_bus_address, strlen (app->a11y_bus_address)); - XFlush (display); - XCloseDisplay (display); - } - } + if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0) + { + Display *display = XOpenDisplay (NULL); + if (display) + { + Atom bus_address_atom = XInternAtom (display, "AT_SPI_BUS", False); + XChangeProperty (display, + XDefaultRootWindow (display), + bus_address_atom, + XA_STRING, 8, PropModeReplace, + (guchar *) app->a11y_bus_address, strlen (app->a11y_bus_address)); + XFlush (display); + XCloseDisplay (display); + } + } #endif return TRUE; @@ -771,50 +772,6 @@ init_sigterm_handling (A11yBusLauncher *app) app); } -static gboolean -already_running () -{ -#ifdef HAVE_X11 - Atom AT_SPI_BUS; - Atom actual_type; - Display *bridge_display; - int actual_format; - unsigned char *data = NULL; - unsigned long nitems; - unsigned long leftover; - gboolean result = FALSE; - - bridge_display = XOpenDisplay (NULL); - if (!bridge_display) - return FALSE; - - AT_SPI_BUS = XInternAtom (bridge_display, "AT_SPI_BUS", False); - XGetWindowProperty (bridge_display, - XDefaultRootWindow (bridge_display), - AT_SPI_BUS, 0L, - (long) BUFSIZ, False, - (Atom) 31, &actual_type, &actual_format, - &nitems, &leftover, &data); - - if (data) - { - GDBusConnection *bus; - bus = g_dbus_connection_new_for_address_sync ((const gchar *)data, 0, - NULL, NULL, NULL); - if (bus != NULL) - { - result = TRUE; - g_object_unref (bus); - } - } - - XCloseDisplay (bridge_display); - return result; -#else - return FALSE; -#endif -} - static GSettings * get_schema (const gchar *name) { @@ -860,9 +817,6 @@ main (int argc, gboolean screen_reader_set = FALSE; gint i; - if (already_running ()) - return 0; - _global_app = g_slice_new0 (A11yBusLauncher); _global_app->loop = g_main_loop_new (NULL, FALSE); @@ -931,19 +885,20 @@ main (int argc, * we don't want early login processes to pick up the stale address. */ #ifdef HAVE_X11 - { - Display *display = XOpenDisplay (NULL); - if (display) - { - Atom bus_address_atom = XInternAtom (display, "AT_SPI_BUS", False); - XDeleteProperty (display, - XDefaultRootWindow (display), - bus_address_atom); + if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0) + { + Display *display = XOpenDisplay (NULL); + if (display) + { + Atom bus_address_atom = XInternAtom (display, "AT_SPI_BUS", False); + XDeleteProperty (display, + XDefaultRootWindow (display), + bus_address_atom); - XFlush (display); - XCloseDisplay (display); - } - } + XFlush (display); + XCloseDisplay (display); + } + } #endif if (_global_app->a11y_launch_error_message) diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 4e25ad61..0519b493 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -1856,7 +1856,7 @@ spi_device_event_controller_class_init (SpiDEControllerClass *klass) object_class->finalize = spi_device_event_controller_object_finalize; #ifdef HAVE_X11 - if (g_getenv ("DISPLAY")) + if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0) spi_dec_setup_x11 (klass); else #endif |