summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-06-08 12:37:29 +0200
committerFlorian Bruhin <me@the-compiler.org>2023-06-08 12:37:29 +0200
commit37e1fff42f6a206f4faf0eaa704275369a844634 (patch)
tree6d2449c39d5cc191716e55a844e1ed61b330d3cf
parent9380c10f23ca14bcd165ed35607407bd6ee1754f (diff)
downloadqutebrowser-37e1fff42f6a206f4faf0eaa704275369a844634.tar.gz
qutebrowser-37e1fff42f6a206f4faf0eaa704275369a844634.zip
nativeeventfilter: Only activate after hierarchy change
-rw-r--r--qutebrowser/misc/nativeeventfilter.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/qutebrowser/misc/nativeeventfilter.py b/qutebrowser/misc/nativeeventfilter.py
index 7f7dc0b3c..39de0534d 100644
--- a/qutebrowser/misc/nativeeventfilter.py
+++ b/qutebrowser/misc/nativeeventfilter.py
@@ -98,6 +98,14 @@ class xcb_query_extension_reply_t(ctypes.Structure):
class NativeEventFilter(QAbstractNativeEventFilter):
+
+ # Return values for nativeEventFilter.
+ #
+ # Tuple because PyQt uses the second value as the *result out-pointer, which
+ # according to the Qt documentation is only used on Windows.
+ _PASS_EVENT_RET = (False, 0)
+ _FILTER_EVENT_RET = (True, 0)
+
def __init__(self) -> None:
super().__init__()
xcb = ctypes.cdll.LoadLibrary("libxcb.so.1")
@@ -123,6 +131,8 @@ class NativeEventFilter(QAbstractNativeEventFilter):
xcb.xcb_disconnect(conn)
+ self._active = False # Set to true when getting hierarchy event
+
def nativeEventFilter(self, evtype: bytes, message: int) -> Tuple[bool, int]:
# We're only installed when the platform plugin is xcb
assert evtype == b"xcb_generic_event_t", evtype
@@ -138,13 +148,19 @@ class NativeEventFilter(QAbstractNativeEventFilter):
if (
event.response_type == _XCB_GE_GENERIC
and event.extension == self.xinput_opcode
- and event.event_type in _PROBLEMATIC_XINPUT_EVENTS
):
- name = XcbInputOpcodes(event.event_type).name
- log.misc.warning(f"Ignoring problematic XInput event {name}")
- return (True, 0)
-
- return (False, 0)
+ if not self._active and event.event_type == XcbInputOpcodes.HIERARCHY:
+ log.misc.warning(
+ "Got XInput HIERARCHY event, future swipe/pinch/touch events will "
+ "be ignored to avoid a Qt 6.5.1 crash"
+ )
+ self._active = True
+ elif self._active and event.event_type in _PROBLEMATIC_XINPUT_EVENTS:
+ name = XcbInputOpcodes(event.event_type).name
+ log.misc.warning(f"Ignoring problematic XInput event {name}")
+ return self._FILTER_EVENT_RET
+
+ return self._PASS_EVENT_RET
def init() -> None: