Skip to content

Fix dock-swipe gestures broken on macOS 27 #1924

Open
zhaoqiman wants to merge 1 commit into
noah-nuebling:masterfrom
zhaoqiman:pr-dockswipe-fix
Open

Fix dock-swipe gestures broken on macOS 27 #1924
zhaoqiman wants to merge 1 commit into
noah-nuebling:masterfrom
zhaoqiman:pr-dockswipe-fix

Conversation

@zhaoqiman

@zhaoqiman zhaoqiman commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #1871 and the duplicates (#1873, #1878, #1887, #1891, #1892, #1919, ...).

Problem

CGEventSetIOHIDEvent() attaches an IOHIDEvent to a CGEvent by poking the pointer into the opaque CGEvent/CGSEventRecord struct at hardcoded offsets (0x18 / 0xd0). Those offsets were never a stable ABI, and the struct layout shifted on macOS 27, so the pointer ends up at the wrong address and Dock never sees a real IOHIDEvent - which is why every synthetic dock-swipe gesture (Spaces, Mission Control, Show Desktop, Launchpad) silently stopped doing anything.

Fix

Prefers Apple's own SLEventSetIOHIDEvent, resolved once via the project's existing MFLoadSymbol_native(kMFFrameworkSkyLight, ...) helper (Shared/Utility/PrivateFunctions). Falls back to the offset-writer only pre-macOS-27, where it was actually validated - on 27+ it's skipped instead of executed, since it's already known to be broken there.

Notes

Same root cause and fix direction as #1920 / #1912 / #1916 (swap to SLEventSetIOHIDEvent). A couple of things that came up while testing, in case they're useful:

  • Reuses the project's own MFLoadSymbol_native / kMFFrameworkSkyLight instead of hand-rolling a dlsym call.
  • Also CFRetains the IOHIDEventRef on the new path, matching what the old offset-writer already did - SLEventSetIOHIDEvent's retain contract isn't documented anywhere, and TouchSimulator.m can repost some dock-swipe events up to 500ms later via a timer, so skipping the retain risks a use-after-free if the event isn't retained internally.
  • The offset-writer fallback is skipped on macOS 27+ instead of always running, since the only current caller is gated to macOS 27+.

Testing

Tested on macOS 27 - Spaces/Mission Control/Show Desktop click-and-drag all work again after this.

…ed CGEvent offsets

CGEventSetIOHIDEvent() attaches an IOHIDEvent to a CGEvent by poking the
pointer into the opaque CGEvent/CGSEventRecord struct at hardcoded offsets
(0x18 / 0xd0). Those offsets were never a stable ABI, and the struct layout
shifted on macOS 27, so the pointer ends up at the wrong address and Dock
never sees a real IOHIDEvent - which is why every synthetic dock-swipe
gesture (Spaces, Mission Control, Show Desktop, Launchpad) silently stopped
doing anything. See noah-nuebling#1871 and the pile of duplicates (noah-nuebling#1873, noah-nuebling#1878, noah-nuebling#1887,
noah-nuebling#1891, noah-nuebling#1892, noah-nuebling#1919, ...).

Now prefers Apple's own SLEventSetIOHIDEvent, resolved once via the
project's existing MFLoadSymbol_native(kMFFrameworkSkyLight, ...) helper
(Shared/Utility/PrivateFunctions) instead of a hand-rolled dlsym call.
Also retains the IOHIDEventRef on this path, same as the old offset-writer
did, since SLEventSetIOHIDEvent's retain contract isn't documented and an
extra retain is safer than an under-retain.

The offset-writer is kept as a fallback only for pre-macOS-27, where it
was actually validated - on 27+ it's skipped instead of executed, since
those offsets are already known to be wrong there and running it would
provide no real safety net, just continued exposure to writing an
unvalidated address.

Tested on macOS 27 - Spaces/Mission Control/Show Desktop click-and-drag
all work again after this.

Same root cause as noah-nuebling#1920, noah-nuebling#1912, noah-nuebling#1916 (also switch to
SLEventSetIOHIDEvent); related to noah-nuebling#1895, noah-nuebling#1918.
@zhaoqiman zhaoqiman changed the title Fix macOS 27 dock-swipes: use SLEventSetIOHIDEvent instead of hardcoded CGEvent offsets Fix: dock-swipe gestures broken on macOS 27 Jul 16, 2026
@zhaoqiman zhaoqiman changed the title Fix: dock-swipe gestures broken on macOS 27 Fix dock-swipe gestures broken on macOS 27 Jul 16, 2026
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.

Spaces & Mission Control click-and-drag broken on macOS 27 beta [bug]

1 participant