FelixKratz / JankyBorders

A lightweight window border system for macOS
GNU General Public License v3.0
1.1k stars 18 forks source link

Better detection of focused window with certain yabai features #66

Closed FelixKratz closed 7 months ago

FelixKratz commented 7 months ago

The current heuristic applied to determine the focused user window is good enough in most cases, however, when JB is used in combination with some more advanced yabai features (e.g. focus_follows_mouse autofocus, or presenting multiple windows of the same app on different system sub-layers) this heuristic breaks apart.

The motivation to use the current heuristic is that it does not require using the slow accessibility API but only fast interactions with the WindowServer. The heuristic depends on the fact that the focused window is usually ordered on top of the application window list. This assumption breaks with the aforementioned yabai modifications applied. As far as I know this is as good as it gets for focused window detection without using the accessibility API, but if someone has another idea, let me know.

Current function for reference: https://github.com/FelixKratz/JankyBorders/blob/bb6ae773bf44f6b605df2be358d92e5b1b757ecd/src/misc/window.h#L24-L71

FelixKratz commented 7 months ago

On current master, launching borders from yabairc (or any other AX trusted process) will automatically enable a fallback method for resolving the focused window that is compatible with all yabai features. This fallback method can also be configured manually with the option ax_focus=<boolean>.

crisidev commented 7 months ago

This solved the issue I reported on #15! This is amazing, thanks!