Skip to content

Commit

Permalink
Ensure there's always an opened GDK display present
Browse files Browse the repository at this point in the history
Sometimes it happens that there's no GDK display present and this
leads to a traceback when a keyCombo() is sent. It's not entirely
sure if this is a bug in dogtail or if we should open the display
explicitly ourselves. We can remove this piece of code in the future
if we find out that this should rather get fixed in dogtail.
  • Loading branch information
jikortus committed Dec 17, 2024
1 parent 3c92a13 commit f10a506
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions anabot/runtime/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ def run_test(file_path, appname="anaconda", children_required=0):
that this file is already processed by anabot preprocessor.
See anabot.preprocessor package.
"""
from gi import require_version
require_version('Gdk', '3.0')
from gi.repository import Gdk # pylint: disable=no-name-in-module

# Workaround for a situation when a default display is missing for some reason.
# It is not clear at this point whether this really is a workaround and it should be
# fixed (potentially) in dogtail.
if Gdk.Display.get_default() is None:
import os
logger.debug("Default GDK display not found! Opening the display explicitly.")
if "WAYLAND_DISPLAY" in os.environ.keys():
display_name = os.environ["WAYLAND_DISPLAY"]
elif "DISPLAY" in os.environ.keys():
display_name = os.environ["DISPLAY"]
else:
logger.error("Can't find a display name to open explicitly, Anabot run may fail!")
# Let's assume Anaconda running on Wayland, as this is likely the only problematic
# configuration anyway.
display_name = "wl-sysinstall-0"
Gdk.Display.open(display_name)
logger.debug(f"Explicitly opened display: '{Gdk.Display.get_default().get_name()}'")

import dogtail.config # pylint: disable=import-error
dogtail.config.config.checkForA11y = False
dogtail.config.config.typingDelay = 0.2
Expand Down

0 comments on commit f10a506

Please sign in to comment.