diff --git a/qutebrowser/browser/mouse.py b/qutebrowser/browser/mouse.py index 31d32d906..1a035c612 100644 --- a/qutebrowser/browser/mouse.py +++ b/qutebrowser/browser/mouse.py @@ -74,6 +74,7 @@ class MouseEventFilter(QObject): self._handlers = { QEvent.MouseButtonPress: self._handle_mouse_press, QEvent.Wheel: self._handle_wheel, + QEvent.ContextMenu: self._handle_context_menu, } self._ignore_wheel_event = False @@ -113,6 +114,10 @@ class MouseEventFilter(QObject): return False + def _handle_context_menu(self, _e): + """Suppress context menus if rocker gestures are turned on.""" + return config.get('input', 'rocker-gestures') + def _mousepress_backforward(self, e): """Handle back/forward mouse button presses. diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py index 8645990a4..f69247f18 100644 --- a/qutebrowser/browser/webkit/webview.py +++ b/qutebrowser/browser/webkit/webview.py @@ -78,9 +78,7 @@ class WebView(QWebView): window=win_id) mode_manager.entered.connect(self.on_mode_entered) mode_manager.left.connect(self.on_mode_left) - if config.get('input', 'rocker-gestures'): - self.setContextMenuPolicy(Qt.PreventContextMenu) - objreg.get('config').changed.connect(self.on_config_changed) + objreg.get('config').changed.connect(self._set_bg_color) def _init_page(self, tabdata): """Initialize the QWebPage used by this view. @@ -110,6 +108,7 @@ class WebView(QWebView): # deleted pass + @config.change_filter('colors', 'webpage.bg') def _set_bg_color(self): """Set the webpage background color as configured.""" col = config.get('colors', 'webpage.bg') @@ -119,17 +118,6 @@ class WebView(QWebView): palette.setColor(QPalette.Base, col) self.setPalette(palette) - @pyqtSlot(str, str) - def on_config_changed(self, section, option): - """Update rocker gestures/background color.""" - if section == 'input' and option == 'rocker-gestures': - if config.get('input', 'rocker-gestures'): - self.setContextMenuPolicy(Qt.PreventContextMenu) - else: - self.setContextMenuPolicy(Qt.DefaultContextMenu) - elif section == 'colors' and option == 'webpage.bg': - self._set_bg_color() - def _mousepress_insertmode(self, e): """Switch to insert mode when an editable element was clicked.