JWM
JWM copied to clipboard
Calculate deltaLines macOS
Calculate deltaLines
from the existing scroll delta. Use the accessibility scaling in calculations.
Related to #115
Sorry, I need to get my hands on a mouse. Will check it out soon!
Okay I did some testing. Some new information:
- It seems that value of
com.apple.scrollwheel.scaling
is already accounted by macOS. On higher setting, Chrome scrolls much faster, so I guess your app just starts receiving higher deltaY-s - Minimal deltaY seems to be 0.1 (one wheel tick), but if you do several one after the other, deltaY starts to get higher. That’s scroll acceleration, and again, you don’t have to do anything, macOS just sends you correct values.
- By testing both Chrome and Safari, they seem to agree on value of 40 to get from deltaY to px offset. I suggest we do the same
I need you to change some calculations though. Roughly this:
- Trackpad.
- Detect by
[event hasPreciseScrollingDeltas] == true
- Get EventMouseScroll::deltaX/deltaY from [event scrollingDeltaX]/[event scrollingDeltaY]
- Do not fill EventMouseScroll::deltaLines, as there is no by-line scrolling on trackpad
- Mouse
- Detect by
[event hasPreciseScrollingDeltas] == true
- Fill
EventMouseScroll::deltaX/Y
from[event deltaX/Y] * 40
- Fill
EventMouseScroll::deltaLines
from[event deltaY] * 4
(≈[event deltaY] * 40 / CGEventSourceGetPixelsPerLine
)
As a side effect, this will let JWM clients distinguish trackpad from the mouse
Let me know if you have better ideas or questions
Of course, sorry about that. I'll change the calculations!
I promise I haven't forgotten about this! I have a lot of work at my full-time job this week, but when it clears up I will make the changes.