Skip to content

Commit 53fe0f0

Browse files
Workaround scroll wheel buffering in Wine
1 parent b68812f commit 53fe0f0

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

graphics.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,28 @@ message_loop(void)
130130
while (GetMessage(&msg, NULL, 0, 0) > 0) {
131131
TranslateMessage(&msg);
132132
DispatchMessageW(&msg);
133+
134+
/*
135+
* HACK: under Wine, mouse scroll messages are buffered until mouse movement (cause unknown).
136+
* Posting a mouse movement message does not work as a workaround, and neither does sending
137+
* a 0-pixel raw input (maybe optimized out by Wine).
138+
* What DOES work is sending two net-zero mouse moves. There is not jitter and the
139+
* scrolling is processed immediately. ¯\_(ツ)_/¯
140+
*/
141+
if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) {
142+
INPUT in[2] = {0};
143+
/* one pixel move left */
144+
in[0].type = INPUT_MOUSE;
145+
in[0].mi.dx = 1;
146+
in[0].mi.dy = 0;
147+
in[0].mi.dwFlags = MOUSEEVENTF_MOVE;
148+
//
149+
in[1].type = INPUT_MOUSE;
150+
in[1].mi.dx = -1;
151+
in[1].mi.dy = 0;
152+
in[1].mi.dwFlags = MOUSEEVENTF_MOVE;
153+
SendInput(2, in, sizeof(INPUT));
154+
}
133155
}
134156
}
135157

0 commit comments

Comments
 (0)