Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 201 additions & 0 deletions LICENSE-FasterSwiper.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2026 Matthew Bowen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,65 @@ The app is about 1,486 lines of Swift and C with no third-party dependencies —
strafe switch left|right # switch once and exit
strafe status # print accessibility / tap status
strafe speed [preset] # show or set transition speed
strafe mc-probe [seconds] # sample overlay detection for diagnosis
strafe # start the menu-bar app
```

## macOS 27 support

On macOS 27 the legacy synthetic gesture is ignored, so strafe uses an
embedded IOHID gesture payload with paced asynchronous posting there, selected
automatically (`STRAFE_EVENT_PROFILE=legacy` forces the old path). Physical
interception is restricted to horizontal HID23 gestures; ambiguous HID32 events
are logged in diagnostic mode but passed through. Hotkeys and trackpad
switching are verified live on 27 including both edges; ramp presets and
pre-27 behavior still want a second machine's confirmation, and the macOS 26
measurements above do not describe the new output path.

Build with `./Scripts/bundle.sh`, quit any running Strafe instance, then run:

```bash
STRAFE_DIAGNOSTICS=1 ./build/strafe.app/Contents/MacOS/strafe 2>&1 | tee /tmp/strafe-macos27.log
```

Test Control + Option + Left/Right from a middle Space, one press at a time.
Diagnostics distinguish posted phases from an observed neighboring Space, or a
timeout. Indices in the logs are **zero-based**. The engine serializes requests
and waits for a stable live destination rather than counting unconfirmed moves.
This diagnostic policy includes 100 ms of destination stability before servicing
the next queued request; it is not the final rapid-switch latency tuning.

Options are read from the environment at launch:

| Variable | Values / default |
|---|---|
| `STRAFE_EVENT_PROFILE` | `auto` (macOS 27+ payload, older OS legacy), `legacy`, `macos27` |
| `STRAFE_PHASE_GAP_MS` | `0`–`100`; default `10` for macOS27, `0` for legacy |
| `STRAFE_INVERT_DIRECTION` | Defaults to `1` for augmented output, `0` for legacy; explicit `0`/`1` overrides |
| `STRAFE_INVERT_SWIPE_DIRECTION` | Defaults to `0` (upstream convention: positive progress means right); `1` flips the physical-progress mapping |
| `STRAFE_INTERCEPT_SWIPES` | `1` (default); `0` leaves trackpad gestures native for hotkey-only testing |
| `STRAFE_DIAGNOSTICS` | `0` (default), `1` for request/gesture diagnostics |

Run `bash Scripts/test.sh` for non-posting serialization and mock-engine tests.
These tests work with Command Line Tools and do not require XCTest. The existing
`bench/` raw poster remains the **legacy** path; its timing results do not validate
the new asynchronous app path.

The initial live test confirmed instant switching but reversed output signs.
The current build corrects those signs separately from physical swipe progress.
Mission Control, App Exposé and Show Desktop gestures pass through while an
overlay is detected (Dock Accessibility notifications plus a window-layer
snapshot). A failure within a second of an overlay is never counted, a merely
changing topology never fails a switch early, and interception pauses only
after three delivery failures in a row — so mashing swipes through Mission
Control's close animation can't kill it. If overlay detection misbehaves on
your macOS version, run `strafe mc-probe`, open and close Mission Control
while it samples, and share the log.
If delivery times out, goes to an unexpected Space, or cannot be prepared,
trackpad interception is disabled automatically; it can be re-enabled from the
menu. Hotkeys remain available. For initial hotkey-only diagnosis, prefix the
launch command with `STRAFE_INTERCEPT_SWIPES=0`.

## Permissions

strafe needs **Accessibility** permission, and only that. macOS requires it to
Expand Down
22 changes: 17 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tap. That is a lot of trust to ask for, so this document states exactly what
strafe can and cannot do, and how to verify every claim yourself. Every claim
below points at a file and line you can read or a command you can run.

The whole program is about **1,486 lines** of Swift + C (`wc -l Sources/**`).
The program is a small Swift + C codebase (`wc -l Sources/strafe/*.swift Sources/CStrafe/*.{c,h} Sources/CStrafe/include/*.h`).
You can build it from source in about 30 seconds (`swift build`) and audit it
in an afternoon.

Expand All @@ -32,11 +32,12 @@ do so. The tap's event mask is defined in exactly one place, and it covers

```c
uint64_t strafe_tap_event_mask(void) {
return (1ULL << kCGSEventGesture) | (1ULL << kCGSEventDockControl);
return (1ULL << kCGSEventGesture) | (1ULL << kCGSEventDockControl)
| (1ULL << kCGSEventFluidTouchGesture);
}
```

That is `(1<<29) | (1<<30)` — the two private trackpad-gesture event types
That is `(1<<29) | (1<<30) | (1<<31)` — the private trackpad-gesture event types
and nothing else. There is no `kCGEventKeyDown`/`kCGEventKeyUp` bit. There is
no second mask and no setting that widens this one.

Expand Down Expand Up @@ -69,8 +70,10 @@ the wrappers in `Sources/CStrafe/CStrafe.c` (lines 221–242):
- swipe motion axis (field 123) — `strafe_event_swipe_motion`
- gesture phase (field 132) — `strafe_event_gesture_phase`
- swipe progress (field 124) — `strafe_event_swipe_progress`
- generic macOS 27 swipe progress (field 119) — `strafe_event_generic_progress`
- swipe velocity X (field 129) — `strafe_event_swipe_velocity_x`
- source process id — `strafe_event_source_pid`
- source user-data marker — `strafe_event_is_strafe`, to exclude our own output

That is the entire surface of event data strafe inspects: enough to tell a real
horizontal 3-finger space swipe from anything else, and its direction. No
Expand All @@ -84,6 +87,11 @@ pick which display to switch on (`copy_cursor_display_identifier`, same file
line 112). Neither the window list nor the cursor position is stored or
transmitted; both are read, used for that one decision, and discarded.

`Sources/strafe/MissionControlMonitor.swift` also registers an Accessibility
observer on Dock for Exposé/Mission Control/Show Desktop entry and exit. It
tracks only overlay state, and reconnects if Dock relaunches. This uses the
existing Accessibility permission and does not observe application contents.

---

## What strafe never does
Expand All @@ -107,8 +115,12 @@ Each of these is verifiable with a single grep over `Sources/`.
- **No analytics or telemetry.** strafe writes only to the process's own
`stderr` (`grep -rn FileHandle.standardError Sources/`) and `stdout` (the
`strafe status` CLI readout in `Permissions.printStatus`, `Sources/strafe/Permissions.swift`
line 28) — never to a network socket, a file, or an analytics sink. Nothing
batches, serializes, or transmits usage.
~line 28) and the `speed` / `mc-probe` CLI readouts — never to a network
socket, a file, or an analytics sink. Nothing batches, serializes, or
transmits usage. Opt-in `STRAFE_DIAGNOSTICS=1` logs gesture metadata (up to 64
candidate samples), display/Space IDs, requested direction, phase timing and
transition results to stderr. Errors are logged even without that option.
A shell command using `tee` saves these diagnostics to a file chosen by the user.

- **No auto-update, and no update check.** strafe never downloads or executes
anything. There is no updater, no Sparkle, no download URL, and nothing that
Expand Down
3 changes: 3 additions & 0 deletions Scripts/bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ echo "==> Assembling $APP_NAME.app (version $VERSION)…"
rm -rf "$APP_DIR"
mkdir -p "$MACOS_DIR"
cp "$BIN_PATH" "$MACOS_DIR/$BIN_NAME"
mkdir -p "$APP_DIR/Contents/Resources"
cp "$ROOT_DIR/LICENSE" "$ROOT_DIR/THIRD-PARTY-LICENSES.txt" \
"$ROOT_DIR/LICENSE-FasterSwiper.txt" "$APP_DIR/Contents/Resources/"

# Strip symbols from the SHIPPED copy (not the .build artifact) BEFORE signing —
# stripping mutates the binary and would invalidate a prior signature. -rSTx
Expand Down
Loading