I noticed that for controls that implement scrolling themselves through OnMouseWheel, scrolling is extremely poor on macOS. While the OS gives very detailed events, OnMouseWheel only sends out scroll events with +/120. I assume that was done for compatibility with Windows, but even Windows itself has moved away from this already: When using a Microsoft precision touchpad, numbers can be much more fine grained. Microsoft specifically states that apps should not rely on the number 120 :-)
In the Cocoa part of LCL, the conversion is happening here:
https://github.com/graemeg/lazarus/blob/c074908bb0c740f13f82ab62dba8abd68bae556f/lcl/interfaces/cocoa/cocoawscommon.pas#L1225I tried patching this up (in a hacky way) like this:
if dy <> 0 then
begin
Msg.Msg := LM_MOUSEWHEEL;
Msg.WheelDelta := Round(dy * 3);
end
else
if dx <> 0 then
begin
Msg.Msg := LM_MOUSEHWHEEL;
// see "deltaX" documentation.
// on macOS: -1 = right, +1 = left
// on LCL: -1 = left, +1 = right
Msg.WheelDelta := Round(-dx);
end
And scrolling was MUCH improved. For best effects it helps if the custom control actually implements pixel-perfect scrolling, but even those that just handle line-based scrolling things are better. Best example: The Lazarus editor itself, which I found almost unusable before but with that patch feels closer to other apps (pixel-perfect scrolling would make it really good, but that's a much bigger undertaking).
I filed a bug about it (
https://bugs.freepascal.org/view.php?id=38205) that explains why the constant 3. Also attached a test program there.
I'm hoping for more opinions on this, especially from the people who are familiar with the Cocoa side of LCL. Thanks!