Skip to content

Fix touchpad swipe/pinch and mouse wheel scroll behaviour - #74

Draft
Nidrax wants to merge 2 commits into
trunkfrom
claude/issue-11-20260705-1241
Draft

Fix touchpad swipe/pinch and mouse wheel scroll behaviour#74
Nidrax wants to merge 2 commits into
trunkfrom
claude/issue-11-20260705-1241

Conversation

@Nidrax

@Nidrax Nidrax commented Jul 5, 2026

Copy link
Copy Markdown
Member
  • Two-finger trackpad swipes (precise wheel events) now always freely pan the viewport on both axes, instead of behaving like mouse wheel notches (vertical swipe zooming, horizontal swipe panning).
  • Pinch gesture zoom stays free/continuous by default; holding Ctrl while pinching now snaps to the nearest integer zoom level.
  • Regular mouse wheel scrolling is now consistent between the vertical and horizontal axes: both pan by default, or both zoom when Ctrl is held (or vice versa if "Zoom with scroll wheel" is unchecked), instead of vertical wheel zooming while horizontal wheel/shift+wheel panned.
  • Removed the now-obsolete "Zoom sliding two fingers" preference, since swiping always pans.

Fixes #11

Co-authored-by: Claude noreply@anthropic.com

- Two-finger trackpad swipes (precise wheel events) now always freely
  pan the viewport on both axes, instead of behaving like mouse wheel
  notches (vertical swipe zooming, horizontal swipe panning).
- Pinch gesture zoom stays free/continuous by default; holding Ctrl
  while pinching now snaps to the nearest integer zoom level.
- Regular mouse wheel scrolling is now consistent between the
  vertical and horizontal axes: both pan by default, or both zoom
  when Ctrl is held (or vice versa if "Zoom with scroll wheel" is
  unchecked), instead of vertical wheel zooming while horizontal
  wheel/shift+wheel panned.
- Removed the now-obsolete "Zoom sliding two fingers" preference,
  since swiping always pans.

Fixes #11

Co-authored-by: Daniel Praźmo <Nidrax@users.noreply.github.com>
@Nidrax
Nidrax force-pushed the claude/issue-11-20260705-1241 branch from e08f4ef to 34b3baa Compare July 20, 2026 22:11
@Nidrax
Nidrax marked this pull request as draft July 23, 2026 08:59
@Nidrax

Nidrax commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

@claude doesn't seem to be working when I test it on my MacBook Pro.
Can you cross-compare it with this proposed change to understand the context better and then commit an update: LibreSprite@6fd4572 ?

@claude

claude Bot commented Jul 28, 2026

Copy link
Copy Markdown

Claude finished @Nidrax's task in 8m 11s —— View job


Findings and fix

Root cause: the new pan/zoom logic in src/app/ui/editor/state_with_wheel_behavior.cpp (added by this PR) branches on msg->preciseWheel(), but that flag is set exclusively by the native, non-SDL2 Cocoa backend (src/she/osx/view.mm). Besprited's default build (USE_SDL2_BACKEND=on) uses src/she/sdl2/she.cpp instead, and its SDL_MOUSEWHEEL handler never called setPreciseWheel()/setPointerType() at all — so preciseWheel() was always false, on macOS and every other platform. Two-finger swipes therefore always fell into the "regular wheel notch" branch (zoom on vertical, pan on horizontal) instead of free-panning. On top of that, SDL2's Cocoa backend never forwards trackpad pinch as any SDL event, so onTouchMagnify never fired either — pinch-zoom was simply inert, matching what @Nidrax saw.

This lines up with what LibreSprite#581 independently found and fixed for their SDL2 backend.

Changes pushed (src/she/sdl2/she.cpp, src/she/sdl2/sdl2_display.cpp, src/she/CMakeLists.txt, new src/she/osx/magnify_gesture.mm):

  • she.cpp's SDL_MOUSEWHEEL case now sets preciseWheel/Multitouch pointer type: via SDL's preciseX/preciseY fields (SDL ≥ 2.0.18) on non-Apple platforms, and unconditionally on macOS (mirroring macOS improvements: trackpad gestures, menu search, and toolbar badges LibreSprite/LibreSprite#581's reasoning — virtually all Mac scroll input is trackpad-originated, and pinch is the dedicated zoom gesture).
  • Added osx/magnify_gesture.mm, which swizzles magnifyWithEvent: on SDL's own content view (SDL2 never forwards this gesture) to queue TouchMagnify events — ported from macOS improvements: trackpad gestures, menu search, and toolbar badges LibreSprite/LibreSprite#581's approach and adapted to reuse Besprited's existing she::Event/TouchMagnify plumbing (the same one the native osx backend's view.mm already uses), rather than copying their bespoke Objective-C event struct.
  • Wired osx_magnify::init() into sdl2_display.cpp next to the existing tablet-support init, and gated the new file in CMake to APPLE AND USE_SDL2_BACKEND (the native backend already implements magnify directly).

I deliberately did not port LibreSprite#581's unconditional removal of the horizontal-scroll delta negation — that part of their patch touches all platforms without an explained rationale, and flipping it blind risks inverting horizontal wheel scroll on Linux/Windows. If horizontal direction still feels wrong on your Mac after this fix, it's a one-line, well-scoped follow-up.

Limitation: I can't build or run Besprited on macOS from this environment (Linux sandbox, no Xcode/macOS SDK, and the system CMake here is too old for this repo's cmake_minimum_required anyway), so this is reviewed carefully but not compiled/tested on real hardware. Please build and test on your MacBook Pro and let me know if swipe-panning and pinch-zoom now work as expected.

Branch: claude/issue-11-20260705-1241

The SDL2 backend (default on all platforms, including macOS) never
called setPreciseWheel()/setPointerType(Multitouch) on MouseWheel
events, so the trackpad-swipe-always-pans logic added for #11 was
dead code everywhere except the legacy native osx backend. It also
never emitted TouchMagnify events at all, since SDL2's Cocoa backend
does not forward pinch gestures.

- she.cpp: detect precise wheel via SDL's preciseX/preciseY (2.0.18+)
  on non-Apple platforms; always treat wheel input as precise on
  macOS, since virtually all Mac scroll input is trackpad-originated
  and pinch is the dedicated zoom gesture.
- Add osx/magnify_gesture.mm: swizzles magnifyWithEvent: on SDL's
  content view to queue TouchMagnify events, mirroring what the
  native osx backend's view.mm already does, ported from
  LibreSprite#581.

Fixes #11

Co-authored-by: Daniel Praźmo <4753308+Nidrax@users.noreply.github.com>
@Nidrax
Nidrax force-pushed the trunk branch 2 times, most recently from 464d137 to 1904c2b Compare August 13, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix touchpad and mouse scroll behaviour

1 participant