Suppress context menu properly with rocker gestures

For some reason, the event filter stopped inhibiting the context menu with Qt
5.9 (or possibly 5.8).

(cherry picked from commit 0ed215d81f)

Remove unnecessary return

(cherry picked from commit 8159206576)
This commit is contained in:
Florian Bruhin 2020-06-30 21:32:11 +02:00
parent 8ade7d22f2
commit 05ba5476b9
2 changed files with 7 additions and 12 deletions

View File

@ -116,7 +116,6 @@ class TabEventFilter(QObject):
QEvent.MouseButtonPress: self._handle_mouse_press,
QEvent.MouseButtonRelease: self._handle_mouse_release,
QEvent.Wheel: self._handle_wheel,
QEvent.ContextMenu: self._handle_context_menu,
QEvent.KeyRelease: self._handle_key_release,
}
self._ignore_wheel_event = False
@ -210,17 +209,6 @@ class TabEventFilter(QObject):
return False
def _handle_context_menu(self, _e):
"""Suppress context menus if rocker gestures are turned on.
Args:
e: The QContextMenuEvent.
Return:
True if the event should be filtered, False otherwise.
"""
return config.val.input.mouse.rocker_gestures
def _handle_key_release(self, e):
"""Ignore repeated key release events going to the website.

View File

@ -151,6 +151,13 @@ class WebEngineView(QWebEngineView):
tab = shared.get_tab(self._win_id, target)
return tab._widget # pylint: disable=protected-access
def contextMenuEvent(self, ev):
"""Prevent context menus when rocker gestures are enabled."""
if config.val.input.mouse.rocker_gestures:
ev.ignore()
return
super().contextMenuEvent(ev)
class WebEnginePage(QWebEnginePage):