LGUG2Z / komorebi

A tiling window manager for Windows 🍉
https://lgug2z.github.io/komorebi/
Other
9.59k stars 198 forks source link

[BUG]: Custom layout column ordering #789

Closed tgrosinger closed 6 months ago

tgrosinger commented 6 months ago

Describe the bug If you place a primary column as the last column in a custom layout, komorebi fails to load.

For example, this custom layout will load:

[
  {
    "column": "Secondary",
    "configuration": {
      "Horizontal": 3
    }
  },
  {
    "column": "Primary"
  },
  {
    "column": "Tertiary",
    "configuration": "Horizontal"
  }
]

But if we change the ordering of the last two columns:

[
  {
    "column": "Secondary",
    "configuration": {
      "Horizontal": 3
    }
  },
  {
    "column": "Tertiary",
    "configuration": "Horizontal"
  },
  {
    "column": "Primary"

  }
]

It will no longer load.

PS C:\Users\tgrosinger> komorebi
2024-04-28T16:04:10.625234Z  INFO init: komorebi::window_manager: initialising
Error:
   0: the layout file provided was invalid

Location:
   D:\a\komorebi\komorebi\komorebi-core\src\custom_layout.rs:48

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: BaseThreadInitThunk<unknown>
      at <unknown source file>:<unknown line>
   2: RtlUserThreadStart<unknown>
      at <unknown source file>:<unknown line>

Operating System

OS Name:                   Microsoft Windows 11 Pro
OS Version:                10.0.22631 Build 22631

komorebic check Output

PS C:\Users\tgrosinger> komorebi --version
komorebi 0.1.24

PS C:\Users\tgrosinger> komorebic check
No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\tgrosinger

Looking for configuration files in C:\Users\tgrosinger

Found komorebi.json; this file can be passed to the start command with the --config flag

Found C:\Users\tgrosinger\.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag
LGUG2Z commented 6 months ago

This is not a bug; this is part of the current design spec of custom layouts. Only a Tertiary column can occupy the rightmost position.

This feature doesn't really have an owner right now and honestly I regret implementing it. 😅

If anyone wants to work on a "Custom Layouts v2" with more flexibility in the design spec I am happy to mentor.

Some good places to start looking for anyone who is interested:

https://github.com/LGUG2Z/komorebi/blob/0b04e3ef93beace9ebe4e968c594b2c1dec72de8/komorebi-core/src/arrangement.rs#L198

https://github.com/LGUG2Z/komorebi/blob/0b04e3ef93beace9ebe4e968c594b2c1dec72de8/komorebi-core/src/custom_layout.rs#L108

tgrosinger commented 6 months ago

Here's the layout that I am actually trying to achieve. Is there another way I can accomplish this that would be valid?

[
  {
    "column": "Tertiary",
    "configuration": "Horizontal"
  },
  {
    "column": "Primary",
    "configuration": {
        "WidthPercentage": 75
    }
  }
]

I tried putting the primary column first and then swapping, but it seems that flip-layout horizontal does not work on custom layouts.

I also tried using the VerticalStack layout, but it enforces that the primary is 50% width and you can't resize it.

So many options that are so close, but haven't quite found one that gets me all the way there.

LGUG2Z commented 6 months ago

You can get close with VerticalStack flipped on the horizontal axis, but resize has not been implemented for this layout:

https://github.com/LGUG2Z/komorebi/blob/0b04e3ef93beace9ebe4e968c594b2c1dec72de8/komorebi/src/workspace.rs#L894

This is also a good first issue to work on and you should be able to take some good inspiration from here:

https://github.com/LGUG2Z/komorebi/blob/0b04e3ef93beace9ebe4e968c594b2c1dec72de8/komorebi/src/workspace.rs#L930

LGUG2Z commented 6 months ago

@tgrosinger I added a RightMainVerticalStack layout with resizing enabled here: https://github.com/LGUG2Z/komorebi/commit/383533e2d9a0cf1e893516311acd2cf4ce2f2dcc

+-----+-------+
|     |       |
+-----+       |
|     |       |
+-----+-------+
 stack   main
tgrosinger commented 6 months ago

Exciting, thank you! I'll give it a try soon.

I'd love to help with adding some features to this project, but I don't have the bandwidth to start learning Rust at the moment. Maybe some day though :)

tgrosinger commented 6 months ago

This is perfect, thanks again.

llinfeng commented 4 months ago

I was also looking for a RightMain-type of layout, and arrived at the same bug with the custom_layout config, where keeping "Primary" to the far-right is treated as an invalid layout.

For now, RightMainVerticalStack works great, as I can actually drag the main column and resize it as long as I don't move any other window around. When a window is moved to another monitor, the 50-50 split layout kicks back again.

Question: how to let the adjusted width for RightMainVerticalStack persist? Does the workspace setting (where I specify the "layout" key) take some additional argument to indicate how wide the Primary column should be? I tried to play with the resize_dimensions key, but didn't find a good way to load it properly.