aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/PlatWin.cxx14
-rw-r--r--win32/PlatWin.h14
-rw-r--r--win32/ScintillaWin.cxx14
3 files changed, 18 insertions, 24 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 87840ff3b..bb808b4e7 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -2895,7 +2895,7 @@ class ListBoxX : public ListBox {
PRectangle rcPreSize;
Point dragOffset;
Point location; // Caret location at which the list is opened
- int wheelDelta; // mouse wheel residue
+ MouseWheelDelta wheelDelta;
ListOptions options;
DWORD frameStyle = WS_THICKFRAME;
@@ -2927,7 +2927,7 @@ public:
desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8),
parent(nullptr), ctrlID(0), dpi(USER_DEFAULT_SCREEN_DPI),
delegate(nullptr),
- widestItem(nullptr), maxCharWidth(1), resizeHit(0), wheelDelta(0) {
+ widestItem(nullptr), maxCharWidth(1), resizeHit(0) {
}
ListBoxX(const ListBoxX &) = delete;
ListBoxX(ListBoxX &&) = delete;
@@ -3689,21 +3689,15 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
}
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
case WM_MOUSEWHEEL:
- wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
- if (std::abs(wheelDelta) >= WHEEL_DELTA) {
+ if (wheelDelta.Accumulate(wParam)) {
const int nRows = GetVisibleRows();
int linesToScroll = std::clamp(nRows - 1, 1, 3);
- linesToScroll *= (wheelDelta / WHEEL_DELTA);
+ linesToScroll *= wheelDelta.Actions();
int top = ListBox_GetTopIndex(lb) + linesToScroll;
if (top < 0) {
top = 0;
}
ListBox_SetTopIndex(lb, top);
- // update wheel delta residue
- if (wheelDelta >= 0)
- wheelDelta = wheelDelta % WHEEL_DELTA;
- else
- wheelDelta = - (-wheelDelta % WHEEL_DELTA);
}
break;
diff --git a/win32/PlatWin.h b/win32/PlatWin.h
index 893618b38..68098f9c7 100644
--- a/win32/PlatWin.h
+++ b/win32/PlatWin.h
@@ -49,6 +49,20 @@ int SystemMetricsForDpi(int nIndex, UINT dpi) noexcept;
HCURSOR LoadReverseArrowCursor(UINT dpi) noexcept;
+class MouseWheelDelta {
+ int wheelDelta = 0;
+public:
+ bool Accumulate(WPARAM wParam) noexcept {
+ wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
+ return std::abs(wheelDelta) >= WHEEL_DELTA;
+ }
+ int Actions() noexcept {
+ const int actions = wheelDelta / WHEEL_DELTA;
+ wheelDelta = wheelDelta % WHEEL_DELTA;
+ return actions;
+ }
+};
+
#if defined(USE_D2D)
extern bool LoadD2D();
extern ID2D1Factory *pD2DFactory;
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 9ffd40d06..c405ed8d1 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -276,20 +276,6 @@ public:
}
};
-class MouseWheelDelta {
- int wheelDelta = 0;
-public:
- bool Accumulate(WPARAM wParam) noexcept {
- wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
- return std::abs(wheelDelta) >= WHEEL_DELTA;
- }
- int Actions() noexcept {
- const int actions = wheelDelta / WHEEL_DELTA;
- wheelDelta = wheelDelta % WHEEL_DELTA;
- return actions;
- }
-};
-
struct HorizontalScrollRange {
int pageWidth;
int documentWidth;