Skip to content

Conversation

@jaketothepast
Copy link

@jaketothepast jaketothepast commented Jan 22, 2024

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

@tonsky
Copy link
Collaborator

tonsky commented Jan 24, 2024

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

@tonsky
Copy link
Collaborator

tonsky commented Jan 25, 2024

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

@jaketothepast
Copy link
Author

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

@jaketothepast
Copy link
Author

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.

@tonsky tonsky force-pushed the main branch 2 times, most recently from c4ee4a9 to 5bdc87b Compare July 9, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants