[at-spi2-core/wip/carlosg/wayland-session-checks] Resort to WAYLAND_DISPLAY checks to avoid X11 connections



commit b68e60b75f4f6741da156d143c242b4a177a6434
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 21 15:59:37 2019 +0200

    Resort to WAYLAND_DISPLAY checks to avoid X11 connections
    
    Same reasoning applies (Opening and closing X11 displays may be from
    ineffective to harmful there), but the XDG_SESSION_TYPE check breaks
    for startx.
    
    Explicitly check that DISPLAY is present but WAYLAND_DISPLAY is not,
    in order to avoid this behavior.
    
    Pointed out at
    https://gitlab.gnome.org/GNOME/at-spi2-core/merge_requests/12

 atspi/atspi-misc.c                | 3 ++-
 bus/at-spi-bus-launcher.c         | 4 ++--
 registryd/deviceeventcontroller.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 8d70849..f680999 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -1601,7 +1601,8 @@ atspi_get_a11y_bus (void)
   if (address_env != NULL && *address_env != 0)
     address = g_strdup (address_env);
 #ifdef HAVE_X11
-  if (!address && g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0)
+  if (!address && g_getenv ("DISPLAY") != NULL &&
+      g_getenv ("WAYLAND_DISPLAY") == NULL)
     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 98f4114..436e6a3 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -466,7 +466,7 @@ ensure_a11y_bus (A11yBusLauncher *app)
 #endif
 
 #ifdef HAVE_X11
-  if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0)
+  if (g_getenv ("DISPLAY") != NULL && g_getenv ("WAYLAND_DISPLAY") == NULL)
     {
       Display *display = XOpenDisplay (NULL);
       if (display)
@@ -885,7 +885,7 @@ main (int    argc,
    * we don't want early login processes to pick up the stale address.
    */
 #ifdef HAVE_X11
-  if (g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0)
+  if (g_getenv ("DISPLAY") != NULL && g_getenv ("WAYLAND_DISPLAY") == NULL)
     {
       Display *display = XOpenDisplay (NULL);
       if (display)
diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c
index 0519b49..f37b8cf 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_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") == 0)
+  if (g_getenv ("DISPLAY") != NULL && g_getenv ("WAYLAND_DISPLAY") == NULL)
     spi_dec_setup_x11 (klass);
   else
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]