Skip to content

Commit

Permalink
smooth scroll accumulator
Browse files Browse the repository at this point in the history
  • Loading branch information
user726687 authored Sep 9, 2024
1 parent a3a56d2 commit 226afd2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ fn editProc(hwnd: *anyopaque, uMsg: u32, wParam: usize, lParam: isize) callconv(
return 0;
}
},
0x020A, 0x020E => { // WM_MOUSEWHEEL, WM_MOUSEHWHEEL
const Arg = packed struct(usize) {
lo: u16,
delta: i16,
unused: if (@sizeOf(usize) == 8) u32 else u0,
var accu: i16 = 0;
};
var arg: Arg = @bitCast(wParam);
const send = 120 * @divTrunc(arg.delta + Arg.accu, 120);
Arg.accu = arg.delta + Arg.accu - send;
arg.delta = send;
return CallWindowProcA(main_window.default_proc, hwnd, uMsg, @bitCast(arg), lParam);
},
else => {},
}
return CallWindowProcA(main_window.default_proc, hwnd, uMsg, wParam, lParam);
Expand Down

0 comments on commit 226afd2

Please sign in to comment.