Skip to content

Commit 98fd66d

Browse files
committed
patch 8.0.0872: no mouse scroll with a terminal window
Problem: Using mouse scroll while a terminal window has focus and the mouse pointer is on another window does not work. Same for focus in a non-terminal window ahd the mouse pointer is over a terminal window. Solution: Send the scroll action to the right window.
1 parent 086d535 commit 98fd66d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/normal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,6 +4638,11 @@ nv_mousescroll(cmdarg_T *cap)
46384638

46394639
if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
46404640
{
4641+
# ifdef FEAT_TERMINAL
4642+
if (term_use_loop())
4643+
send_keys_to_term(curbuf->b_term, cap->cmdchar, TRUE);
4644+
else
4645+
# endif
46414646
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
46424647
{
46434648
(void)onepage(cap->arg ? FORWARD : BACKWARD, 1L);

src/proto/terminal.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
55
int term_job_running(term_T *term);
66
int term_in_terminal_mode(void);
77
void term_leave_terminal_mode(void);
8+
int send_keys_to_term(term_T *term, int c, int typed);
89
int term_use_loop(void);
910
int terminal_loop(void);
1011
void term_job_ended(job_T *job);

src/terminal.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
*
3838
* TODO:
3939
* - MS-Windows: no redraw for 'updatetime' #1915
40-
* - mouse scroll: when over other window, scroll that window.
4140
* - add argument to term_wait() for waiting time.
4241
* - For the scrollback buffer store lines in the buffer, only attributes in
4342
* tl_scrollback.
@@ -909,7 +908,7 @@ term_vgetc()
909908
* Return FAIL when the key needs to be handled in Normal mode.
910909
* Return OK when the key was dropped or sent to the terminal.
911910
*/
912-
static int
911+
int
913912
send_keys_to_term(term_T *term, int c, int typed)
914913
{
915914
char msg[KEY_BUF_LEN];
@@ -948,13 +947,18 @@ send_keys_to_term(term_T *term, int c, int typed)
948947
case K_X1RELEASE:
949948
case K_X2MOUSE:
950949
case K_X2RELEASE:
950+
951+
case K_MOUSEUP:
952+
case K_MOUSEDOWN:
953+
case K_MOUSELEFT:
954+
case K_MOUSERIGHT:
951955
if (mouse_row < W_WINROW(curwin)
952956
|| mouse_row >= (W_WINROW(curwin) + curwin->w_height)
953957
|| mouse_col < W_WINCOL(curwin)
954958
|| mouse_col >= W_ENDCOL(curwin)
955959
|| dragging_outside)
956960
{
957-
/* click outside the current window */
961+
/* click or scroll outside the current window */
958962
if (typed)
959963
{
960964
stuffcharReadbuff(c);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
872,
772774
/**/
773775
871,
774776
/**/

0 commit comments

Comments
 (0)