[BUG]: Custom layout change requests are ignored #190

Closed
opened 2026-01-05 14:48:52 +01:00 by adam · 10 comments
Owner

Originally created by @thesobercoder on GitHub (Apr 7, 2023).

Describe the bug
Custom layout change requests are being ignored by Komorebi when there are only three windows on the screen. I use an utrawide 49in monitor and I typically have two layouts that I switch between. It all works fine when there are >3 windows on screen but when there are exactly =3 windows, the layout change requests are ignored, and nothing happens.

Layout 1:

- column: Secondary
  configuration: !Horizontal 2 # max number of rows
- column: Primary
- column: Tertiary
  configuration: Horizontal

Layout 2:

- column: Secondary
  configuration: !Horizontal 2 # max number of rows
- column: Primary
  configuration: !WidthPercentage 50 # percentage of screen
- column: Tertiary
  configuration: Horizontal

To Reproduce
Steps to reproduce the behavior:

  1. Copy the above-mentioned layouts to your layout directory and name them layout1.yaml and layout2.yaml respectively.
  2. Configure Komorebi to start with layout1.yaml by adding komorebic.exe load-custom-layout ~/layouts/layout1.yaml to your komorebi.ps1 configuration file.
  3. Start komorebi with komorebic start --await-configuration.
  4. Open three Windows. I tried this with Microsoft Teams, Microsoft Outlook, and Microsoft Edge.
  5. Now try to switch to the second layout by executing this command komorebic.exe load-custom-layout ~/layouts/layout2.yaml.

Expected behavior
The layout should have changed and assigned the primary section window 50% of the screen width, but the change requests are ignored. Once you add a fourth window, the layout change suddenly starts to work.

Operating System

OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.19044 N/A Build 19044

Additional context
Once you add a fourth window, the layout change suddenly starts to work.

Originally created by @thesobercoder on GitHub (Apr 7, 2023). **Describe the bug** Custom layout change requests are being ignored by Komorebi when there are only three windows on the screen. I use an utrawide 49in monitor and I typically have two layouts that I switch between. It all works fine when there are `>3` windows on screen but when there are exactly `=3` windows, the layout change requests are ignored, and nothing happens. Layout 1: ```yaml - column: Secondary configuration: !Horizontal 2 # max number of rows - column: Primary - column: Tertiary configuration: Horizontal ``` Layout 2: ```yaml - column: Secondary configuration: !Horizontal 2 # max number of rows - column: Primary configuration: !WidthPercentage 50 # percentage of screen - column: Tertiary configuration: Horizontal ``` **To Reproduce** Steps to reproduce the behavior: 1. Copy the above-mentioned layouts to your layout directory and name them `layout1.yaml` and `layout2.yaml` respectively. 2. Configure Komorebi to start with `layout1.yaml` by adding `komorebic.exe load-custom-layout ~/layouts/layout1.yaml` to your `komorebi.ps1` configuration file. 3. Start komorebi with `komorebic start --await-configuration`. 4. Open three Windows. I tried this with Microsoft Teams, Microsoft Outlook, and Microsoft Edge. 5. Now try to switch to the second layout by executing this command `komorebic.exe load-custom-layout ~/layouts/layout2.yaml`. **Expected behavior** The layout should have changed and assigned the primary section window 50% of the screen width, but the change requests are ignored. Once you add a fourth window, the layout change suddenly starts to work. **Operating System** ``` OS Name: Microsoft Windows 10 Enterprise OS Version: 10.0.19044 N/A Build 19044 ``` **Additional context** Once you add a fourth window, the layout change suddenly starts to work.
adam added the enhancement label 2026-01-05 14:48:52 +01:00
adam closed this issue 2026-01-05 14:48:52 +01:00
Author
Owner

@LGUG2Z commented on GitHub (Apr 9, 2023):

I think what you are experiencing is the intended behaviour: if the number of containers is not greater than the number of columns defined in the custom layout, the arrangement falls back to a simple column layout.

I'm open to PRs to improve the custom layout algorithm and remove this requirement for the number of containers needing to be greater than the number of columns, but I'm afraid that the state it is in right now is the limit of my own personal ability (hence the columns layout fallback).

I'll leave this issue open and label it as a feature request that needs help to be progressed.

@LGUG2Z commented on GitHub (Apr 9, 2023): I think what you are experiencing is the intended behaviour: [if the number of containers is not greater than the number of columns defined in the custom layout, the arrangement falls back to a simple column layout](https://github.com/LGUG2Z/komorebi/blob/master/komorebi-core/src/arrangement.rs#L235). I'm open to PRs to improve the custom layout algorithm and remove this requirement for the number of containers needing to be greater than the number of columns, but I'm afraid that the state it is in right now is the limit of my own personal ability (hence the `columns` layout fallback). I'll leave this issue open and label it as a feature request that needs help to be progressed.
Author
Owner

@thesobercoder commented on GitHub (Apr 9, 2023):

I think what you are experiencing is the intended behaviour: if the number of containers is not greater than the number of columns defined in the custom layout, the arrangement falls back to a simple column layout.

@LGUG2Z I think changing the condition to something like if the number of containers >= number of columns instead of only greater should be a non-breaking change, no? I'm a C# programmer by profession and not a Rust expert by any means, but here is what I think the change should be.

0de3fa62f0/komorebi-core/src/arrangement.rs (L234)

Instead of using <= if you replace it with <, should technically translate to the logic I mentioned above.

Please let me know what you think, and thanks for all your hard work on komorebi which makes our lives easier every day!

@thesobercoder commented on GitHub (Apr 9, 2023): > I think what you are experiencing is the intended behaviour: if the number of containers is not greater than the number of columns defined in the custom layout, the arrangement falls back to a simple column layout. @LGUG2Z I think changing the condition to something like `if the number of containers >= number of columns` instead of only `greater` should be a non-breaking change, no? I'm a C# programmer by profession and not a Rust expert by any means, but here is what I think the change should be. https://github.com/LGUG2Z/komorebi/blob/0de3fa62f0985a7c3a906d6143b3bf41bd3249d8/komorebi-core/src/arrangement.rs#L234 Instead of using `<=` if you replace it with `<`, should technically translate to the logic I mentioned above. Please let me know what you think, and thanks for all your hard work on komorebi which makes our lives easier every day!
Author
Owner

@olivoil commented on GitHub (Jun 15, 2023):

@LGUG2Z I'm interested in this as well, is there more to this than what @thesobercoder is suggesting?

It seems logical that if a layout defines 3 columns, and there are exactly 3 containers on screen, it should be able to apply this layout, and the fallback to a column layout should only be needed if there are 2 or less containers on screen, don't you think?

@olivoil commented on GitHub (Jun 15, 2023): @LGUG2Z I'm interested in this as well, is there more to this than what @thesobercoder is suggesting? It seems logical that if a layout defines 3 columns, and there are exactly 3 containers on screen, it should be able to apply this layout, and the fallback to a column layout should only be needed if there are 2 or less containers on screen, don't you think?
Author
Owner

@LGUG2Z commented on GitHub (Jun 15, 2023):

Unfortunately, it doesn't work as expected. Making that change results in this rendering with the following custom layout:

- column: Secondary
  configuration: !Horizontal 2
- column: Primary
  configuration: !WidthPercentage 45
- column: Tertiary
  configuration: Horizontal

image

@LGUG2Z commented on GitHub (Jun 15, 2023): Unfortunately, it doesn't work as expected. Making that change results in this rendering with the following custom layout: ```yaml - column: Secondary configuration: !Horizontal 2 - column: Primary configuration: !WidthPercentage 45 - column: Tertiary configuration: Horizontal ``` ![image](https://github.com/LGUG2Z/komorebi/assets/13164844/c9fc685f-fd40-4758-900e-e76949c044b7)
Author
Owner

@LGUG2Z commented on GitHub (Jun 15, 2023):

Layouts are unfortunately not something I'm best suited to working on; I have a poor intuition for geometry and layout and whenever I'm trying to work on code like this for more than 10 minutes I start getting headaches because it's so mentally taxing :/

@LGUG2Z commented on GitHub (Jun 15, 2023): Layouts are unfortunately not something I'm best suited to working on; I have a poor intuition for geometry and layout and whenever I'm trying to work on code like this for more than 10 minutes I start getting headaches because it's so mentally taxing :/
Author
Owner

@thesobercoder commented on GitHub (Jun 15, 2023):

@LGUG2Z I switched to the default layouts, and it has been working pretty well for me. Geometry hurts my head too, so I can totally relate. 😄

@thesobercoder commented on GitHub (Jun 15, 2023): @LGUG2Z I switched to the default layouts, and it has been working pretty well for me. Geometry hurts my head too, so I can totally relate. 😄
Author
Owner

@olivoil commented on GitHub (Jun 17, 2023):

@LGUG2Z It looks like your screenshot is what I would expect with configuration: !Horizontal 2 in the Secondary column, it does not have enough containers to start filling the tertiary column, and the primary column is at 45%, leaving the secondary one to fill out the rest of the screen. This does seem to be working, doesn't it?

Would the change work with this config?

In komorebi.layout.json:

- column: Secondary
  configuration: !Horizontal 1
- column: Primary
  configuration: !WidthPercentage 60
- column: Tertiary
  configuration: Horizontal

And applying as soon as there are 3 windows on screen:

komorebic workspace-custom-layout-rule 0 0 3 ~/komorebi.layout.json

At the moment, this does not work as it applies komorebi.layout.json only until there are 4 windows. When there are only 3, it fallbacks to the column layout, resulting in 3 columns of equal width

@olivoil commented on GitHub (Jun 17, 2023): @LGUG2Z It looks like your screenshot is what I would expect with `configuration: !Horizontal 2` in the Secondary column, it does not have enough containers to start filling the tertiary column, and the primary column is at 45%, leaving the secondary one to fill out the rest of the screen. This does seem to be working, doesn't it? Would the change work with this config? In komorebi.layout.json: ``` - column: Secondary configuration: !Horizontal 1 - column: Primary configuration: !WidthPercentage 60 - column: Tertiary configuration: Horizontal ``` And applying as soon as there are 3 windows on screen: ``` komorebic workspace-custom-layout-rule 0 0 3 ~/komorebi.layout.json ``` At the moment, this does not work as it applies `komorebi.layout.json` only until there are 4 windows. When there are only 3, it fallbacks to the column layout, resulting in 3 columns of equal width
Author
Owner

@LGUG2Z commented on GitHub (Jul 1, 2023):

@olivoil I think you're right and I'm overthinking this and/or my own mental model is a little skewed by the specific custom layouts that I use. I'm going to add this change to the master branch and it will be in the next release, so that custom layout changes are triggered when there are at least as many windows open as columns in the custom layout.

Thanks to all of you for your patience with this!

@LGUG2Z commented on GitHub (Jul 1, 2023): @olivoil I think you're right and I'm overthinking this and/or my own mental model is a little skewed by the specific custom layouts that I use. I'm going to add [this change](https://github.com/LGUG2Z/komorebi/issues/390#issuecomment-1501072693) to the master branch and it will be in the next release, so that custom layout changes are triggered when there are at least as many windows open as columns in the custom layout. Thanks to all of you for your patience with this!
Author
Owner

@thesobercoder commented on GitHub (Jul 3, 2023):

@LGUG2Z Thanks to you for all the hard work on this!

@thesobercoder commented on GitHub (Jul 3, 2023): @LGUG2Z Thanks to you for all the hard work on this!
Author
Owner

@olivoil commented on GitHub (Jul 6, 2023):

Amazing, thank you @LGUG2Z!

@olivoil commented on GitHub (Jul 6, 2023): Amazing, thank you @LGUG2Z!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#190