Yabai: Directions appear relative to space rather than active window

Created on 6 Nov 2019  路  13Comments  路  Source: koekeishiya/yabai

To explain this further I have the following binds:

yabai -m window --focus north
yabai -m window --focus east
yabai -m window --focus south
yabai -m window --focus west

and a set of four windows on a single space like this:
Screenshot 2019-11-06 at 16 37 33

Now if I select the bottom right window so it is active and press the keybind for focus west, it will not focus the window in the bottom left, it will focus the window in the top left, which is potentially "west" for the space but not "west" relative to the window I'm moving from, is this a regression or am I doing it wrong? (coming from chunkwm)

bug

Most helpful comment

Calculation using the center of the window does not work correctly, because of size constraints (tested this primarily with a combination Terminal, Finder and Kitty). I have however changed to using ordinary euclidean distance and it does seem to resolve the issue in an acceptable way.

All 13 comments

also terminal.app has always tiled a bit weird (gaps at bottom and top), not sure if this is related

This is happening because of the sizing issue with Terminal.app, yeah. The reason chunkwm didn't exhibit this behaviour is that it used the node region rather than the actual size of the window. I honestly don't remember the reason I made this change in yabai, but I did this specific change deliberately. I'll have to revisit this when I have time and see if I can recall why I made that decision.

also terminal.app has always tiled a bit weird (gaps at bottom and top), not sure if this is related

That's because it doesn't add padding around its content view, whose size always is a multiple of the cell size. iTerm2 has an option to add padding for smooth resizing.

I honestly don't remember the reason I made this change in yabai, but I did this specific change deliberately. I'll have to revisit this when I have time and see if I can recall why I made that decision.

I assume this is because yabai supports directional focus for floating windows.

This should be quite easy to fix by taking the window center instead of the top left coordinate for this calculation.

This should be quite easy to fix by taking the window center instead of the top left coordinate for this calculation.

@koekeishiya Is this a viable solution?

I did do that type of a calculation initially, but it does not exhibit the same behaviour. I preferred the way it currently works - might revisit this logic at some point to see if this can be resolved..

@ramblingenzyme posted in #225:

[...] I found that when you've got a fullscreen window with other windows beneath, it keeps toggling between the fullscreen window and another window and never goes to another monitor. Not sure how to express that to create a new issue though.

This directly relates to my post above:

This should be quite easy to fix by taking the window center instead of the top left coordinate for this calculation.

Calculation using the center of the window does not work correctly, because of size constraints (tested this primarily with a combination Terminal, Finder and Kitty). I have however changed to using ordinary euclidean distance and it does seem to resolve the issue in an acceptable way.

Thanks so much for this improvement and for yabai! Finally swapped from chunkwm yesterday and I did not think yabai would be as big an improvement as it is. Didn't realise how much of a performance impact chunkwm was having, and it was ruining plenty of my work days.

@ramblingenzyme chunkwm was fairly slow to be honest. I wouldn't go as far as to say that yabai is fast by modern standards, but it is definitely less slow than most alternatives.

Hopefully I'll find a decent profiler at some point that actually works. I'm sure there is a lot that could be sped up still.

Hopefully I'll find a decent profiler at some point that actually works.

The time profiler in Instruments (bundled with Xcode) works quite well from my experience. It's by far the best on macOS.

I'll try to give instruments another shot. Fairly certain I had issues when running yabai in it, that would cause AX features to not work properly and slow down the application, but I don't remember exactly which functionality I tried to use.

What I really want is to instrument my code with performance counters that nest through function calls, showing the amount of cycles spent in each function through the graph, and the total accumulated cycles for the whole thing (for each function including their callee's).

This would let me know how much the percentage of work of a certain path is taken up by which sub-functions, and since a lot of functions are called from multiple paths (event types in the case of yabai), I could get better information as to which functions are worth optimizing to increase performance as a whole.

image

Works really well for me. This can then be filtered and inverted and so much more.

The key to getting it to work is to go to the AX permission settings and to add Instruments.app (must press cmd + shift + G to enter the path: /Applications/Xcode.app/Contents/Applications/).

562 for reference.

Was this page helpful?
0 / 5 - 0 ratings