diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/keysets_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/api/ui_events.in.h | 2 | ||||
-rw-r--r-- | src/nvim/api/win_config.c | 13 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/grid_defs.h | 4 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/mouse.c | 2 | ||||
-rw-r--r-- | src/nvim/ui_compositor.c | 2 | ||||
-rw-r--r-- | src/nvim/window.c | 5 | ||||
-rw-r--r-- | src/nvim/winfloat.c | 1 |
10 files changed, 25 insertions, 9 deletions
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h index 552612dd13..96aabb851f 100644 --- a/src/nvim/api/keysets_defs.h +++ b/src/nvim/api/keysets_defs.h @@ -119,6 +119,7 @@ typedef struct { Array bufpos; Boolean external; Boolean focusable; + Boolean mouse; Boolean vertical; Integer zindex; Object border; diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 2bd8792d71..865e84ab91 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -102,7 +102,7 @@ void win_pos(Integer grid, Window win, Integer startrow, Integer startcol, Integ Integer height) FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; void win_float_pos(Integer grid, Window win, String anchor, Integer anchor_grid, Float anchor_row, - Float anchor_col, Boolean focusable, Integer zindex) + Float anchor_col, Boolean mouse_enabled, Integer zindex) FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; void win_external_pos(Integer grid, Window win) FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index f63fdc5381..16811e0cd9 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -129,7 +129,12 @@ /// fractional. /// - focusable: Enable focus by user actions (wincmds, mouse events). /// Defaults to true. Non-focusable windows can be entered by -/// |nvim_set_current_win()|. +/// |nvim_set_current_win()|, or, when the `mouse` field is set to true, +/// by mouse events. +/// - mouse: Specify how this window interacts with mouse events. +/// Defaults to `focusable` value. +/// - If false, mouse events pass through this window. +/// - If true, mouse events interact with this window normally. /// - external: GUI should display the window as an external /// top-level window. Currently accepts no other positioning /// configuration together with this. @@ -714,6 +719,7 @@ Dict(win_config) nvim_win_get_config(Window window, Arena *arena, Error *err) PUT_KEY_X(rv, focusable, config->focusable); PUT_KEY_X(rv, external, config->external); PUT_KEY_X(rv, hide, config->hide); + PUT_KEY_X(rv, mouse, config->mouse); if (wp->w_floating) { PUT_KEY_X(rv, width, config->width); @@ -1202,6 +1208,11 @@ static bool parse_win_config(win_T *wp, Dict(win_config) *config, WinConfig *fco if (HAS_KEY_X(config, focusable)) { fconfig->focusable = config->focusable; + fconfig->mouse = config->focusable; + } + + if (HAS_KEY_X(config, mouse)) { + fconfig->mouse = config->mouse; } if (HAS_KEY_X(config, zindex)) { diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 6f059fc376..1fe5512708 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -938,6 +938,7 @@ typedef struct { FloatRelative relative; bool external; bool focusable; + bool mouse; WinSplit split; int zindex; WinStyle style; @@ -964,6 +965,7 @@ typedef struct { .row = 0, .col = 0, .anchor = 0, \ .relative = 0, .external = false, \ .focusable = true, \ + .mouse = true, \ .split = 0, \ .zindex = kZIndexFloatDefault, \ .style = kWinStyleUnused, \ diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h index ac67f42fe0..19a79ff810 100644 --- a/src/nvim/grid_defs.h +++ b/src/nvim/grid_defs.h @@ -80,8 +80,8 @@ struct ScreenGrid { // whether the compositor should blend the grid with the background grid bool blending; - // whether the grid can be focused with mouse clicks. - bool focusable; + // whether the grid interacts with mouse events. + bool mouse_enabled; // z-index: the order in the stack of grids. int zindex; diff --git a/src/nvim/message.c b/src/nvim/message.c index 79e6bc8be7..151fb3d903 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -199,7 +199,7 @@ void msg_grid_validate(void) ui_call_grid_resize(msg_grid.handle, msg_grid.cols, msg_grid.rows); msg_scrolled_at_flush = msg_scrolled; - msg_grid.focusable = false; + msg_grid.mouse_enabled = false; msg_grid_adj.target = &msg_grid; } else if (!should_alloc && msg_grid.chars) { ui_comp_remove_grid(&msg_grid); diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 884bc88d73..1289adfabb 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -1740,7 +1740,7 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp) } else if (*gridp > 1) { win_T *wp = get_win_by_grid_handle(*gridp); if (wp && wp->w_grid_alloc.chars - && !(wp->w_floating && !wp->w_config.focusable)) { + && !(wp->w_floating && !wp->w_config.mouse)) { *rowp = MIN(*rowp - wp->w_grid.row_offset, wp->w_grid.rows - 1); *colp = MIN(*colp - wp->w_grid.col_offset, wp->w_grid.cols - 1); return wp; diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 6e89894e0b..e28e8d4da7 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -275,7 +275,7 @@ ScreenGrid *ui_comp_mouse_focus(int row, int col) { for (ssize_t i = (ssize_t)kv_size(layers) - 1; i > 0; i--) { ScreenGrid *grid = kv_A(layers, i); - if (grid->focusable + if (grid->mouse_enabled && row >= grid->comp_row && row < grid->comp_row + grid->rows && col >= grid->comp_col && col < grid->comp_col + grid->cols) { return grid; diff --git a/src/nvim/window.c b/src/nvim/window.c index d3280a3478..91a69c3ec4 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -857,7 +857,7 @@ void ui_ext_win_position(win_T *wp, bool validate) String anchor = cstr_as_string(float_anchor_str[c.anchor]); if (!c.hide) { ui_call_win_float_pos(wp->w_grid_alloc.handle, wp->handle, anchor, - grid->handle, row, col, c.focusable, + grid->handle, row, col, c.mouse, wp->w_grid_alloc.zindex); } else { ui_call_win_hide(wp->w_grid_alloc.handle); @@ -889,7 +889,7 @@ void ui_ext_win_position(win_T *wp, bool validate) ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col, wp->w_height_outer, wp->w_width_outer, valid, false); ui_check_cursor_grid(wp->w_grid_alloc.handle); - wp->w_grid_alloc.focusable = wp->w_config.focusable; + wp->w_grid_alloc.mouse_enabled = wp->w_config.mouse; if (!valid) { wp->w_grid_alloc.valid = false; redraw_later(wp, UPD_NOT_VALID); @@ -4044,6 +4044,7 @@ void win_alloc_aucmd_win(int idx) fconfig.width = Columns; fconfig.height = 5; fconfig.focusable = false; + fconfig.mouse = false; aucmd_win[idx].auc_win = win_new_float(NULL, true, fconfig, &err); aucmd_win[idx].auc_win->w_buffer->b_nwindows--; RESET_BINDING(aucmd_win[idx].auc_win); diff --git a/src/nvim/winfloat.c b/src/nvim/winfloat.c index fdb65ad614..054ef07fc5 100644 --- a/src/nvim/winfloat.c +++ b/src/nvim/winfloat.c @@ -389,6 +389,7 @@ win_T *win_float_create(bool enter, bool new_buf) config.row = curwin->w_wrow; config.relative = kFloatRelativeEditor; config.focusable = false; + config.mouse = false; config.anchor = 0; // NW config.noautocmd = true; config.hide = true; |