summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorMike Gorse <mgorse@suse.com>2019-05-20 09:59:22 +0000
committerMike Gorse <mgorse@suse.com>2019-05-20 09:59:22 +0000
commitffba513d3c4a275fd665c0cbc4fb9e148eb4d258 (patch)
treea9a23e4a0a85acbd6308ae0602c3620a31b7a530 /bus
parent218af4ee001d1093c0328a55a00e0ae9e4fc3262 (diff)
parentc52d4c203866551ef1e1a2909c1d5cf47ddfbcd1 (diff)
downloadat-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
Diffstat (limited to 'bus')
-rw-r--r--bus/at-spi-bus-launcher.c101
1 files changed, 28 insertions, 73 deletions
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)