Module: wine Branch: master Commit: 1642d312fd8ae98df7f24a59307a72a639a269c8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1642d312fd8ae98df7f24a5930...
Author: Ken Thomases ken@codeweavers.com Date: Sun Feb 10 19:08:50 2013 -0600
user32: Improve mouse wheel scrolling in edit control.
Allow fractions of WHEEL_DELTA to scroll fractions of SPI_GETWHEELSCROLLLINES, although still only whole lines. Keep the remainder and apply it to next event if in same direction.
---
dlls/user32/edit.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index ada313f..74e0ea4 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -140,6 +140,7 @@ typedef struct Even if parent will change, EN_* messages should be sent to the first parent. */ HWND hwndListBox; /* handle of ComboBox's listbox or NULL */ + INT wheelDeltaRemainder; /* scroll wheel delta left over after scrolling whole lines */ /* * only for multi line controls */ @@ -3551,6 +3552,8 @@ static LRESULT EDIT_WM_KillFocus(EDITSTATE *es) if(!(es->style & ES_NOHIDESEL)) EDIT_InvalidateText(es, es->selection_start, es->selection_end); EDIT_NOTIFY_PARENT(es, EN_KILLFOCUS); + /* throw away left over scroll when we lose focus */ + es->wheelDeltaRemainder = 0; return 0; }
@@ -5108,7 +5111,7 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B
case WM_MOUSEWHEEL: { - int gcWheelDelta = 0; + int wheelDelta; UINT pulScrollLines = 3; SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
@@ -5116,12 +5119,20 @@ LRESULT EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, B result = DefWindowProcW(hwnd, msg, wParam, lParam); break; } - gcWheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam); - if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines) + wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam); + /* if scrolling changes direction, ignore left overs */ + if ((wheelDelta < 0 && es->wheelDeltaRemainder < 0) || + (wheelDelta > 0 && es->wheelDeltaRemainder > 0)) + es->wheelDeltaRemainder += wheelDelta; + else + es->wheelDeltaRemainder = wheelDelta; + if (es->wheelDeltaRemainder && pulScrollLines) { - int cLineScroll= (int) min((UINT) es->line_count, pulScrollLines); - cLineScroll *= (gcWheelDelta / WHEEL_DELTA); - result = EDIT_EM_LineScroll(es, 0, cLineScroll); + int cLineScroll; + pulScrollLines = (int) min((UINT) es->line_count, pulScrollLines); + cLineScroll = pulScrollLines * (float)es->wheelDeltaRemainder / WHEEL_DELTA; + es->wheelDeltaRemainder -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines; + result = EDIT_EM_LineScroll(es, 0, -cLineScroll); } } break;