Skip to content

feat(core): add one swipe per gesture-button press - #2511

Open
stanislav-janu wants to merge 5 commits into
AprilNEA:masterfrom
stanislav-janu:feat/one-swipe-per-press
Open

stanislav-janu wants to merge 5 commits into
AprilNEA:masterfrom
stanislav-janu:feat/one-swipe-per-press

Conversation

@stanislav-janu

@stanislav-janu stanislav-janu commented Nov 10, 2026 •

Copy link
Copy Markdown

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_true to false, plus the test).

One swipe per press in Settings → General

Changes

  • openlogi-core: SwipeAccumulator reads set_one_swipe_per_press when a hold begins. Such a hold commits once and ignores the rest of its travel. Its state is now one Hold (Idle / Held), and a held press one Stroke (Tracking / Stroking / Rested / Consumed), each carrying only its own travel. New AppSettings::one_gesture_per_press, default true, also for configs that predate it.
  • openlogi-inject: set_desktop_chain. One Flight phase 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_settings hands 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-targets and the non-GUI rustdoc job with RUSTDOCFLAGS="-D warnings", green on macOS 27.2 (arm64) with Rust 1.100 (rustfmt from 1.99.1), and the MSRV cargo check on 1.99.1. cargo clippy --target aarch64-unknown-linux-musl -p openlogi-inject -p openlogi-core --all-targets -- -D warnings green too.
  • New tests: 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.
  • Counter-proof: with the load in SwipeAccumulator::begin removed, published_swipe_policy_is_kept_for_each_press fails with [Right, Right, Right, Right, Left, Right] instead of [Right].
  • Hardware: MX Master 3S over Bluetooth on macOS 27.2, with "Move left/right a space" enabled (the shortcut path). One long sweep moved one desktop. Double and triple presses during one movement moved two and three desktops, and the agent log showed every follow-up posted, none skipped. That run used the first version of this branch; the phase machine and the state enum that followed review are covered by tests only. The slide and instant fallbacks and Linux/Windows are not runtime-tested on hardware.

@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the outstanding follow-up ownership issue is fixed.

Summary

Adds a default-on “One swipe per press” setting and lets macOS desktop switches follow an earlier switch.

  • Each gesture-button press now produces at most one swipe.
  • A second desktop request can follow a switch already in progress.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Idle -->|Admit lead| Preparing
    Preparing -->|Claim post before deadline| Posting
    Posting -->|Finish posting| Confirming
    Confirming -->|Lead ends without pending followers| Idle
    Confirming -->|Lead ends with pending followers| Draining
    Draining -->|Admit or finish a follower| Draining
    Draining -->|Last follower drops| Idle
Loading

Reviews (5) · Last reviewed commit: "fix(inject): keep the flight until every..." · Reviewed by Greptile

@stanislav-janu

Copy link
Copy Markdown
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 map_unwrap_or, not from this diff. #2566 fixes them.

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
stanislav-janu force-pushed the feat/one-swipe-per-press branch from 4184522 to 944392a Compare November 23, 2026 09:47
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs: decision Needs a maintainer/product decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants