TimUntersberger / nog

A tiling window manager for Windows
MIT License
697 stars 20 forks source link

Changing split mode of existing tiles? #264

Closed garymm closed 3 years ago

garymm commented 3 years ago

IIRC, i3 let me change the split mode of existing tiles / windows.

E.g. go from

A
B

to

AB

It's been a while since I used i3. Most recently I used chunkwm, which definitely allowed this.

Does nog support this already? If so, how? If not, consider this a feature request.

Thanks!

ramirezmike commented 3 years ago

I added a "swap_columns_and_rows" feature here a while back that might be what you're looking for... it just takes all rows and turns them into columns and turns all columns into rows.

It's possible that it got lost in a refactor though... I don't see it in the documentation and while the code still exists I don't think it's hooked up to the latest keybinding code. I can take a look at it tomorrow and get a fix for it merged for you.

ramirezmike commented 3 years ago

I made #265 to fix this. Let me know if this build works for you and I'll merge it

The binding should be like this

bind("Alt+R", () => nog.workspace.swap_columns_and_rows())

garymm commented 3 years ago

Thanks for the fast response! Tried it out for a few minutes and it seems to work.

In summary I think this will do nicely for now.

More commentary: I have a vague memory that this is somehow different from what chunkwm and i3 did. I think they only swapped the orientation of the current window with regards to its siblings but not its parents. I can imagine particular rearrangements that would take several steps to accomplish using this that might be trivial with a "swap orientation of this window and its siblings" feature. However until I use it for at least a few days I don't have a strong reason to prefer one over the other, so I will try this out and hopefully be content.

ramirezmike commented 3 years ago

More commentary: I have a vague memory that this is somehow different from what chunkwm and i3 did. I think they only swapped the orientation of the current window with regards to its siblings but not its parents. I can imagine particular rearrangements that would take several steps to accomplish using this that might be trivial with a "swap orientation of this window and its siblings" feature. However until I use it for at least a few days I don't have a strong reason to prefer one over the other, so I will try this out and hopefully be content.

Not sure how you still feel about this but just for more background on this. The way the tiling is tracked in nog uses a tree that follows a couple rules, one of which is preventing a child node from being the same type as its direct parent node. That is, it prevents situations like a column node that has a child that is also columns.

AAABBBCCDD
AAABBBCCDD
AAABBBCCDD

Something like the above would be represented like this in the graph.

             C1
          / | | \
         A  B C  D

And something like this with columns and rows...

AAABBBCCCC
AAABBBDDDD

Is represented like this

 C1
/ | \
A B R1
    / \
    C D

If you were to go to the C/D tiles and try to convert them into columns, it would create an "invalid" graph like this (R1 turns to C2)

 C1
/ | \
A B C2
    / \
    C D

In a simple graph like this, it's not too bad to deal with, but allowing this capability starts to introduce edge cases on more nested graphs and then there's a question of whether things should be tracked so that you could go back to the C/D and switch only those two back to rows.

The alternative is to focus C and move it out into a column using the move_out keybinding which will convert C and D into columns under the parent C1 node. And if you want to revert it back into rows you would select either C or D and use the move_in keybinding to do that.

I personally use a mode config that uses these keybindings

    bind("Alt+H", () => nog.workspace.move_in("Left"))
    bind("Alt+J", () => nog.workspace.move_in("Down"))
    bind("Alt+K", () => nog.workspace.move_in("Up"))
    bind("Alt+L", () => nog.workspace.move_in("Right"))

    bind("Alt+Shift+H", () => nog.workspace.move_out("Left"))
    bind("Alt+Shift+J", () => nog.workspace.move_out("Down"))
    bind("Alt+Shift+K", () => nog.workspace.move_out("Up"))
    bind("Alt+Shift+L", () => nog.workspace.move_out("Right"))
ramirezmike commented 3 years ago

I have an updated version of this that is post-lua config changes here #265

I'll close this issue once that has been merged.