comparison src/mouse.c @ 30980:eb51299c4bfc v9.0.0825

patch 9.0.0825: cannot drag an entry in the tabpage line Commit: https://github.com/vim/vim/commit/8e0ccb6bc21a446e5c6375b7fdf200fb53a129da Author: zeertzjq <zeertzjq@outlook.com> Date: Tue Nov 1 18:35:27 2022 +0000 patch 9.0.0825: cannot drag an entry in the tabpage line Problem: Cannot drag an entry in the tabpage line. Solution: Clear dragwin instead of got_click. (closes https://github.com/vim/vim/issues/11483, closes #11482)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Nov 2022 11:18:55 +0100
parents 013f8436b0d5
children 33ca088dbd3e
comparison
equal deleted inserted replaced
30979:71079a666431 30980:eb51299c4bfc
176 176
177 mpos->coladd = 0; 177 mpos->coladd = 0;
178 return IN_BUFFER; 178 return IN_BUFFER;
179 } 179 }
180 #endif 180 #endif
181
182 static int mouse_got_click = FALSE; // got a click some time back
183
184 /*
185 * Reset the flag that a mouse click was seen. To be called when switching tab
186 * page.
187 */
188 void
189 reset_mouse_got_click(void)
190 {
191 mouse_got_click = FALSE;
192 }
193 181
194 /* 182 /*
195 * Do the appropriate action for the current mouse click in the current mode. 183 * Do the appropriate action for the current mouse click in the current mode.
196 * Not used for Command-line mode. 184 * Not used for Command-line mode.
197 * 185 *
234 int dir, // Direction to 'put' if necessary 222 int dir, // Direction to 'put' if necessary
235 long count, 223 long count,
236 int fixindent) // PUT_FIXINDENT if fixing indent necessary 224 int fixindent) // PUT_FIXINDENT if fixing indent necessary
237 { 225 {
238 static int do_always = FALSE; // ignore 'mouse' setting next time 226 static int do_always = FALSE; // ignore 'mouse' setting next time
227 static int got_click = FALSE; // got a click some time back
239 228
240 int which_button; // MOUSE_LEFT, _MIDDLE or _RIGHT 229 int which_button; // MOUSE_LEFT, _MIDDLE or _RIGHT
241 int is_click = FALSE; // If FALSE it's a drag or release event 230 int is_click = FALSE; // If FALSE it's a drag or release event
242 int is_drag = FALSE; // If TRUE it's a drag event 231 int is_drag = FALSE; // If TRUE it's a drag event
243 int jump_flags = 0; // flags for jump_to_mouse() 232 int jump_flags = 0; // flags for jump_to_mouse()
345 } 334 }
346 #endif 335 #endif
347 336
348 // Ignore drag and release events if we didn't get a click. 337 // Ignore drag and release events if we didn't get a click.
349 if (is_click) 338 if (is_click)
350 mouse_got_click = TRUE; 339 got_click = TRUE;
351 else 340 else
352 { 341 {
353 if (!mouse_got_click) // didn't get click, ignore 342 if (!got_click) // didn't get click, ignore
354 return FALSE; 343 return FALSE;
355 if (!is_drag) // release, reset mouse_got_click 344 if (!is_drag) // release, reset got_click
356 { 345 {
357 mouse_got_click = FALSE; 346 got_click = FALSE;
358 if (in_tab_line) 347 if (in_tab_line)
359 { 348 {
360 in_tab_line = FALSE; 349 in_tab_line = FALSE;
361 return FALSE; 350 return FALSE;
362 } 351 }
369 if (State & MODE_INSERT) 358 if (State & MODE_INSERT)
370 stuffcharReadbuff(Ctrl_O); 359 stuffcharReadbuff(Ctrl_O);
371 if (count > 1) 360 if (count > 1)
372 stuffnumReadbuff(count); 361 stuffnumReadbuff(count);
373 stuffcharReadbuff(Ctrl_T); 362 stuffcharReadbuff(Ctrl_T);
374 mouse_got_click = FALSE; // ignore drag&release now 363 got_click = FALSE; // ignore drag&release now
375 return FALSE; 364 return FALSE;
376 } 365 }
377 366
378 // CTRL only works with left mouse button 367 // CTRL only works with left mouse button
379 if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT) 368 if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT)
650 setcursor(); 639 setcursor();
651 out_flush(); // Update before showing popup menu 640 out_flush(); // Update before showing popup menu
652 } 641 }
653 # ifdef FEAT_MENU 642 # ifdef FEAT_MENU
654 show_popupmenu(); 643 show_popupmenu();
655 mouse_got_click = FALSE; // ignore release events 644 got_click = FALSE; // ignore release events
656 # endif 645 # endif
657 return (jump_flags & CURSOR_MOVED) != 0; 646 return (jump_flags & CURSOR_MOVED) != 0;
658 #else 647 #else
659 return FALSE; 648 return FALSE;
660 #endif 649 #endif
707 696
708 // If an operator is pending, ignore all drags and releases until the 697 // If an operator is pending, ignore all drags and releases until the
709 // next mouse click. 698 // next mouse click.
710 if (!is_drag && oap != NULL && oap->op_type != OP_NOP) 699 if (!is_drag && oap != NULL && oap->op_type != OP_NOP)
711 { 700 {
712 mouse_got_click = FALSE; 701 got_click = FALSE;
713 oap->motion_type = MCHAR; 702 oap->motion_type = MCHAR;
714 } 703 }
715 704
716 // When releasing the button let jump_to_mouse() know. 705 // When releasing the button let jump_to_mouse() know.
717 if (!is_click && !is_drag) 706 if (!is_click && !is_drag)
906 { 895 {
907 if (curwin->w_llist_ref == NULL) // quickfix window 896 if (curwin->w_llist_ref == NULL) // quickfix window
908 do_cmdline_cmd((char_u *)".cc"); 897 do_cmdline_cmd((char_u *)".cc");
909 else // location list window 898 else // location list window
910 do_cmdline_cmd((char_u *)".ll"); 899 do_cmdline_cmd((char_u *)".ll");
911 mouse_got_click = FALSE; // ignore drag&release now 900 got_click = FALSE; // ignore drag&release now
912 } 901 }
913 #endif 902 #endif
914 903
915 // Ctrl-Mouse click (or double click in a help window) jumps to the tag 904 // Ctrl-Mouse click (or double click in a help window) jumps to the tag
916 // under the mouse pointer. 905 // under the mouse pointer.
918 && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)) 907 && (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK))
919 { 908 {
920 if (State & MODE_INSERT) 909 if (State & MODE_INSERT)
921 stuffcharReadbuff(Ctrl_O); 910 stuffcharReadbuff(Ctrl_O);
922 stuffcharReadbuff(Ctrl_RSB); 911 stuffcharReadbuff(Ctrl_RSB);
923 mouse_got_click = FALSE; // ignore drag&release now 912 got_click = FALSE; // ignore drag&release now
924 } 913 }
925 914
926 // Shift-Mouse click searches for the next occurrence of the word under 915 // Shift-Mouse click searches for the next occurrence of the word under
927 // the mouse pointer 916 // the mouse pointer
928 else if ((mod_mask & MOD_MASK_SHIFT)) 917 else if ((mod_mask & MOD_MASK_SHIFT))
1511 mouse_model_popup(void) 1500 mouse_model_popup(void)
1512 { 1501 {
1513 return (p_mousem[0] == 'p'); 1502 return (p_mousem[0] == 'p');
1514 } 1503 }
1515 1504
1505 static win_T *dragwin = NULL; // window being dragged
1506
1507 /*
1508 * Reset the window being dragged. To be called when switching tab page.
1509 */
1510 void
1511 reset_dragwin(void)
1512 {
1513 dragwin = NULL;
1514 }
1515
1516 /* 1516 /*
1517 * Move the cursor to the specified row and column on the screen. 1517 * Move the cursor to the specified row and column on the screen.
1518 * Change current window if necessary. Returns an integer with the 1518 * Change current window if necessary. Returns an integer with the
1519 * CURSOR_MOVED bit set if the cursor has moved or unset otherwise. 1519 * CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
1520 * 1520 *
1554 static int in_popup_win = FALSE; 1554 static int in_popup_win = FALSE;
1555 static win_T *click_in_popup_win = NULL; 1555 static win_T *click_in_popup_win = NULL;
1556 #endif 1556 #endif
1557 static int prev_row = -1; 1557 static int prev_row = -1;
1558 static int prev_col = -1; 1558 static int prev_col = -1;
1559 static win_T *dragwin = NULL; // window being dragged
1560 static int did_drag = FALSE; // drag was noticed 1559 static int did_drag = FALSE; // drag was noticed
1561 1560
1562 win_T *wp, *old_curwin; 1561 win_T *wp, *old_curwin;
1563 pos_T old_cursor; 1562 pos_T old_cursor;
1564 int count; 1563 int count;