swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.08k stars 1.08k forks source link

Add `split tabbed` and `split stacking` command #8202

Open lukasfink1 opened 3 weeks ago

lukasfink1 commented 3 weeks ago

Description: Suppose there are two windows horizontally splitting a workspace, with the left being focused:

    #63: workspace "3"
      #65: con "swaymsg -t get_tree" (xdg_shell, pid: 57343, app_id: "Alacritty")
      #76: con "lukas@lukas-pc:~" (xdg_shell, pid: 58031, app_id: "Alacritty")

Now the command splitv can be used. This will make new windows appearing split the space of the left window vertically:

    #63: workspace "3"
      #78: con "(null)"
        #65: con "swaymsg -t get_tree" (xdg_shell, pid: 57343, app_id: "Alacritty")
        #80: con "lukas@lukas-pc:~" (xdg_shell, pid: 58274, app_id: "Alacritty")
      #76: con "lukas@lukas-pc:~" (xdg_shell, pid: 58031, app_id: "Alacritty")

According to the man page there doesn’t seem to be an analogous command for tabbed layout, where the next opened window will be tabbed together with the focused. The only command I could find was layout tabbed, but this switches the layout of the whole workspace to tabbed, which means that the right window would have to be separated again after creating the windows that should be tabbed together with the left window. The same holds true for the stacking layout, too.

It would be nice to have analogous commands to splitv, splith etc. for the tabbed and stacking layout.

Edit: I would suggest adding split tabbed and split stacking and make it interoperate with the other split subcommands.

Arnavion commented 2 weeks ago

You can do it with two commands splitv; layout tabbed (H[A B] -> H[V[A] B] -> H[T[A] B]) to get the same result. But yes, there's no single command to do it.

lukasfink1 commented 1 week ago

This certainly works and it is what I’m currently using. The problem with this approach is, that it can’t be combined with splitv and splith that well:

If I first issue splith and then change my mind and issue a splitv command, the tree changes from H[H[A] B] to H[V[A] B].

If I first issue splitv; layout tabbed but then change my mind and use splitv again, the tree will be H[T[V[A]] B].

The solution would be to use layout vertical instead of the second splitv, but because there is no visual indicator for a tabbed container with a single child, it sometimes happens that I create such a tabbed container, then don’t use it and later on forget about its existence and create such a recursive arrangement.