Gabriel Ivăncescu : comctl32/listbox: Fix mouse wheel scrolling for multi-column listboxes.

Alexandre Julliard julliard at winehq.org
Mon Nov 25 09:12:24 CST 2019


Module: wine
Branch: stable
Commit: 786a246aa6c67a3e907e3df9ba439a0354bd141d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=786a246aa6c67a3e907e3df9ba439a0354bd141d

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Wed Jun  5 14:38:57 2019 +0300

comctl32/listbox: Fix mouse wheel scrolling for multi-column listboxes.

Multi-column listboxes scroll horizontally, so each wheel tick must go an
entire page at a time instead of an item at a time. But we have to limit
the amount of scrolling in this case to avoid "jumping over" columns,
if the window is too small.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=22253
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 1f3787519463bd99994a34a8648b7b9797bca985)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/comctl32/listbox.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c
index cb645b4467..545707dc04 100644
--- a/dlls/comctl32/listbox.c
+++ b/dlls/comctl32/listbox.c
@@ -2012,7 +2012,7 @@ static LRESULT LISTBOX_HandleHScroll( LB_DESCR *descr, WORD scrollReq, WORD pos
 
 static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta )
 {
-    UINT pulScrollLines = 3;
+    INT pulScrollLines = 3;
 
     SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
 
@@ -2026,9 +2026,20 @@ static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta )
     if (descr->wheel_remain && pulScrollLines)
     {
         int cLineScroll;
-        pulScrollLines = min((UINT) descr->page_size, pulScrollLines);
-        cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA;
-        descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
+        if (descr->style & LBS_MULTICOLUMN)
+        {
+            pulScrollLines = min(descr->width / descr->column_width, pulScrollLines);
+            pulScrollLines = max(1, pulScrollLines);
+            cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
+            descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
+            cLineScroll *= descr->page_size;
+        }
+        else
+        {
+            pulScrollLines = min(descr->page_size, pulScrollLines);
+            cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
+            descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
+        }
         LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
     }
     return 0;




More information about the wine-cvs mailing list