glzr-io / glazewm

GlazeWM is a tiling window manager for Windows inspired by i3wm.
GNU General Public License v3.0
5.49k stars 158 forks source link

[Feature Request] Layout support #678

Open lars-berger opened 1 month ago

lars-berger commented 1 month ago

Describe the problem/motivation

Windows are currently arranged via move commands and by changing the tiling direction. It would be nice to have preset layouts that windows can be automatically arranged into.

Describe the solution you'd like

Depends on:

Proposed solution

A workspace can optionally have a layout active, which will do 3 things:

1) When activated (e.g. via a keybinding command) it will automatically arrange your windows in the current workspace to the specified layout (e.g. a grid layout). 2) When a new window is opened within that workspace or moved to that workspace, it will be arranged according to the active layout. 3) Windows can still be moved as per usual WM behavior when the layout is active, but if a window is moved in a way that doesn't correspond to the active layout (e.g. if a grid layout is active and the windows aren't in a grid anymore), then the layout will deactivate and windows won't be added in a grid anymore.

A crucial part to making this idea work is to be able to move windows without breaking the layout. But if there was a way to swap windows in a given direction (#677), the layout could be maintained.

So what would make a lot of sense IMO is to add a command for swapping windows, and to also have a binding mode that automatically triggers (#675) when a layout is active. When this binding mode is active, move keybindings are changed to swap keybindings.

Potential config:

binding_modes:
  name: 'swap'
  match_enabled:
    # Automatically trigger binding mode when the focused workspace has the given layout
    - focused_workspace_layout: { exact: 'dwindle' }
  keybindings:
      # Replace alt+shift+hjkl move commands with swaps
      - command: 'swap --direction left'
        bindings: ['alt+shift+h', 'alt+shift+left']
      - command: 'swap --direction right'
        bindings: ['alt+shift+l', 'alt+shift+right']
      - command: 'swap --direction up'
        bindings: ['alt+shift+k', 'alt+shift+up']
      - command: 'swap --direction down'
        bindings: ['alt+shift+j', 'alt+shift+down']

keybindings:
  # Activate dwindle layout
  - commands: ['layout --name dwindle']
    bindings: [..]

Potential layouts:

Alternatives considered

No response

DreamMaoMao commented 2 days ago

Does windows now have an existing interface to force tpreset he position and size of the window open? Now some Windows on the screen will fill the screen when starting up and then return to the tiled position and size, which will cause visual flickering.