From 05444bb0917ff06361ae9cf8dc297b21f0b71f04 Mon Sep 17 00:00:00 2001 From: Yigit BALABAN Date: Fri, 30 Oct 2026 23:11:28 +0300 Subject: [PATCH] =?UTF-8?q?Fire=20App=20Expos=C3=A9=20on=20slide=20down=20?= =?UTF-8?q?while=20held?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Press the thumb button and slide down, and App Exposé fires as soon as the slide crosses the threshold, once per hold. The release then does nothing. Left, right, up and tap still act on release. Assisted-by: Claude Sonnet 5.5 Signed-off-by: Yigit BALABAN --- mxd.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mxd.swift b/mxd.swift index 6b34155..e79110f 100644 --- a/mxd.swift +++ b/mxd.swift @@ -56,7 +56,8 @@ struct Config { // CID_BACK: .shortcut(0x30, [.maskCommand, .maskShift]), // Cmd-Shift-Tab... (0x30 = Tab) // CID_BACK: .mouseButton(3), // let each app decide what "back" means ] - // Gesture button: false = act on press (instant). true = hold+swipe ←/→ Spaces, ↓ App Exposé, tap = its action. + // Gesture button: false = act on press (instant). true = hold+swipe: ↓ App Exposé fires at once while held; + // ←/→ Spaces and ↑ Mission Control fire on release; tap = its action. var gestureSwipes = true var gestureThreshold = 60 // raw sensor counts before a hold counts as a swipe @@ -366,7 +367,7 @@ final class Device { var inbox: [[UInt8]] = [] let buf = UnsafeMutablePointer.allocate(capacity: 64) var pressed: Set = [] - var gestureDown = false, gx = 0, gy = 0 + var gestureDown = false, gestureFired = false, gx = 0, gy = 0 var busy = false var diverted: [UInt16] = [] var divertsApplied = false // buttons currently match !frontmostIgnored @@ -544,13 +545,14 @@ func syncDiverts(_ d: Device) { // MARK: - Button events func buttonDown(_ d: Device, _ cid: UInt16) { - if cid == CID_GESTURE && config.gestureSwipes { d.gestureDown = true; d.gx = 0; d.gy = 0; return } + if cid == CID_GESTURE && config.gestureSwipes { d.gestureDown = true; d.gestureFired = false; d.gx = 0; d.gy = 0; return } if let a = config.buttons[cid] { perform(a) } } func buttonUp(_ d: Device, _ cid: UInt16) { guard cid == CID_GESTURE, config.gestureSwipes, d.gestureDown else { return } d.gestureDown = false + if d.gestureFired { return } let t = config.gestureThreshold if verbose { log("gesture dx=\(d.gx) dy=\(d.gy)") } if abs(d.gx) < t && abs(d.gy) < t { perform(config.buttons[CID_GESTURE] ?? .missionControl) } @@ -594,6 +596,8 @@ func handleReport(_ d: Device, _ r: [UInt8]) { guard d.gestureDown else { return } d.gx += Int(Int16(bitPattern: UInt16(r[4]) << 8 | UInt16(r[5]))) d.gy += Int(Int16(bitPattern: UInt16(r[6]) << 8 | UInt16(r[7]))) + // slide down past the threshold fires App Exposé now, once per hold; release then does nothing + if !d.gestureFired && d.gy >= config.gestureThreshold && d.gy > abs(d.gx) { d.gestureFired = true; perform(.appExpose) } default: break } }