Skip to content

fix: suppress unintended tag switch from macOS auto-activation after app termination#161

Merged
typester merged 3 commits intomainfrom
fix/auto-tag-change
Apr 13, 2026
Merged

fix: suppress unintended tag switch from macOS auto-activation after app termination#161
typester merged 3 commits intomainfrom
fix/auto-tag-change

Conversation

@typester
Copy link
Copy Markdown
Owner

When apps are terminated in quick succession (e.g., repeated Cmd-Q), macOS auto-activates another app which may have hidden windows on a different tag, causing an unwanted tag switch. The existing deferred logic (same-batch WindowDestroyed detection) cannot handle this because the AppTerminated event arrives in a later batch (~60ms delay).

Add last_app_terminated_at timestamp to RunLoopContext. When a deferred tag switch decision finds the window still alive but an app was terminated within the last 2 seconds, suppress the tag switch and restore focus to the current display's visible window instead.

typester added 2 commits March 6, 2026 10:38
…app termination

When apps are terminated in quick succession (e.g., repeated Cmd-Q),
macOS auto-activates another app which may have hidden windows on a
different tag, causing an unwanted tag switch. The existing deferred
logic (same-batch WindowDestroyed detection) cannot handle this because
the AppTerminated event arrives in a later batch (~60ms delay).

Add last_app_terminated_at timestamp to RunLoopContext. When a deferred
tag switch decision finds the window still alive but an app was
terminated within the last 2 seconds, suppress the tag switch and
restore focus to the current display's visible window instead.
Rename last_app_terminated_at to last_focused_window_destroyed_at and
set the timestamp when the focused window is destroyed (not just on
AppTerminated). This covers Cmd-W closing the last window of an app
and batch-separated events where workspace callback hasn't fired yet.

Also narrow the timestamp scope to only fire when focus is actually
lost, preventing false suppression after background app termination.
@typester typester force-pushed the fix/auto-tag-change branch from 9f63a37 to f52b549 Compare March 7, 2026 18:18
macOS can take over 500ms to redirect Firefox focus to a different
window on another display after activate_application. The previous
500ms suppression window was insufficient, causing spurious tag
switches when auto-raise focused Firefox on a secondary display.

Also add debug logging to find_window_at_point and auto-raise
no-window branch to aid future diagnosis.
@typester typester merged commit 5855bb2 into main Apr 13, 2026
2 checks passed
@typester typester deleted the fix/auto-tag-change branch April 13, 2026 12:22
@github-actions github-actions bot mentioned this pull request Feb 25, 2026
typester pushed a commit that referenced this pull request Apr 13, 2026
## 🤖 New release

* `yashiki-ipc`: 0.12.0 -> 0.12.1
* `yashiki`: 0.12.0 -> 0.12.1
* `yashiki-layout-tatami`: 0.12.0 -> 0.12.1
* `yashiki-layout-byobu`: 0.12.0 -> 0.12.1

<details><summary><i><b>Changelog</b></i></summary><p>

## `yashiki-ipc`

<blockquote>

##
[0.12.0](yashiki-ipc-v0.11.6...yashiki-ipc-v0.12.0)
- 2026-02-25

### Added

- [**breaking**] add keybinding mode system (river-style)
([#157](#157))
</blockquote>

## `yashiki`

<blockquote>

##
[0.12.1](yashiki-v0.12.0...yashiki-v0.12.1)
- 2026-04-13

### Fixed

- suppress cross-PID spurious focus bounce on tag switch
([#165](#165))
- suppress unintended tag switch from macOS auto-activation after app
termination ([#161](#161))
</blockquote>

## `yashiki-layout-tatami`

<blockquote>

##
[0.7.3](yashiki-layout-tatami-v0.7.2...yashiki-layout-tatami-v0.7.3)
- 2026-01-20

### Other

- update Cargo.lock dependencies
</blockquote>

## `yashiki-layout-byobu`

<blockquote>

##
[0.7.3](yashiki-layout-byobu-v0.7.2...yashiki-layout-byobu-v0.7.3)
- 2026-01-20

### Other

- update Cargo.lock dependencies
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant