diff options
Diffstat (limited to 'src/nvim/mouse.c')
-rw-r--r-- | src/nvim/mouse.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 32d8352d9b..fcd9ee4f75 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -60,6 +60,7 @@ int jump_to_mouse(int flags, { static int on_status_line = 0; // #lines below bottom of window static int on_sep_line = 0; // on separator right of window + static bool in_winbar = false; static int prev_row = -1; static int prev_col = -1; static win_T *dragwin = NULL; // window being dragged @@ -93,10 +94,24 @@ int jump_to_mouse(int flags, retnomove: // before moving the cursor for a left click which is NOT in a status // line, stop Visual mode - if (on_status_line) + if (on_status_line) { return IN_STATUS_LINE; - if (on_sep_line) + } + if (on_sep_line) { return IN_SEP_LINE; + } + if (in_winbar) { + // A quick second click may arrive as a double-click, but we use it + // as a second click in the WinBar. + if ((mod_mask & MOD_MASK_MULTI_CLICK) && !(flags & MOUSE_RELEASED)) { + wp = mouse_find_win(&grid, &row, &col); + if (wp == NULL) { + return IN_UNKNOWN; + } + winbar_click(wp, col); + } + return IN_OTHER_WIN | MOUSE_WINBAR; + } if (flags & MOUSE_MAY_STOP_VIS) { end_visual_mode(); redraw_curbuf_later(INVERTED); // delete the inversion @@ -134,6 +149,16 @@ retnomove: } fdc = win_fdccol_count(wp); dragwin = NULL; + + if (row == -1) { + // A click in the window toolbar does not enter another window or + // change Visual highlighting. + winbar_click(wp, col); + in_winbar = true; + return IN_OTHER_WIN | MOUSE_WINBAR; + } + in_winbar = false; + // winpos and height may change in win_enter()! if (grid == DEFAULT_GRID_HANDLE && row >= wp->w_height) { // In (or below) status line @@ -223,6 +248,9 @@ retnomove: did_drag |= count; } return IN_SEP_LINE; // Cursor didn't move + } else if (in_winbar) { + // After a click on the window toolbar don't start Visual mode. + return IN_OTHER_WIN | MOUSE_WINBAR; } else { // keep_window_focus must be true // before moving the cursor for a left click, stop Visual mode @@ -471,6 +499,7 @@ win_T *mouse_find_win(int *gridp, int *rowp, int *colp) // exist. FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp == fp->fr_win) { + *rowp -= wp->w_winbar_height; return wp; } } |