diff --git a/README.asciidoc b/README.asciidoc index bb714ec94..bb0f5b106 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -150,6 +150,7 @@ Contributors, sorted by the number of commits in descending order: * Matthias Lisin * Helen Sherwood-Taylor * HalosGhost +* Gregor Pohl * Eivind Uggedal * Andreas Fischer // QUTE_AUTHORS_END diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 4dae48081..2149a4de4 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -78,6 +78,7 @@ |<>|Whether to forward unbound keys to the webview in normal mode. |<>|Enables or disables the Spatial Navigation feature |<>|Whether hyperlinks should be included in the keyboard focus chain. +|<>|Whether to enable Opera-like mouse rocker gestures. This disables the context menu. |============== .Quick reference for section ``tabs'' @@ -731,6 +732,17 @@ Valid values: Default: +pass:[true]+ +[[input-rocker-gestures]] +=== rocker-gestures +Whether to enable Opera-like mouse rocker gestures. This disables the context menu. + +Valid values: + + * +true+ + * +false+ + +Default: +pass:[false]+ + == tabs Configuration of the tab bar. diff --git a/qutebrowser/browser/webview.py b/qutebrowser/browser/webview.py index 13b2cbb9b..8484879fd 100644 --- a/qutebrowser/browser/webview.py +++ b/qutebrowser/browser/webview.py @@ -143,6 +143,8 @@ class WebView(QWebView): self.setZoomFactor(float(config.get('ui', 'default-zoom')) / 100) self._default_zoom_changed = False objreg.get('config').changed.connect(self.on_config_changed) + if config.get('input', 'rocker-gestures'): + self.setContextMenuPolicy(Qt.PreventContextMenu) def __repr__(self): url = utils.elide(self.url().toDisplayString(), 50) @@ -178,6 +180,11 @@ class WebView(QWebView): 100) self._default_zoom_changed = False self.init_neighborlist() + elif section == 'input' and option == 'rocker-gestures': + if config.get('input', 'rocker-gestures'): + self.setContextMenuPolicy(Qt.PreventContextMenu) + else: + self.setContextMenuPolicy(Qt.DefaultContextMenu) def init_neighborlist(self): """Initialize the _zoom neighborlist.""" @@ -192,15 +199,15 @@ class WebView(QWebView): Args: e: The QMouseEvent. """ - if e.button() == Qt.XButton1: - # Back button on mice which have it. + if e.button() in (Qt.XButton1, Qt.LeftButton): + # Back button on mice which have it, or rocker gesture if self.page().history().canGoBack(): self.back() else: message.error(self._win_id, "At beginning of history.", immediately=True) - elif e.button() == Qt.XButton2: - # Forward button on mice which have it. + elif e.button() in (Qt.XButton2, Qt.RightButton): + # Forward button on mice which have it, or rocker gesture if self.page().history().canGoForward(): self.forward() else: @@ -497,7 +504,10 @@ class WebView(QWebView): Return: The superclass return value. """ - if e.button() in (Qt.XButton1, Qt.XButton2): + is_rocker_gesture = (config.get('input', 'rocker-gestures') and + e.buttons() == Qt.LeftButton | Qt.RightButton) + + if e.button() in (Qt.XButton1, Qt.XButton2) or is_rocker_gesture: self._mousepress_backforward(e) super().mousePressEvent(e) return diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 75703f8de..059e49b0e 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -370,6 +370,11 @@ DATA = collections.OrderedDict([ ('links-included-in-focus-chain', SettingValue(typ.Bool(), 'true'), "Whether hyperlinks should be included in the keyboard focus chain."), + + ('rocker-gestures', + SettingValue(typ.Bool(), 'false'), + "Whether to enable Opera-like mouse rocker gestures. This disables " + "the context menu."), )), ('tabs', sect.KeyValue(