aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-10-20 22:18:26 +0800
committerGitHub <noreply@github.com>2024-10-20 22:18:26 +0800
commit9b8907d90508d7b66f025bbd1f5a48a78c5ce035 (patch)
tree28ba9bba6705cf19f8f3279c6b0b3ade41c81f4c /src/nvim/api
parentdff684fdb3d2e787ac6d6fd49ec52ede604fd0ce (diff)
downloadrneovim-9b8907d90508d7b66f025bbd1f5a48a78c5ce035.tar.gz
rneovim-9b8907d90508d7b66f025bbd1f5a48a78c5ce035.tar.bz2
rneovim-9b8907d90508d7b66f025bbd1f5a48a78c5ce035.zip
feat(float): allow enabling mouse for non-focusable window (#30844)
Problem: Cannot allow mouse interaction for non-focusable float window. Solution: Add a "mouse" field to float window config.
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/keysets_defs.h1
-rw-r--r--src/nvim/api/ui_events.in.h2
-rw-r--r--src/nvim/api/win_config.c13
3 files changed, 14 insertions, 2 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)) {