Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing layouts makes inefficient use of space #230

Closed
alextes opened this issue Sep 2, 2019 · 7 comments
Closed

Changing layouts makes inefficient use of space #230

alextes opened this issue Sep 2, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@alextes
Copy link

alextes commented Sep 2, 2019

On a desktop with a handful of windows, switching between the floating and bsp layout results in a relayout that ignores most of the space and looks to use about a fourth of the available space.

Interestingly, but barely helpful for debugging I'm guessing is that restarting yabai once means all but one window (the terminal, in which I trigger the restart) get equal space distribution, another restart results in a proper tree split layout like bsp uses.

@dominiklohmann
Copy link
Collaborator

dominiklohmann commented Sep 2, 2019

I'm not quite sure what the issue is.

yabai sorts windows into a tree structure for binary space partitioning. If you don't tell yabai where to insert the windows in the tree, it will have to default to some node, which usually is the focused window.

If I'm understanding correctly, your issue is that you don't want the tree structure to nest deeply.

You can change a window's parent by issuing a warp command.

# change the focused windows parent node to be the largest windows node
yabai -m window --warp largest

Additionally, you could think about having a strategy for unfloating many windows at once (only works with the windows individually set to float, not the whole space).

# grab every window id on the focused space that belongs to a floating window
# then for every id focus the largest window on the space before unfloating the window
# this strategy aims to create as little nesting as possible
yabai -m query --windows --space \
    | jq '.[] | select(.floating == 1).id' \
    | xargs -I{} sh -c 'yabai -m window --focus largest; yabai -m window {} --toggle float'

Similarly, you could always just issue a warp command for every tiled window after running your command to change to the bsp layout. This will change up your tree so that the tree depth is minimal as well.

yabai -m query --windows --space \
    | jq -r '.[] | select(.floating == 0).id' \
    | xargs -I{} yabai -m window {} --warp largest

@koekeishiya
Copy link
Owner

yabai defaults to the focused window. When a layout is set to bsp from float, it will continually insert at the focused region, which will keep getting smaller and smaller.

It is possible to implement a different strategy for this scenario, e.g. always selecting the minimum-depth leaf node for the insertion. This is a fairly low priority issue, imo.

@koekeishiya koekeishiya added the enhancement New feature or request label Sep 2, 2019
@alextes
Copy link
Author

alextes commented Sep 2, 2019

Thanks for the suggestions @dominiklohmann . This will help me write a custom command that lets me do what I want. Perhaps it's helpful if I take a step back and explain what I was trying to do. A bit better 😅 .

Sometimes my windows are a mess. Either I've been floating things or using a bunch of terminals together, in any case, I sometimes want to rebalance all things. Meaning, I'd like to get all windows to get into the managed bsp layout. As if I just created them all in a fresh desktop or space. Sometimes running balance is enough, but sometimes that doesn't result in the binary partitioned space I'm looking for, and sometimes I have floating windows mixed in. So, I thought I'd try to float all windows, by switching the layout to floating, and then switching it back to bsp. When I do that however, the following happens (keybinds are the defaults):

bsp-layout

In words, I open a bunch of terminals, I switch layout to float, switch layout bsp (all windows fly into the top left, tiny), balance the space, switch to float, switch to bsp end.

Rebalancing all windows in a space to bsp layout is really the feature I'm looking for here :) Sorry for going off on a trail in my first post 🙈 . I should know better than to commit the XY fallacy.

Thanks for everything so far!

@dominiklohmann
Copy link
Collaborator

In words, I open a bunch of terminals, I switch layout to float, switch layout bsp (all windows fly into the top left, tiny), balance the space, switch to float, switch to bsp end.

That's definitely a bug. I can reproduce this 100% with two windows on a space. This almost looks like yabai is trying to set every windows frame to x=0, y=0, w=0, h=0.

@koekeishiya koekeishiya added bug Something isn't working and removed enhancement New feature or request labels Sep 3, 2019
@koekeishiya
Copy link
Owner

So, I thought I'd try to float all windows, by switching the layout to floating, and then switching it back to bsp.

This doesn't actually work the way you want it to. If a window has been toggled floating, switching the space to float and back to bsp won't unfloat that window again. A floating space simply just does not attempt to manage windows, but it does not affect the actual floating property of any given window, if that makes sense.

@koekeishiya
Copy link
Owner

In words, I open a bunch of terminals, I switch layout to float, switch layout bsp (all windows fly into the top left, tiny), balance the space, switch to float, switch to bsp end.

That's definitely a bug. I can reproduce this 100% with two windows on a space. This almost looks like yabai is trying to set every windows frame to x=0, y=0, w=0, h=0.

This issue should now be fixed. I consider this report to be about this problem and marking it as solved.

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label Sep 3, 2019
@alextes
Copy link
Author

alextes commented Sep 3, 2019

Yea let's close it. A custom command to relayout windows like dominik proposed works for my case. The issue of the layout going bad when switching between float and bsp should be solved. If more people ask about having more control in balancing spaces I guess they'll create a new issue 😉 .

@alextes alextes closed this as completed Sep 3, 2019
@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Sep 3, 2019
dominiklohmann pushed a commit to dominiklohmann/yabai that referenced this issue Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants