Patch 8.1.2257

10 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 5, 2019, 3:10:01 PM11/5/19
to vim...@googlegroups.com

Patch 8.1.2257
Problem: MS-Windows GUI: scroll wheel always uses current window.
Solution: Add the 'scrollfocus' option for MS-Windows.
Files: runtime/doc/options.txt, src/gui_w32.c, src/optiondefs.h,
src/option.h


*** ../vim-8.1.2256/runtime/doc/options.txt 2019-10-27 22:54:24.579870629 +0100
--- runtime/doc/options.txt 2019-11-05 20:32:28.229960918 +0100
***************
*** 6283,6288 ****
--- 6282,6296 ----
file. This means that ":split | edit file" results in two windows
with scroll-binding, but ":split file" does not.

+ *'scrollfocus'* *'scf'* *'noscrollfocus'* *'noscf'*
+ 'scrollfocus' 'scf' boolean (default off)
+ global
+ {only for MS-Windows GUI}
+ When using the scroll wheel and this option is set, the window under
+ the mouse pointer is scrolled. With this option off the current
+ window is scrolled.
+ Systems other than MS-Windows behave like this option is on.
+
*'scrolljump'* *'sj'*
'scrolljump' 'sj' number (default 1)
global
*** ../vim-8.1.2256/src/gui_w32.c 2019-11-04 22:52:08.366798096 +0100
--- src/gui_w32.c 2019-11-05 20:36:25.049154620 +0100
***************
*** 4234,4293 ****
}


! /* Intellimouse wheel handler */
static void
_OnMouseWheel(
HWND hwnd,
short zDelta)
{
- /* Treat a mouse wheel event as if it were a scroll request */
int i;
int size;
HWND hwndCtl;

- if (curwin->w_scrollbars[SBAR_RIGHT].id != 0)
- {
- hwndCtl = curwin->w_scrollbars[SBAR_RIGHT].id;
- size = curwin->w_scrollbars[SBAR_RIGHT].size;
- }
- else if (curwin->w_scrollbars[SBAR_LEFT].id != 0)
- {
- hwndCtl = curwin->w_scrollbars[SBAR_LEFT].id;
- size = curwin->w_scrollbars[SBAR_LEFT].size;
- }
- else
- return;
-
- size = curwin->w_height;
if (mouse_scroll_lines == 0)
init_mouse_wheel();

#ifdef FEAT_TEXT_PROP
{
! win_T *wp = gui_mouse_window(FIND_POPUP);

! if (wp != NULL && popup_is_popup(wp))
! {
! cmdarg_T cap;
! oparg_T oa;
!
! // Mouse hovers over popup window, scroll it if possible.
! mouse_row = wp->w_winrow;
! mouse_col = wp->w_wincol;
! vim_memset(&cap, 0, sizeof(cap));
! cap.arg = zDelta < 0 ? MSCR_UP : MSCR_DOWN;
! cap.cmdchar = zDelta < 0 ? K_MOUSEUP : K_MOUSEDOWN;
! clear_oparg(&oa);
! cap.oap = &oa;
! nv_mousescroll(&cap);
! update_screen(0);
! setcursor();
! out_flush();
! return;
! }
}
#endif

mch_disable_flush();
if (mouse_scroll_lines > 0
&& mouse_scroll_lines < (size > 2 ? size - 2 : 1))
--- 4234,4291 ----
}


! /*
! * Intellimouse wheel handler.
! * Treat a mouse wheel event as if it were a scroll request.
! */
static void
_OnMouseWheel(
HWND hwnd,
short zDelta)
{
int i;
int size;
HWND hwndCtl;
+ win_T *wp;

if (mouse_scroll_lines == 0)
init_mouse_wheel();

+ wp = gui_mouse_window(FIND_POPUP);
+
#ifdef FEAT_TEXT_PROP
+ if (wp != NULL && popup_is_popup(wp))
{
! cmdarg_T cap;
! oparg_T oa;

! // Mouse hovers over popup window, scroll it if possible.
! mouse_row = wp->w_winrow;
! mouse_col = wp->w_wincol;
! vim_memset(&cap, 0, sizeof(cap));
! cap.arg = zDelta < 0 ? MSCR_UP : MSCR_DOWN;
! cap.cmdchar = zDelta < 0 ? K_MOUSEUP : K_MOUSEDOWN;
! clear_oparg(&oa);
! cap.oap = &oa;
! nv_mousescroll(&cap);
! update_screen(0);
! setcursor();
! out_flush();
! return;
}
#endif

+ if (wp == NULL || !p_scf)
+ wp = curwin;
+
+ if (wp->w_scrollbars[SBAR_RIGHT].id != 0)
+ hwndCtl = wp->w_scrollbars[SBAR_RIGHT].id;
+ else if (wp->w_scrollbars[SBAR_LEFT].id != 0)
+ hwndCtl = wp->w_scrollbars[SBAR_LEFT].id;
+ else
+ return;
+ size = wp->w_height;
+
mch_disable_flush();
if (mouse_scroll_lines > 0
&& mouse_scroll_lines < (size > 2 ? size - 2 : 1))
*** ../vim-8.1.2256/src/optiondefs.h 2019-10-27 22:54:24.579870629 +0100
--- src/optiondefs.h 2019-11-05 20:33:02.717848476 +0100
***************
*** 2148,2153 ****
--- 2148,2160 ----
{"scrollbind", "scb", P_BOOL|P_VI_DEF,
(char_u *)VAR_WIN, PV_SCBIND,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
+ {"scrollfocus", "scf", P_BOOL|P_VI_DEF,
+ #if defined(MSWIN) && defined(FEAT_GUI)
+ (char_u *)&p_scf, PV_NONE,
+ #else
+ (char_u *)NULL, PV_NONE,
+ #endif
+ {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
(char_u *)&p_sj, PV_NONE,
{(char_u *)1L, (char_u *)0L} SCTX_INIT},
*** ../vim-8.1.2256/src/option.h 2019-10-27 05:12:38.284773720 +0100
--- src/option.h 2019-11-05 20:33:38.677729222 +0100
***************
*** 814,819 ****
--- 814,822 ----
EXTERN char_u *p_pp; // 'packpath'
EXTERN char_u *p_rtp; // 'runtimepath'
EXTERN long p_sj; // 'scrolljump'
+ #if defined(MSWIN) && defined(FEAT_GUI)
+ EXTERN int p_scf; // 'scrollfocus'
+ #endif
EXTERN long p_so; // 'scrolloff'
EXTERN char_u *p_sbo; // 'scrollopt'
EXTERN char_u *p_sections; // 'sections'
*** ../vim-8.1.2256/src/version.c 2019-11-04 23:36:26.371298800 +0100
--- src/version.c 2019-11-05 20:31:02.302231964 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2257,
/**/

--
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
-- Arthur Dent and Ford Prefect in Douglas Adams'
"The Hitchhiker's Guide to the Galaxy"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages