asmvik / asmvik/yabai

Feature request: per-app focus_follows_mouse exclusion via rules

Open
#2,750 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
29.6k
Forks
750
PR merge metrics
No merged PRs in 30d

Description

## Problem

With `focus_follows_mouse autoraise` enabled globally, certain apps that show transient overlay windows (e.g. notification popups in the corner of the screen) cause their main window to steal focus when the mouse passes over the overlay.

A concrete example: **Granola** displays a small notification in the top-right corner. When the mouse hovers over it, `autoraise` focuses the Granola window, which then raises its main window — stealing focus from whatever you were working on.

## Current workarounds and why they fall short

### `sub-layer=below` rule
```sh
yabai -m rule --add app="^Granola" manage=off sub-layer=below
```
This affects stacking order but does **not** prevent `autoraise` from focusing the window. The window still receives focus and gets raised.

### `window_focused` signal to bounce focus back
```sh
yabai -m signal --add event=window_focused app="^Granola$" action='
recent=$(yabai -m query --windows --window recent 2>/dev/null | jq -r ".id // empty")
if [ -n "$recent" ] && [ "$recent" != "$YABAI_WINDOW_ID" ]; then
yabai -m window --focus recent
fi
'
```
This technically works but has significant drawbacks:
- **Visible flicker** — the window briefly gains focus before bouncing back, which is visually jarring
- **Blocks intentional focus** — you can never focus the app via mouse; only Cmd-Tab works
- **Fragile** — distinguishing notification windows from the main window requires brittle title/subrole matching that can break across app updates
- **Race conditions** — rapid mouse movements can cause focus loops or unexpected behavior

## Proposed solution

Allow `focus_follows_mouse` behavior to be controlled per-app via rules, e.g.:

```sh
yabai -m rule --add app="^Granola$" focus_follows_mouse=off
```

This would let users opt specific apps out of `autoraise` / `autofocus` while keeping it enabled globally for everything else.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the C code that parses window rules and the handling for focus_follows_mouse, autoraise, and autofocus. Trace how a per-app rule could override the global setting without affecting intentional focus. Done means a rule such as app="^Granola$" focus_follows_mouse=off prevents mouse-driven focus while global behavior remains unchanged for other apps.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, macos
Domain
desktop, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.