From 4190a470c56ed90d97af89711a30c4603a347858 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 18 Sep 2023 18:09:26 +0200 Subject: Add qtutils.is_wayland() Backported to v3.0.x as simpler fix: b317038a01094136d06d4cb769b7755450b94f61 --- doc/changelog.asciidoc | 2 ++ qutebrowser/keyinput/eventfilter.py | 4 ++-- qutebrowser/utils/qtutils.py | 5 +++++ tests/unit/utils/test_qtutils.py | 11 +++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index ddded0983..b02daf73e 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -30,6 +30,8 @@ Fixed - Navigating via hints to a remote URL from a file:// one works again. (#7847) - The timers related to the tab audible indicator and the auto follow timeout no longer accumulate connections over time. (#7888) +- The workaround for crashes when using drag & drop on Wayland with Qt 6.5.2 now also + works correctly when using `wayland-egl` rather than `wayland` as Qt platform. - Upgraded the bundled Qt version to 6.5.3. Note this is only relevant for the macOS/Windows releases, on Linux those will be upgraded via your distribution packages. This Qt patch release comes with diff --git a/qutebrowser/keyinput/eventfilter.py b/qutebrowser/keyinput/eventfilter.py index 306d4405b..a9e7e78aa 100644 --- a/qutebrowser/keyinput/eventfilter.py +++ b/qutebrowser/keyinput/eventfilter.py @@ -11,7 +11,7 @@ from qutebrowser.qt.gui import QKeyEvent, QWindow from qutebrowser.keyinput import modeman from qutebrowser.misc import quitter, objects -from qutebrowser.utils import objreg, debug, log +from qutebrowser.utils import objreg, debug, log, qtutils class EventFilter(QObject): @@ -86,7 +86,7 @@ class EventFilter(QObject): if ( ev_type == QEvent.Type.DragEnter and - objects.qapp.platformName() == "wayland" and + qtutils.is_wayland() and qVersion() == "6.5.2" ): # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-115757 diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py index ebcd6578f..5e36a90d2 100644 --- a/qutebrowser/utils/qtutils.py +++ b/qutebrowser/utils/qtutils.py @@ -123,6 +123,11 @@ def is_single_process() -> bool: return '--single-process' in args +def is_wayland() -> bool: + """Check if we are running on Wayland.""" + return objects.qapp.platformName() in ["wayland", "wayland-egl"] + + def check_overflow(arg: int, ctype: str, fatal: bool = True) -> int: """Check if the given argument is in bounds for the given type. diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index 541f4e4fe..3aceca668 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -110,6 +110,17 @@ def test_is_single_process(monkeypatch, stubs, backend, arguments, single_proces assert qtutils.is_single_process() == single_process +@pytest.mark.parametrize('platform, is_wayland', [ + ("wayland", True), + ("wayland-egl", True), + ("xcb", False), +]) +def test_is_wayland(monkeypatch, stubs, platform, is_wayland): + qapp = stubs.FakeQApplication(platform_name=platform) + monkeypatch.setattr(qtutils.objects, 'qapp', qapp) + assert qtutils.is_wayland() == is_wayland + + class TestCheckOverflow: """Test check_overflow.""" -- cgit v1.2.3-54-g00ecf