Permalink
Browse files

Move input -> rocker-gestures to MouseEventFilter

  • Loading branch information...
The-Compiler committed Aug 11, 2016
1 parent e8980d0 commit fb07655e5614cca1eedff7a53b46d310bee96e33
Showing with 7 additions and 14 deletions.
  1. +5 −0 qutebrowser/browser/mouse.py
  2. +2 −14 qutebrowser/browser/webkit/webview.py
@@ -74,6 +74,7 @@ def __init__(self, tab, parent=None):
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 @@ def _handle_wheel(self, e):
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.
@@ -78,9 +78,7 @@ def __init__(self, win_id, tab_id, tab, parent=None):
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 @@ def __del__(self):
# 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 @@ def _set_bg_color(self):
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.

0 comments on commit fb07655

Please sign in to comment.