Skip to content

Commit

Permalink
Fallback to Wayland if Xorg is not available
Browse files Browse the repository at this point in the history
In environments where Anaconda handles the overall GUI environment
setup (eq. netinst/boot.iso) try to use Wayland compositor if
Xorg server is not found.

Also add support for a (temporary?) boot inst.wayland boot option,
that can be used to force Wayland compositor to be used. This makes it
possible to check if Waland can be used in the given environment even
if the given installation image still contains Xorg.
  • Loading branch information
M4rtinK committed Nov 9, 2023
1 parent a70ac7c commit 81308c8
Showing 1 changed file with 87 additions and 11 deletions.
98 changes: 87 additions & 11 deletions pyanaconda/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.process_watchers import WatchProcesses
from pyanaconda.core.kernel import kernel_arguments
from pyanaconda import startup_utils
from pyanaconda.core import util, constants, hw
from pyanaconda import vnc
Expand Down Expand Up @@ -245,6 +246,56 @@ def write_xdriver(driver, root=None):
f.close()


# Wayland

def start_wayland_compositor():
"""Start Wayland compositor for the Anaconda GUI.
Add XDG_DATA_DIRS to the environment to pull in our overridden schema
files.
FIXME: Will XDG_DATA_DIRS work with Wayland compositor ?
"""
datadir = os.environ.get('ANACONDA_DATADIR', '/usr/share/anaconda')
if 'XDG_DATA_DIRS' in os.environ:
xdg_data_dirs = datadir + '/window-manager:' + os.environ['XDG_DATA_DIRS']
else:
xdg_data_dirs = datadir + '/window-manager:/usr/share'

def wayland_preexec():
# to set GUI subprocess SIGINT handler
# FIXME: does this even work with a Wayland compoitor ?
signal.signal(signal.SIGINT, signal.SIG_IGN)

childproc = util.startProgram(["gnome-kiosk", "--wayland-display", ":1", "--sm-disable",
"--wayland"], env_add={'XDG_DATA_DIRS': xdg_data_dirs},
preexec_fn=wayland_preexec)
WatchProcesses.watch_process(childproc, "gnome-kiosk")


def set_wayland_resolution(runres):
"""Set Wayland server screen resolution.
FIXME: implement this using Mutter DBus API
FIXME: keep runres or use horizontal/vertical resolution instead ?
:param str runres: a resolution specification string
"""
log.error("FIXME: set screen resolution - not yet implemented on Wayland")


def do_extra_wayland_actions(runres, gui_mode):
"""Perform Wayland related actions not related to startup.
:param str runres: a resolution specification string
:param gui_mode: an Anaconda display mode
"""
if runres and gui_mode and not flags.usevnc:
set_wayland_resolution(runres)

start_user_systemd()


# general display startup
def setup_display(anaconda, options):
"""Setup the display for the installation environment.
Expand Down Expand Up @@ -319,16 +370,35 @@ def setup_display(anaconda, options):
for error_message in vnc_error_messages:
stdout_log.warning(error_message)

# Should we try to start Xorg?
want_x = anaconda.gui_mode and not (flags.preexisting_x11 or flags.usevnc)

# Is Xorg is actually available?
if want_x and not os.access("/usr/bin/Xorg", os.X_OK):
stdout_log.warning(_("Graphical installation is not available. "
"Starting text mode."))
time.sleep(2)
anaconda.display_mode = constants.DisplayModes.TUI
want_x = False
# Xorg or Wayland?
want_x = False
want_wayland = False

# try to run in local GUI mode
if anaconda.gui_mode and not (flags.preexisting_x11 or flags.usevnc):
# is Xorg actually available?
xorg_server_available = os.access("/usr/bin/Xorg", os.X_OK)

# is our Wayland compositor available ?
wayland_compositor_available = os.access("/usr/bin/gnome-kiosk", os.X_OK)

# do we have at least one of the needed deps we need to run in graphical mode ?
if xorg_server_available:
# check for Wayland override
if "wayland" in kernel_arguments and wayland_compositor_available:
# this way we can test if insaller on Wayland works on a given system
want_wayland = True
else:
# no Wayland override or no Wayland, just use X
want_x = True
elif wayland_compositor_available:
want_wayland = True
else:
# neither X or Wayland is available
anaconda.display_mode = constants.DisplayModes.TUI
stdout_log.warning(_("Graphical installation is not available. "
"Starting text mode."))
time.sleep(2)

if anaconda.tui_mode and flags.vncquestion:
# we prefer vnc over text mode, so ask about that
Expand All @@ -346,7 +416,13 @@ def setup_display(anaconda, options):

# check_memory may have changed the display mode
want_x = want_x and (anaconda.gui_mode)
if want_x:
want_wayland = want_wayland and (anaconda.gui_mode)

if want_wayland:
log.debug("Using Wayland compositor to provide locally running graphical interface.")
start_wayland_compositor()
elif want_x:
log.debug("Using Xorg server to provide locally running graphical interface.")
try:
start_x11(xtimeout)
do_startup_x11_actions()
Expand Down

0 comments on commit 81308c8

Please sign in to comment.