Repository navigation
feat(core): add one swipe per gesture-button press - #2511
Open
stanislav-janu wants to merge 5 commits into
Open
stanislav-janu wants to merge 5 commits into
stanislav-janu wants to merge 5 commits into
Conversation
stanislav-janu
requested review from
AprilNEA and
davidbudnick
as code owners
November 10, 2026 13:20
[Medium impact] The PR appears safe to merge; the outstanding follow-up ownership issue is fixed.
|
Author
|
Heads-up: three newer PRs touch the same gesture code, so whichever lands first will conflict with the others.
The red clippy jobs here come from rustc 1.100's |
Logi Options+ treats every press of the gesture button as exactly one swipe: pressing twice during one sideways movement moves two desktops, and a press during the slide starts the next switch at once. OpenLogi treats a hold as a stroke that can repeat (AprilNEA#1652) and drops a desktop switch requested while one is in flight. Add the app setting one_gesture_per_press, on by default as in Logi Options+. A hold that begins under it commits once and ignores the rest of its travel. On macOS a Previous or Next Desktop requested while a switch is in flight on the same display is posted at once, serialized with the switch in flight. Turning it off restores the repeating stroke.
The accumulator tracked a hold through independent fields (held_since, fired, last, one_per_press) that could disagree, such as a held press that never fired but has a committed direction. It now holds one Hold, Idle or Held, and a held press one Stroke: Tracking, Stroking, Rested or Consumed, each carrying only its own travel. The rule a press began with lives only in Tracking, so a chained stroke under the one-swipe rule can't be represented. The one-swipe-per-press test no longer sets the rule through a test seam. It runs in its own test binary, since the choice is process-wide, and goes through set_one_swipe_per_press and begin(). With the load in begin() removed it fails.
A follow-up could be posted while the switch it followed was still reading its Spaces. The Space then moved under that switch, which gave up without posting, so two requests made one switch. A busy flag and a separate in-flight record also tracked one lifecycle between them. One Flight phase machine, Idle, Preparing or Confirming with a flight id, now owns the single-flight rule. A follow-up on the same display waits until the switch in flight has posted, never past its preparation deadline, and is refused if it never posts. A late call about one switch never changes the next. Both posting paths also read the cursor display only once they hold the posting lock, since a request can wait behind another switch's slide while the pointer leaves the display.
A follow-up waited for the switch in flight only until that switch's preparation deadline. A preparation that ended just before its deadline could still start a slide of about 315 ms, and a follow-up then hit the deadline mid-slide and was dropped, so two presses made one switch. The flight now has a Posting phase. A switch claims its post under the flight's lock, against the same deadline a waiting follow-up checks, right before its gate commits. From then on follow-ups wait for the post however long it takes, as the dispatching caller does. A claimed post the gate refuses is given back, so waiting follow-ups see the deadline again.
stanislav-janu
force-pushed
the
feat/one-swipe-per-press
branch
from
November 23, 2026 09:47
4184522 to
944392a
Compare
A follow-up held only the id of the switch it followed. When that switch landed and dropped its ticket while the follow-up was still preparing or posting, the flight went idle, and a new request could lead and read Spaces the follow-up was about to change. That request then saw the Space move and gave up, so three presses could make fewer switches. A follower is now a guard the flight counts. A switch that ends with follow-ups outstanding leaves the flight draining: requests on its display still follow, others are refused, and the last follow-up to finish frees it. a_stale_follow_up_never_marks_the_next_switch asserted the old behaviour and is replaced by follow_up_keeps_flight_until_post_finishes.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Logi Options+, every press of the gesture button is exactly one swipe. Press twice while the hand moves sideways and you move two desktops, three times and you move three, and a press during the slide starts the next switch right away. OpenLogi treats a hold as a stroke instead: one long sweep can repeat (#1652), so a single sweep that travels far enough moves two desktops, and a Previous/Next Desktop requested while a switch is still in flight is dropped.
This adds
one_gesture_per_press(Settings → General → "One swipe per press"), on by default to match Options+. That changes the default that #1652 introduced. Turning the setting off restores today's behaviour, so anyone who relies on the repeating stroke is one toggle away from it. If you'd rather keep #1652 as the default, it's a one-line change (default_truetofalse, plus the test).Changes
openlogi-core:SwipeAccumulatorreadsset_one_swipe_per_presswhen a hold begins. Such a hold commits once and ignores the rest of its travel. Its state is now oneHold(Idle/Held), and a held press oneStroke(Tracking/Stroking/Rested/Consumed), each carrying only its own travel. NewAppSettings::one_gesture_per_press, defaulttrue, also for configs that predate it.openlogi-inject:set_desktop_chain. OneFlightphase machine (Idle/Preparing/Posting/Confirming/Draining, with a flight id) replaces the busy flag. On macOS, a switch requested while another is in flight on the same display follows it: it waits until that switch has posted, then posts at once instead of being dropped. It waits for a preparation only until that preparation's deadline, but for a post claimed before the deadline as long as the post takes, like the caller that dispatched it. The in-flight switch keeps the single confirmation. A follow-up holds the flight until it has posted, so a switch that lands first leaves the flight draining instead of letting a new switch read Spaces the follow-up is changing. A posting lock keeps two switches' events from interleaving, since desktop switches arrive from both the hook's action worker and the HID++ gesture sessions, and the cursor display is checked only once that lock is held.openlogi-agent-core:publish_gesture_settingshands the setting to both layers on load and on reload.openlogi-desktop: the switch in Settings → General, after Thumb wheel sensitivity.openlogi-ui: two strings (en, cs; the other catalogs carry the English text).docs/CONFIGURATION.md: the new key.Testing
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --all-targetsand the non-GUI rustdoc job withRUSTDOCFLAGS="-D warnings", green on macOS 27.2 (arm64) with Rust 1.100 (rustfmt from 1.99.1), and the MSRVcargo checkon 1.99.1.cargo clippy --target aarch64-unknown-linux-musl -p openlogi-inject -p openlogi-core --all-targets -- -D warningsgreen too.published_swipe_policy_is_kept_for_each_press(its own test binary, since the choice is process-wide),one_gesture_per_press_is_on_unless_turned_off,every_phase_decides_every_request,follow_up_waits_for_first_post,follower_waits_for_committed_post_past_preparation_deadline,a_post_claimed_too_late_or_refused_by_its_gate_lets_no_follow_up_through,a_follow_up_of_a_switch_that_never_posted_is_refused,follow_up_keeps_flight_until_post_finishes,desktop_post_rechecks_display_after_wait. The existing accumulator tests pass with their assertions unchanged.SwipeAccumulator::beginremoved,published_swipe_policy_is_kept_for_each_pressfails with[Right, Right, Right, Right, Left, Right]instead of[Right].