From 8e5666b3064d03041094eb0b3e49952d14c1378b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Jul 2022 08:22:07 +0530 Subject: [PATCH] Linux: Default to using XWayland instead of native Wayland as there are various bugs with Qt+Wayland . You can set the env var QT_QPA_PLATFORM=wayland to force calibre to use Wayland. --- manual/customize.rst | 1 + src/calibre/gui2/__init__.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/manual/customize.rst b/manual/customize.rst index 217c581624..fd8df15b0b 100644 --- a/manual/customize.rst +++ b/manual/customize.rst @@ -49,6 +49,7 @@ Environment variables the system theme -- beware of crashes and hangs. * ``CALIBRE_SHOW_DEPRECATION_WARNINGS`` - causes calibre to print deprecation warnings to stdout. Useful for calibre developers. * ``CALIBRE_NO_DEFAULT_PROGRAMS`` - prevent calibre from automatically registering the filetypes it is capable of handling with Windows. + * ``QT_QPA_PLATFORM`` - On Linux set this to ``wayland`` to force calibre to use Wayland. Note however that Qt + Wayland is extremely buggy. * ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys * ``http_proxy``, ``https_proxy`` - used on Linux to specify an HTTP(S) proxy diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 22ae1051a6..dc7bc03df1 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1059,6 +1059,16 @@ class Application(QApplication): if set_app_uid(windows_app_uid): self.windows_app_uid = windows_app_uid self.file_event_hook = None + if not iswindows and not ismacos and not os.environ.get('QT_QPA_PLATFORM') and not headless: + # Various issues in Wayland make it unuseable so prevent Qt from + # using Wayland unless the user asks for it explicitly. + # In KDE right clicking on the book list causes left clicks on it + # to stop working till kwin is restarted. On GNOME there are no + # native window decorations. There have been reports of left clicks + # not working in GNOME though I cannot reproduce. So force use of + # XWayland. + os.environ['QT_QPA_PLATFORM'] = 'xcb' + if isfrozen and QT_VERSION <= 0x050700 and 'wayland' in os.environ.get('QT_QPA_PLATFORM', ''): os.environ['QT_QPA_PLATFORM'] = 'xcb' if override_program_name: