Only apply Wayland workaround in Wayland path

https://github.com/ankitects/anki/issues/1767#issuecomment-1562695240
This commit is contained in:
Damien Elmes 2023-05-29 19:07:54 +10:00
parent b618ab93a5
commit 93e1a6be22

View file

@ -523,12 +523,19 @@ def _run(argv: Optional[list[str]] = None, exec: bool = True) -> Optional[AnkiAp
profiler = cProfile.Profile()
profiler.enable()
if (
getattr(sys, "frozen", False)
and (os.getenv("QT_QPA_PLATFORM") == "wayland" or os.getenv("WAYLAND_DISPLAY"))
and not os.getenv("ANKI_WAYLAND")
):
if not os.getenv("DISPLAY"):
packaged = getattr(sys, "frozen", False)
x11_available = os.getenv("DISPLAY")
wayland_configured = qtmajor > 5 and (
os.getenv("QT_QPA_PLATFORM") == "wayland" or os.getenv("WAYLAND_DISPLAY")
)
wayland_forced = os.getenv("ANKI_WAYLAND")
if packaged and wayland_configured:
if wayland_forced or not x11_available:
# Work around broken fractional scaling in Wayland
# https://bugreports.qt.io/browse/QTBUG-113574
os.environ["QT_SCALE_FACTOR_ROUNDING_POLICY"] = "RoundPreferFloor"
if not x11_available:
print(
"Trying to use X11, but it is not available. Falling back to Wayland, which has some bugs:"
)
@ -576,11 +583,6 @@ def _run(argv: Optional[list[str]] = None, exec: bool = True) -> Optional[AnkiAp
if os.environ.get("ANKI_SOFTWAREOPENGL"):
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
# Work around broken fractional scaling in Wayland
# https://bugreports.qt.io/browse/QTBUG-113574
if is_lin and qtmajor > 5:
os.environ["QT_SCALE_FACTOR_ROUNDING_POLICY"] = "RoundPreferFloor"
# fix an issue on Windows, where Ctrl+Alt shortcuts are triggered by AltGr,
# preventing users from typing things like "@" through AltGr+Q on a German
# keyboard.