Add a "visible" option flag and use it to hide various settings that only work on X11 if you aren't on X11.

This is in support of #4882
This commit is contained in:
Daniel Johnson 2024-08-13 18:43:58 -04:00 committed by Mathieu Comandon
parent ea28991896
commit f56289e257
4 changed files with 28 additions and 11 deletions

View file

@ -149,6 +149,13 @@ class ConfigBox(VBox):
option_key = option["option"] option_key = option["option"]
value = self.config.get(option_key) value = self.config.get(option_key)
if "visible" in option:
if callable(option["visible"]):
option["visible"] = option["visible"]()
if not option["visible"]:
continue
if callable(option.get("choices")) and option["type"] != "choice_with_search": if callable(option.get("choices")) and option["type"] != "choice_with_search":
option["choices"] = option["choices"]() option["choices"] = option["choices"]()
if callable(option.get("condition")): if callable(option.get("condition")):

View file

@ -3,11 +3,11 @@
from gettext import gettext as _ from gettext import gettext as _
import gi import gi
from gi.repository import Gdk, Gtk from gi.repository import Gtk
from lutris.database.games import get_games from lutris.database.games import get_games
from lutris.game import Game from lutris.game import Game
from lutris.util import cache_single from lutris.util.display import is_display_x11
try: try:
gi.require_version("AppIndicator3", "0.1") gi.require_version("AppIndicator3", "0.1")
@ -18,13 +18,8 @@ except (ImportError, ValueError):
APP_INDICATOR_SUPPORTED = False APP_INDICATOR_SUPPORTED = False
@cache_single def supports_status_icon() -> bool:
def supports_status_icon(): return bool(APP_INDICATOR_SUPPORTED or is_display_x11())
if APP_INDICATOR_SUPPORTED:
return True
display = Gdk.Display.get_default()
return "x11" in type(display).__name__.casefold()
class LutrisStatusIcon: class LutrisStatusIcon:

View file

@ -6,7 +6,7 @@ from gettext import gettext as _
from lutris import runners from lutris import runners
from lutris.util import linux, system from lutris.util import linux, system
from lutris.util.display import DISPLAY_MANAGER, SCREEN_SAVER_INHIBITOR, is_compositing_enabled from lutris.util.display import DISPLAY_MANAGER, SCREEN_SAVER_INHIBITOR, is_compositing_enabled, is_display_x11
from lutris.util.graphics.gpu import GPUS from lutris.util.graphics.gpu import GPUS
@ -131,6 +131,7 @@ system_options = [ # pylint: disable=invalid-name
"type": "bool", "type": "bool",
"label": _("Restore resolution on game exit"), "label": _("Restore resolution on game exit"),
"default": False, "default": False,
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _( "help": _(
"Some games don't restore your screen resolution when \n" "Some games don't restore your screen resolution when \n"
@ -145,7 +146,8 @@ system_options = [ # pylint: disable=invalid-name
"type": "bool", "type": "bool",
"default": False, "default": False,
"advanced": True, "advanced": True,
"condition": is_compositing_enabled(), "visible": is_display_x11,
"condition": is_compositing_enabled,
"help": _("Disable desktop effects while game is running, " "reducing stuttering and increasing performance"), "help": _("Disable desktop effects while game is running, " "reducing stuttering and increasing performance"),
}, },
{ {
@ -169,6 +171,7 @@ system_options = [ # pylint: disable=invalid-name
"label": _("SDL 1.2 Fullscreen Monitor"), "label": _("SDL 1.2 Fullscreen Monitor"),
"choices": get_output_list, "choices": get_output_list,
"default": "off", "default": "off",
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _( "help": _(
"Hint SDL 1.2 games to use a specific monitor when going " "Hint SDL 1.2 games to use a specific monitor when going "
@ -183,6 +186,7 @@ system_options = [ # pylint: disable=invalid-name
"label": _("Turn off monitors except"), "label": _("Turn off monitors except"),
"choices": get_output_choices, "choices": get_output_choices,
"default": "off", "default": "off",
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _( "help": _(
"Only keep the selected screen active while the game is " "Only keep the selected screen active while the game is "
@ -197,6 +201,7 @@ system_options = [ # pylint: disable=invalid-name
"type": "choice", "type": "choice",
"label": _("Switch resolution to"), "label": _("Switch resolution to"),
"advanced": True, "advanced": True,
"visible": is_display_x11,
"choices": get_resolution_choices, "choices": get_resolution_choices,
"default": "off", "default": "off",
"help": _("Switch to this screen resolution while the game is running."), "help": _("Switch to this screen resolution while the game is running."),
@ -501,6 +506,7 @@ system_options = [ # pylint: disable=invalid-name
(_("24BPP (16M colors)"), "24bpp"), (_("24BPP (16M colors)"), "24bpp"),
), ),
"default": "off", "default": "off",
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _("Run program in Xephyr to support 8BPP and 16BPP color modes"), "help": _("Run program in Xephyr to support 8BPP and 16BPP color modes"),
}, },
@ -509,6 +515,7 @@ system_options = [ # pylint: disable=invalid-name
"option": "xephyr_resolution", "option": "xephyr_resolution",
"type": "string", "type": "string",
"label": _("Xephyr resolution"), "label": _("Xephyr resolution"),
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _("Screen resolution of the Xephyr server"), "help": _("Screen resolution of the Xephyr server"),
}, },
@ -518,6 +525,7 @@ system_options = [ # pylint: disable=invalid-name
"type": "bool", "type": "bool",
"label": _("Xephyr Fullscreen"), "label": _("Xephyr Fullscreen"),
"default": True, "default": True,
"visible": is_display_x11,
"advanced": True, "advanced": True,
"help": _("Open Xephyr in fullscreen (at the desktop resolution)"), "help": _("Open Xephyr in fullscreen (at the desktop resolution)"),
}, },

View file

@ -46,6 +46,13 @@ def get_default_dpi():
return 96 return 96
@cache_single
def is_display_x11():
"""True if"""
display = Gdk.Display.get_default()
return "x11" in type(display).__name__.casefold()
class DisplayManager: class DisplayManager:
"""Get display and resolution using GnomeDesktop""" """Get display and resolution using GnomeDesktop"""