Hi,
I submit patch that uses generic code path for mouse wheel events instead of scrollbar hack.
It fixes several small problems:
* <S-MouseDown>/<S-MouseUp> didn't work. Now one can remap S-/C-/MouseDown and S-/C-/MouseUp events. No Alt modifier.
* missing autocommand CursorMoved after scroll wheel
also Win32: The matchparen plugin doesn't update the match when scrolling with the mouse wheel. (Ilya Bobir, 2006 Jun 27) * Win32: after "[I" showing matches, scroll wheel messes up screen. (Tsakiridis, 2007 Feb 18)

Cons: We lost possibility to change the number of lines to scroll via Control Panel.

Best regards,
Alex.

*** gui_w32.c.orig      Fri Jun  1 11:24:24 2007
--- gui_w32.c   Sun Jun  3 15:23:37 2007
***************
*** 560,602 ****
     }
 }


 /* 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();
!
!     if (mouse_scroll_lines > 0
!           && mouse_scroll_lines < (size > 2 ? size - 2 : 1))
!     {
!       for (i = mouse_scroll_lines; i > 0; --i)
!           _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_LINEUP : SB_LINEDOWN, 0);
!     }
!     else
!       _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN, 0);
 }

 #ifdef USE_SYSMENU_FONT
--- 560,600 ----
     }
 }

+ #ifndef WHEEL_DELTA
+ # define WHEEL_DELTA    120
+ #endif

 /* Intellimouse wheel handler */
!     static LRESULT
 _OnMouseWheel(
!     int zDelta,
!     int x,
!     int y,
!     int fwKeys)
! {
!     static int wheel_acc = 0;
!     int_u modifiers = 0;
!     int key = 0;
!     int lines;
!
!     /* Accumulate deltas until full line is reached */
!     wheel_acc += zDelta;
!     lines = wheel_acc / WHEEL_DELTA;
!     wheel_acc %= WHEEL_DELTA;
!
!     if (lines > 0)
!         key = MOUSE_4;
!     else if (lines < 0)
!         key = MOUSE_5;
!
!     if (fwKeys & MK_CONTROL)
!         modifiers |= MOUSE_CTRL;
!     if (fwKeys & MK_SHIFT)
!         modifiers |= MOUSE_SHIFT;

!     if (key)
!         gui_send_mouse_event(key, x, y, 0, modifiers);
!     return 0;
 }

 #ifdef USE_SYSMENU_FONT
***************
*** 904,911 ****
        return _DuringSizing((UINT)wParam, (LPRECT)lParam);

     case WM_MOUSEWHEEL:
!       _OnMouseWheel(hwnd, HIWORD(wParam));
!       break;

        /* Notification for change in SystemParametersInfo() */
     case WM_SETTINGCHANGE:
--- 902,908 ----
        return _DuringSizing((UINT)wParam, (LPRECT)lParam);

     case WM_MOUSEWHEEL:
! return _OnMouseWheel((short)HIWORD(wParam), LOWORD(lParam), HIWORD(lParam), LOWORD(wParam));

        /* Notification for change in SystemParametersInfo() */
     case WM_SETTINGCHANGE:
***************
*** 1108,1114 ****
     default:
        if (uMsg == msh_msgmousewheel && msh_msgmousewheel != 0)
        {   /* handle MSH_MOUSEWHEEL messages for Intellimouse */
!           _OnMouseWheel(hwnd, HIWORD(wParam));
            break;
        }
 #ifdef MSWIN_FIND_REPLACE
--- 1105,1111 ----
     default:
        if (uMsg == msh_msgmousewheel && msh_msgmousewheel != 0)
        {   /* handle MSH_MOUSEWHEEL messages for Intellimouse */
!           _OnMouseWheel((int)wParam, LOWORD(lParam), HIWORD(lParam), 0);
            break;
        }
 #ifdef MSWIN_FIND_REPLACE

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Reply via email to