[at-spi2-core/benzea/xwayland-on-demand-support-for-root-apps] bus: Set X root property when Xwayland starts on-demand




commit 8d514cc1b8456224fa687bc0e32d26c3b4b994c0
Author: Benjamin Berg <bberg redhat com>
Date:   Wed May 19 15:08:42 2021 +0200

    bus: Set X root property when Xwayland starts on-demand
    
    On wayland, the X11 server may not always be running so that
    at-spi-bus-launcher cannot set it when it is starting.
    
    This is usually not a big problem, as applications can retrieve the a11y
    bus address by querying the session bus. Unfortunately, there may be
    exceptions such as applications that are run as a different user.
    
    We can easily solve this problem by setting the X11 root property when
    the Xwayland server is started. To do so, install a simple script to
    /etc/xdg/Xwayland-session.d/ that queries the session bus and sets the
    root property.
    
    This script is only needed when Xwayland is started on-demand, which can
    only happen on systemd enabled sessions. However, it is always safe to
    install, and there will be no severe side effects should the script be
    running needlessly or failing.
    
    Closes: #34

 bus/00-at-spi   | 10 ++++++++++
 bus/meson.build |  8 ++++++++
 2 files changed, 18 insertions(+)
---
diff --git a/bus/00-at-spi b/bus/00-at-spi
new file mode 100755
index 0000000..dc3bb60
--- /dev/null
+++ b/bus/00-at-spi
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Copy a11y bus address from the DBus session bus to the X11 root property.
+# This is useful when Xwayland is started on demand and if the user has an
+# application with X11 access that does not have access to the session bus.
+
+ADDR="$( busctl call --user org.a11y.Bus /org/a11y/bus org.a11y.Bus GetAddress )" || exit 0
+ADDR="$( echo $ADDR | sed 's/s "\(.*\)"/\1/' )" || exit 0
+
+exec xprop -root -format AT_SPI_BUS 8s -set AT_SPI_BUS "$ADDR"
diff --git a/bus/meson.build b/bus/meson.build
index f6c32c9..3504fb3 100644
--- a/bus/meson.build
+++ b/bus/meson.build
@@ -6,6 +6,7 @@ accessibility_conf.set('DATADIR', atspi_datadir)
 
 busconfig_dir = join_paths(atspi_datadir, 'defaults/at-spi2')
 session_dir = join_paths(atspi_sysconfdir, 'xdg/autostart')
+xwayland_session_dir = join_paths(atspi_sysconfdir, 'xdg/Xwayland-session.d')
 
 configure_file(input: 'accessibility.conf.in',
                output: 'accessibility.conf',
@@ -27,6 +28,13 @@ configure_file(input: 'at-spi-dbus-bus.service.in',
                configuration: libexec_conf,
                install_dir: systemd_user_dir)
 
+if x11_dep.found()
+  # Note: It is safe to always install it. However, we only need this on
+  #       systemd enabled machines where Xwayland may be started on-demand.
+  install_data('00-at-spi',
+               install_dir: xwayland_session_dir)
+endif
+
 launcher_args = [
              '-DSYSCONFDIR="@0@"'.format(atspi_sysconfdir),
              '-DDATADIR="@0@"'.format(atspi_datadir),


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