Implement an option to have focus follow the mouse

Fixes #156
This commit is contained in:
Kovid Goyal 2017-10-24 09:29:28 +05:30
parent 2443d76ac3
commit 2f5b110c41
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 12 additions and 1 deletions

View File

@ -240,6 +240,7 @@ type_map = {
'scrollback_in_new_tab': to_bool, 'scrollback_in_new_tab': to_bool,
'font_size': to_font_size, 'font_size': to_font_size,
'font_size_delta': positive_float, 'font_size_delta': positive_float,
'focus_follows_mouse': to_bool,
'cursor_shape': to_cursor_shape, 'cursor_shape': to_cursor_shape,
'open_url_modifiers': to_open_url_modifiers, 'open_url_modifiers': to_open_url_modifiers,
'repaint_delay': positive_int, 'repaint_delay': positive_int,

View File

@ -90,6 +90,9 @@ select_by_word_characters :@-./_~?&=%+#
# zero to disable mouse cursor hiding. # zero to disable mouse cursor hiding.
mouse_hide_wait 3.0 mouse_hide_wait 3.0
# Set the active window to the window under the mouse when moving the mouse around
focus_follows_mouse no
# The enabled window layouts. A comma separated list of layout names. The special value * means # The enabled window layouts. A comma separated list of layout names. The special value * means
# all layouts. The first listed layout will be used as the startup layout. # all layouts. The first listed layout will be used as the startup layout.
# For a list of available layouts, see the file layouts.py # For a list of available layouts, see the file layouts.py

View File

@ -164,6 +164,12 @@ detect_url(Window *w, Screen *screen, unsigned int x, unsigned int y) {
HANDLER(handle_move_event) { HANDLER(handle_move_event) {
unsigned int x, y; unsigned int x, y;
if (OPT(focus_follows_mouse)) {
Tab *t = global_state.tabs + global_state.active_tab;
if (window_idx != t->active_window) {
call_boss(switch_focus_to, "I", window_idx);
}
}
if (!cell_for_pos(w, &x, &y)) return; if (!cell_for_pos(w, &x, &y)) return;
Screen *screen = w->render_data.screen; Screen *screen = w->render_data.screen;
detect_url(w, screen, x, y); detect_url(w, screen, x, y);

View File

@ -151,6 +151,7 @@ PYWRAP1(set_options) {
#define S(name, convert) { GA(name); global_state.opts.name = convert(ret); Py_DECREF(ret); if (PyErr_Occurred()) return NULL; } #define S(name, convert) { GA(name); global_state.opts.name = convert(ret); Py_DECREF(ret); if (PyErr_Occurred()) return NULL; }
S(visual_bell_duration, PyFloat_AsDouble); S(visual_bell_duration, PyFloat_AsDouble);
S(enable_audio_bell, PyObject_IsTrue); S(enable_audio_bell, PyObject_IsTrue);
S(focus_follows_mouse, PyObject_IsTrue);
S(cursor_blink_interval, PyFloat_AsDouble); S(cursor_blink_interval, PyFloat_AsDouble);
S(cursor_stop_blinking_after, PyFloat_AsDouble); S(cursor_stop_blinking_after, PyFloat_AsDouble);
S(cursor_shape, PyLong_AsLong); S(cursor_shape, PyLong_AsLong);

View File

@ -18,6 +18,7 @@ typedef struct {
char_type select_by_word_characters[256]; size_t select_by_word_characters_count; char_type select_by_word_characters[256]; size_t select_by_word_characters_count;
color_type url_color; color_type url_color;
double repaint_delay, input_delay; double repaint_delay, input_delay;
bool focus_follows_mouse;
} Options; } Options;
typedef struct { typedef struct {

View File

@ -80,7 +80,6 @@ class Window:
self.tab_id = tab.id self.tab_id = tab.id
self.tabref = weakref.ref(tab) self.tabref = weakref.ref(tab)
self.override_title = None self.override_title = None
self.last_mouse_cursor_pos = 0, 0
self.destroyed = False self.destroyed = False
self.click_queue = deque(maxlen=3) self.click_queue = deque(maxlen=3)
self.geometry = WindowGeometry(0, 0, 0, 0, 0, 0) self.geometry = WindowGeometry(0, 0, 0, 0, 0, 0)