Skip to content

Suppress programmatically setting playhead position on drag operations 11176 - #11474

Merged
luapmartin merged 7 commits into
audacity:masterfrom
luapmartin:luapmartin/11176
Jul 28, 2026
Merged

luapmartin merged 7 commits into
audacity:masterfrom
luapmartin:luapmartin/11176

Conversation

@luapmartin

@luapmartin luapmartin commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Resolves: Suppress programmatically setting playhead position on drag operations #11176

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

  • Click in track area → playhead moves on release, not on press
  • Drag a clip → playhead never moves
  • Small jitter click (<5 px) still moves playhead; drag out-and-back does not
  • Drag a long clip with edges off-screen → no viewport jump (the original bug)
  • Drag selection (both directions, multi-track, Ctrl/Shift, edge handles) → playhead unmoved
  • Play after drag selection → plays the selection
  • Stop after that → playhead returns to its pre-selection position ⚠️ intended, most visible change
  • Click while playing → playback uninterrupted; Stop lands on clicked spot, snapped (test near clip edge + grid snap)
  • Known limitation: dragging a clip during playback still stops playback (pre-existing) — but no playhead jump
  • No regression: ruler click (incl. playback-on-ruler-click), playhead handle drag, double-click clip/track, split tool, Ctrl/Shift clip clicks, Esc/focus-loss mid-drag
  • New actions "Move play cursor to selection start/end" (unbound, bind in Preferences → Shortcuts): jump to edge, selection survives, no-op without selection, works during playback

@luapmartin luapmartin self-assigned this Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 593c070f-9a50-4b17-b812-1fb9a0a06d97

📥 Commits

Reviewing files that changed from the base of the PR and between 318290fc1baa4cd733896a0e6d062fb403c68552 and e7ca59a.

📒 Files selected for processing (23)
  • au3/libraries/au3-audio-io/PlaybackSchedule.h
  • au3/src/AdornedRulerPanel.cpp
  • au3/src/ProjectAudioManager.cpp
  • au3/src/menus/SelectMenus.cpp
  • au3/src/tracks/ui/PlayIndicatorOverlay.cpp
  • au3/src/tracks/ui/Scrubbing.cpp
  • src/au3audio/internal/defaultplaybackpolicy.cpp
  • src/playback/tests/mocks/playbackcontrollermock.h
  • src/projectscene/internal/projectsceneuiactions.cpp
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackClipsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackItemsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackLabelsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/CMakeLists.txt
  • src/projectscene/tests/playcursorcontroller_tests.cpp
  • src/projectscene/tests/playpositionactioncontroller_tests.cpp
  • src/projectscene/tests/snaptestaccess.h
  • src/projectscene/view/playcursor/playcursorcontroller.cpp
  • src/projectscene/view/playcursor/playcursorcontroller.h
  • src/projectscene/view/playcursor/playpositionactioncontroller.cpp
  • src/projectscene/view/playcursor/playpositionactioncontroller.h
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.cpp
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.h

📝 Walkthrough

Walkthrough

The change defers track-area playhead seeking until pointer release. PlayCursorController tracks gesture movement, suppresses seeks for drags or cancellations, and records seek time during playback. TracksItemsView integrates the gesture lifecycle and selection handling. Cursor-to-selection start/end actions are added, obsolete seek and selection-direction APIs are removed, and tests cover the new behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Pointer
  participant TracksItemsView
  participant PlayCursorController
  participant PlaybackController
  Pointer->>TracksItemsView: Press in tracks area
  TracksItemsView->>PlayCursorController: beginSeekGesture(...)
  Pointer->>TracksItemsView: Move or release
  TracksItemsView->>PlayCursorController: updateSeekGesture(...) or endSeekGesture()
  PlayCursorController->>PlaybackController: Record last seek time when playing
  PlayCursorController->>PlayCursorController: Dispatch seek for click gestures
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: preventing programmatic playhead updates during drag operations.
Description check ✅ Passed The description largely follows the template with issue link, summary, and checklist, but the QA Testflow checkbox remains unchecked.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/projectscene/tests/playcursorcontroller_tests.cpp (1)

19-19: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

LGTM! Solid coverage of the gesture state machine (click, drag, jitter, cancel, and playing-state paths).

One optional addition: since setLastPlaybackSeekTime currently receives an unsnapped value (see the companion comment on playcursorcontroller.cpp lines 110-130), a variant of SeekGesture_ClickWhilePlaying_RecordsSeekTime_DoesNotMovePlayhead with useGridSnapOff({ boundary }) or useGridSnapOn(...) would pin down the expected (snapped) behavior once fixed.

Also applies to: 41-41, 69-69, 96-96, 198-363


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e1dea0b3-a4a9-41f9-9001-0f17b020dd7b

📥 Commits

Reviewing files that changed from the base of the PR and between 97eb0f2 and 8444590afdd16d61fd54f792bd27f237ed322502.

📒 Files selected for processing (8)
  • src/playback/tests/mocks/playbackcontrollermock.h
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/playcursorcontroller_tests.cpp
  • src/projectscene/tests/snaptestaccess.h
  • src/projectscene/view/playcursor/playcursorcontroller.cpp
  • src/projectscene/view/playcursor/playcursorcontroller.h
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.cpp
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.h
💤 Files with no reviewable changes (2)
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.h
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.cpp

@luapmartin luapmartin changed the title Suppress programmatically setting playhead position on drag operations Suppress programmatically setting playhead position on drag operations 11176 Jul 21, 2026
@luapmartin
luapmartin force-pushed the luapmartin/11176 branch 2 times, most recently from 269bb98 to 4339c76 Compare July 22, 2026 10:36
@grliszas14
grliszas14 self-requested a review July 27, 2026 11:24

@grliszas14 grliszas14 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please prepare QA bulletpoint list to thoroughly check this feature (including manual testing of each test case from unit tests)

Comment on lines +53 to +54
dispatcher()->reg(this, CURS_SEL_START, this, &PlayPositionActionController::cursorToSelectionStart);
dispatcher()->reg(this, CURS_SEL_END, this, &PlayPositionActionController::cursorToSelectionEnd);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put those two somewhere in the upper menu? @teetow @luapmartin
We already have Select->Move cursor to closest zero crossing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we are missing lot of those cursor movements from au3 (at least in menus)

@teetow teetow Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific context: If it has a keybind and a menu item in AU3, we should bring it over (if straightforward). The rest we can defer to later, PRs welcome, guided by user feedback etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/projectscene/tests/playpositionactioncontroller_tests.cpp (1)

161-176: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Also assert that the playing case does not request playback.

This test checks seekTime but not triggerPlay; a regression that restarts playback would still pass. Add the same assertion used by the earlier cursor-action tests.

Proposed assertion
     EXPECT_DOUBLE_EQ(captured.param("seekTime").toDouble(), 5.0);
+    EXPECT_FALSE(captured.param("triggerPlay").toBool());

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 7089b3d0-6c67-4bb9-b467-372889bd8311

📥 Commits

Reviewing files that changed from the base of the PR and between 4339c7637f1f3042b05db6e780bba57bd29a96a6 and 1e74db14be96b010519fa82286f65c0ca58610c0.

📒 Files selected for processing (16)
  • src/playback/tests/mocks/playbackcontrollermock.h
  • src/projectscene/internal/projectsceneuiactions.cpp
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackClipsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackItemsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackLabelsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/CMakeLists.txt
  • src/projectscene/tests/playcursorcontroller_tests.cpp
  • src/projectscene/tests/playpositionactioncontroller_tests.cpp
  • src/projectscene/tests/snaptestaccess.h
  • src/projectscene/view/playcursor/playcursorcontroller.cpp
  • src/projectscene/view/playcursor/playcursorcontroller.h
  • src/projectscene/view/playcursor/playpositionactioncontroller.cpp
  • src/projectscene/view/playcursor/playpositionactioncontroller.h
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.cpp
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.h
💤 Files with no reviewable changes (3)
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackItemsContainer.qml
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.h
  • src/projectscene/view/tracksitemsview/selectionviewcontroller.cpp
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackClipsContainer.qml
  • src/projectscene/internal/projectsceneuiactions.cpp
  • src/projectscene/view/playcursor/playpositionactioncontroller.h
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackLabelsContainer.qml
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TracksItemsView.qml
  • src/projectscene/tests/playcursorcontroller_tests.cpp
  • src/projectscene/view/playcursor/playcursorcontroller.h
  • src/playback/tests/mocks/playbackcontrollermock.h

A press in the track area must not move the playhead immediately: the
target is remembered on press and the seek is dispatched on release,
and only when the gesture stayed a plain click. Dragging past the
threshold (in either axis) or cancelling the gesture suppresses the
seek entirely. While playing, a click records the seek position for
stop without moving the playhead.
Pressing in the track area no longer seeks immediately. The press
begins a deferred seek gesture; the playhead moves on release, and only
when the gesture stayed a plain click. Dragging a clip or a selection
never moves the playhead, so the viewport no longer jumps mid-drag and
playback is left alone.

The release-time isLeftSelection seek is gone with it: it existed only
to patch up the eager mousedown seek after a leftwards selection drag.
Dragging a selection — whether by dragging out a new range, extending
one with Ctrl/Shift, or dragging a selection edge handle — left two
paths that still repositioned the playhead and the next playback start:
the unconditional playback-region update on release (which sets
lastPlaybackSeekTime to the region start) and the seekToX emitted when
a selection resize completes.

Both are gone. The release path now updates playback position state
only when the gesture was a plain click, and the seekToX plumbing is
removed entirely since resizing a selection was its only caller.

Nothing is lost by not setting the region eagerly: doPlay derives its
region from the live data selection when playback starts.
seekToTime returns early when playing, before snapTime runs, so the
position bookmarked for the eventual stop was stored raw while a click
made when not playing lands on the snapped boundary. Clicking near a
clip edge during playback then resumed slightly off that edge.

Snap it explicitly at the call site. Covers both clip-boundary and grid
snapping.
Implements the curs-sel-start / curs-sel-end actions, which existed as
unbound placeholders in shortcuts.xml with no handler. Both move the
play position to an edge of the time selection and scroll it into view,
and are no-ops when there is no time selection.

Unlike the stepping actions, and unlike au3's CursSelStart/CursSelEnd
which collapse the selection to the cursor, these leave the selection
intact — moving the playhead and changing the selection are separate
concerns.

No default shortcut, matching au3 where both ship unbound; the actions
are registered as UiActions so users can bind them in preferences.
@luapmartin
luapmartin merged commit 2412e9a into audacity:master Jul 28, 2026
9 of 10 checks passed
@luapmartin
luapmartin deleted the luapmartin/11176 branch July 28, 2026 18:38
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.

Suppress programmatically setting playhead position on drag operations

3 participants