FelixKratz / JankyBorders

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

yabai autofocus does not activate border #15

Closed crisidev closed 10 months ago

crisidev commented 10 months ago

Hello, I am not sure if this is by design or not :)

I use yabai with focus_follows_mouse autofocus and if I have 2 windows in the same space and move the mouse from the active one to other, the border remain on the first window, while the focus changes. The same does not happen of course if I use focus_follows_mouse autoraise.

Would you be open to enable this functionality (I am not even sure its possible)?

FelixKratz commented 10 months ago

The assumption I made while building this tool is that a window which has focus is also ordered on top of the apps window list. This assumption is needed to acquire the window id of the active window without resorting to accessibility api. This heuristic works very well when no external tools modify the windows because it is rare (I never saw it happen actually) that a window is focused but not raised.

In principle this could be included with a more robust function that acquires the window id of the focused window (but without accessibility permissions) here: https://github.com/FelixKratz/JankyBorders/blob/616b015ffa4af11f61c5caa4ba4a8999ba399188/src/helpers.h#L65-L102

crisidev commented 10 months ago

Thanks for the explanation.. This makes sense. I could try to hack around and see if I can find a way to ensure the window id is acquired properly, but it's the first time I work with MacOS internals, so it will probably take a while 😄

FelixKratz commented 10 months ago

Ill mark this as not planned for now, but feel free to experiment with the code and submit a PR if you find something that works.

crisidev commented 10 months ago

To reduce a little the scope, I have found that the issue happens only with windows from the same application.

Timothee commented 10 months ago

@crisidev I had the same issue. I had focus_follows_mouse set to autofocus for yabai, and it seems that changing that to autoraise fixes the issue here.

crisidev commented 10 months ago

Yeah, setting it to autoraise solves the issue, but I really do not like the autoraise behavior..

Timothee commented 10 months ago

Lol, somehow missed you suggested that exact thing in your original post 🤦‍♂️ 😄

FelixKratz commented 6 months ago

Lets track this issue here: #66.

FelixKratz commented 6 months ago

I have resolved the issue. See https://github.com/FelixKratz/JankyBorders/issues/66#issuecomment-1939713220