From 9de071c366b85ff2ed59f159860a61f643930e7c Mon Sep 17 00:00:00 2001 From: prompt.ac/@jeffrey Date: Mon, 10 Aug 2026 21:19:16 +0000 Subject: [PATCH] Give key-promoted focus the whole surface Clicking a menubar piano key provisionally arms local key delivery, and the first mapped physical key promotes that audition to keyboard- performance focus. But the promotion set `keyboardPerformanceFocusActive` and stopped there — the bookkeeping half. The surface half (TrackDrum armed, click shields up, cursor hidden and pinned, focus watchdog running) lived inside `beginFocusCaptureFromShortcut`, reachable only by the Command double-tap. So a promoted session wore every sign of focus — red glow, defocus cue, icon state — over a dead trackpad. Split that half out as `enterFullPerformanceFocus` and give it to both doors. The promotion defers it off the key event for the same reason the quiet-focus tap defers: arming does real AppKit work, and running it mid-dispatch resigns the very capture it is promoting. Co-Authored-By: Claude Opus 5 (1M context) --- slab/menuband/Sources/MenuBand/AppDelegate.swift | 31 +++++++++++++++++++++++++++++++ 1 file(s) changed, 31 insertion(s)(+), 0 deletion(s)(-) diff --git a/slab/menuband/Sources/MenuBand/AppDelegate.swift b/slab/menuband/Sources/MenuBand/AppDelegate.swift --- a/slab/menuband/Sources/MenuBand/AppDelegate.swift +++ b/slab/menuband/Sources/MenuBand/AppDelegate.swift @@ -1469,7 +1469,23 @@ // A mouse click may provisionally arm the local key panel, but // the first mapped PHYSICAL key is what promotes that state to // keyboard-performance focus. Mouse-only auditions therefore // never acquire slide ownership or the red defocus cue. + let promoting = !self.keyboardPerformanceFocusActive self.keyboardPerformanceFocusActive = true + if promoting { + // Promotion is the SAME focus ⌘⌘ arms, so it owes the same + // surface: TrackDrum live, pointer hidden and pinned. The + // flag alone left the trackpad dead in a session that + // otherwise looked focused. Deferred off the key event for + // the reason the quiet-focus tap defers — arming does real + // AppKit work (key-window dance, click-shield handshake), + // and running it mid-dispatch resigns the very capture it + // is promoting. + DispatchQueue.main.async { [weak self] in + guard let self, self.localCapture.isArmed, + self.keyboardPerformanceFocusActive else { return } + self.enterFullPerformanceFocus() + } + } // Note plays only — the floating panel is reserved // for explicit triggers (LED chip / gear popover). // Earlier this called `showIfNeeded()` so a typed @@ -2028,6 +2044,21 @@ _ = startTrackpadPercussionSystemClickShield() } #endif localCapture.arm() + enterFullPerformanceFocus() + } + + /// The pointer-owning half of focus: the TrackDrum (or local slide) skin, + /// plus the hidden, pinned cursor that says Menu Band has the surface. + /// Split out because focus has two doors — the ⌘⌘ gesture above, and the + /// first mapped physical key promoting a mouse audition (see the + /// `localCapture.onKey` handler). Both need the whole thing; the key path + /// used to flip `keyboardPerformanceFocusActive` alone and leave the + /// trackpad dead. + /// + /// Assumes `localCapture` is already armed — the shortcut path installs + /// its click shield before arming for the readiness handshake, and every + /// other shield here is idempotent. + private func enterFullPerformanceFocus() { #if MAC_APP_STORE // Command-Command is the explicit trackpad-performance gesture. If // TrackDrum is available, always arm it here even when a previous Tab -- tangled.sh