qutebrowser icon indicating copy to clipboard operation
qutebrowser copied to clipboard

Enabling Rocker Gestures & Disabling Back Forward Mouse buttons has no effect on new QT version.

Open lwilletts opened this issue 1 year ago • 8 comments

Version info: qutebrowser v3.0.0 Git commit: Backend: QtWebEngine 6.5.2, based on Chromium 108.0.5359.220 (from api) Qt: 6.5.2

Does the bug happen if you start with --temp-basedir?:

Yes

Description

Config settings below with the following values no not apply and work:

c.input.mouse.rocker_gestures = True
c.input.mouse.back_forward_buttons = False

How to reproduce

For rocker gestures, open any webpage and click through on any link - then try the rocker gesture of holding rmb then clicking lmb. Nothing happens. Likewise, for moving forward a page holding lmb and clicking rmb also does not function.

Mouse forward and back buttons work regardless of above setting.

lwilletts avatar Aug 22 '23 20:08 lwilletts

Reproduced with qutebrowser --qt-wrapper PyQt6 --debug --temp-basedir -s input.mouse.rocker_gestures true -s input.mouse.back_forward_buttons false yet works fine with Qt 5.

Might be the same root cause as here:

https://github.com/qutebrowser/qutebrowser/blob/8c2e23d248e4d2150aa159ae4ac4b464bdb286cd/qutebrowser/browser/eventfilter.py#L114-L119

The-Compiler avatar Aug 22 '23 23:08 The-Compiler

Might be the same root cause as here:

https://github.com/qutebrowser/qutebrowser/blob/8c2e23d248e4d2150aa159ae4ac4b464bdb286cd/qutebrowser/browser/eventfilter.py#L114-L119

This is exactly the case. Even with -s input.mouse.back_forward_buttons false back/forward mouse buttons are still registered and result in going back/forward in history.

To fix rocker gestures manual testing confirmed that we just need to call self._mousepress_backforward():

diff --git a/qutebrowser/browser/eventfilter.py b/qutebrowser/browser/eventfilter.py
index 1cff11ac4..e3300168c 100644
--- a/qutebrowser/browser/eventfilter.py
+++ b/qutebrowser/browser/eventfilter.py
@@ -111,7 +111,11 @@ class TabEventFilter(QObject):
         is_rocker_gesture = (config.val.input.mouse.rocker_gestures and
                              e.buttons() == Qt.MouseButton.LeftButton | Qt.MouseButton.RightButton)
 
-        if e.button() in [Qt.MouseButton.XButton1, Qt.MouseButton.XButton2] or is_rocker_gesture:
+        if is_rocker_gesture:
+            self._mousepress_backforward(e)
+            return True
+
+        if e.button() in [Qt.MouseButton.XButton1, Qt.MouseButton.XButton2]:
             if not machinery.IS_QT6:
                 self._mousepress_backforward(e)
             # FIXME:qt6 For some reason, this doesn't filter the action on

I have no idea why Qt is not filtering the event for Qt.MouseButton.XButton1 or Qt.MouseButton.XButton2, though.

pylbrecht avatar Sep 07 '23 12:09 pylbrecht

@The-Compiler, do you have any starting point on how to debug this further? I'm lost right now.

// edit To be a little more specific: the comment stating that

for some reason, this doesn't filter the action on Qt 6...

still applies. Somehow, even though we return True from eventFilter(), Qt6 does not filter the event. As already mentioned in https://github.com/qutebrowser/qutebrowser/issues/7853#issuecomment-1710096500, I observed the following:

Even with -s input.mouse.back_forward_buttons false back/forward mouse buttons are still registered and result in going back/forward in history.

I browsed these related parts in the code, but could not explain to myself (probably due to lack of knowledge of the inner workings of Qt's event system) why Qt would not filter the event:

  • https://github.com/qutebrowser/qutebrowser/blob/b070cf45dbed27771578d98f3f4129d1f52a28f3/qutebrowser/browser/webengine/webenginetab.py#L1305-L1314
  • qutebrowser/browser/eventfilter.py

pylbrecht avatar Sep 08 '23 06:09 pylbrecht

I browsed these related parts in the code, but could not explain to myself (probably due to lack of knowledge of the inner workings of Qt's event system) why Qt would not filter the event: [...]

That's what I was trying to find out last time I looked at this, and I couldn't from a quick look. It'll be a few days until I get around to taking a closer look again.

I wonder if GammaRay could provide more information about how events are being propagated and such.

The-Compiler avatar Sep 12 '23 06:09 The-Compiler

I got GammaRay working and attached to a qutebrowser process:

./.tox/py311-pyqt65/bin/python3 -m qutebrowser -s input.mouse.back_forward_buttons false --temp-basedir
# find pid via `ps aux | grep tox`
gammaray --pid <pid of tox>

Though I can't make too much sense out of its output:

gammaray-1 gammaray-2

There are two receivers of the MousePress* events:

  • MainWindow
  • some "invalid" receiver (GammaRay can't link it to a widget)

pylbrecht avatar Sep 17 '23 10:09 pylbrecht

Here's mine with a locally built Qt with debug symbols. This looks like an anonymous object which I assume is a focus proxy, based on looking at other objects, but I don't know for sure. (> receiver > means I'm showing the attributes of the "receiver" attribute of the selected object) image

You should (hopefully) be able to right click and ask it to show in the Object view which goes to this for me: image

toofar avatar Sep 17 '23 11:09 toofar

As this turned out to be a little over my head, I will unassign myself and leave it up to the experts to solve this.

pylbrecht avatar Sep 22 '23 04:09 pylbrecht

Unfortunately haven't gotten around to taking another look at this yet.

The-Compiler avatar Dec 08 '23 16:12 The-Compiler