fix(reactor): drive auto-focus workspace switch from NSWorkspace activations#403
Closed
bhedavivek wants to merge 1 commit into
Closed
Conversation
ce108af to
5e07f25
Compare
…vations Route Event::ApplicationGloballyActivated through AppEventHandler::handle_application_activated after the login-window short-circuit, so Cmd+Tab and dock activations drive the same auto-switch logic as the per-app AXApplicationActivated path. The auto-switch logic is idempotent via its existing guards (active_workspace_switch, manual_switch_in_progress, app_is_on_visible_workspace), so double-firing with the per-app path is safe. Resolve the activated app's bundle id from `app_manager.apps` instead of `NSRunningApplication::with_process_id`. The reactor already records every running app's `AppInfo` when `ApplicationLaunched` is processed, and `NSRunningApplication` is not reachable from unit tests. The early returns when the app is not tracked or has no `CFBundleIdentifier` preserve the existing observable behavior. Six new tests in `actor::reactor::tests`, covering each early-exit and the positive switch path: - globally_activated_app_on_other_workspace_switches_to_apps_workspace - globally_activated_app_on_visible_workspace_does_not_switch - globally_activated_blacklisted_app_does_not_switch_workspace - globally_activated_login_window_does_not_drive_auto_switch - globally_activated_app_without_bundle_id_does_not_switch - globally_activated_untracked_pid_does_not_switch Closes acsandmann#402.
5e07f25 to
727204c
Compare
Author
|
closing as a dup of #400 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #402.
Change
Event::ApplicationGloballyActivated, sent by the wm_controller when NSWorkspace firesdidActivateApplication, now also dispatches toAppEventHandler::handle_application_activated. The login-window short-circuit still runs first; the new call only fires for non-login activations.Quiet::Nois passed.Before this change,
handle_application_activatedis only invoked fromEvent::ApplicationActivated, which originates inactor::app::on_activation_changed. After this change, Cmd+Tab and dock activations of an app on another virtual workspace switch the active workspace.The activated app's bundle id is now resolved from
app_manager.appsinstead ofNSRunningApplication::with_process_id. The reactor already records every running app'sAppInfowhenApplicationLaunchedis processed, andNSRunningApplicationis not reachable from unit tests. The early returns when the app is not tracked or has noCFBundleIdentifierpreserve the existing observable behavior.Tests
Six new unit tests in
src/actor/reactor/tests.rscovering the positive switch path and each early-exit:globally_activated_app_on_other_workspace_switches_to_apps_workspace— activating an app pinned to a different workspace switches the active workspace to that workspace.globally_activated_app_on_visible_workspace_does_not_switch— exits atapp_is_on_visible_workspace.globally_activated_blacklisted_app_does_not_switch_workspace— exits at theauto_focus_blacklistcheck.globally_activated_login_window_does_not_drive_auto_switch— login-window short-circuit fires; new dispatch is skipped.globally_activated_app_without_bundle_id_does_not_switch— app tracked by rift but with noCFBundleIdentifierexits at the bundle-id check.globally_activated_untracked_pid_does_not_switch— pid not present inapp_manager.appsexits at the lookup.cargo test --lib actor::reactor— 57 passing (was 51 before this PR).Manual repro
macOS 26.5 / arm64, single display. Built
cargo build --release, pointed~/Library/LaunchAgents/git.acsandmann.rift.plistat the patched binary, granted Accessibility to the new binary path, restarted vialaunchctl bootout+bootstrap. With theseapp_rules:Starting from workspace 0, Cmd+Tab switched the active workspace as expected for every app with a
CFBundleIdentifierand a currentAXStandardWindow:Two cases did not switch, matching the existing limits of
handle_app_activation_workspace_switch:CFBundleIdentifier(a Cargo debug binary). Exits at the bundle-id check.AXStandardWindow(Zoom between meetings). Exits at theapp_window_idlookup.Manual
Alt+Nswitching,switch_to_last_workspace, andMoveWindowToWorkspacecontinue to work unchanged. Not tested on multi-display, scrolling, or master-stack.