JWM icon indicating copy to clipboard operation
JWM copied to clipboard

Calculate deltaLines macOS

Open jaketothepast opened this issue 1 year ago • 4 comments

Calculate deltaLines from the existing scroll delta. Use the accessibility scaling in calculations.

Related to #115

Screenshot 2024-01-22 at 8 14 58 AM

jaketothepast avatar Jan 22 '24 13:01 jaketothepast

Sorry, I need to get my hands on a mouse. Will check it out soon!

tonsky avatar Jan 24 '24 15:01 tonsky

Okay I did some testing. Some new information:

  1. 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
  2. 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.
  3. 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:

  1. 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
  1. 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

tonsky avatar Jan 25 '24 16:01 tonsky

Of course, sorry about that. I'll change the calculations!

jaketothepast avatar Jan 25 '24 20:01 jaketothepast

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.

jaketothepast avatar Feb 05 '24 14:02 jaketothepast