This PR reworks the way the postload and the reload functions apply the monitor configs to the monitors. Previously it was looping through the monitor configs and applying them to the monitor with the index corresponding to the config's index.
However this isn't correct, since the user might set the preferred indices for 3 monitors (like monitor A, B and C), with the preferred index set to 0 for A, 1 for B and 2 for C, but if only monitors A and C are connected then komorebi would apply config 0 to A and config 1 to C, which is wrong it should be 2 for C.
This PR changes the way the configs are applied on those functions.
Now it loops through the existing monitors (already in order), then checks if the monitor has a preferred config index, if it does it uses that one, if it doesn't then it uses the first monitor config that isn't a preferred index for some other monitor and that hasn't been used yet.
For the situation above it means that it would still apply config 2 to monitor C. And in case there aren't any display_index_preferences set it will still apply the configs in order.
It also changes the way the layout is stored from the current monitor, by making sure to set it to None if the workspace is not tiling. Previously any floating workspace would be restored from cache with a tiling BSP layout.
However this entire code is based on the premise that the device_id is always the same for the same devices. However there have been comments on discord stating that this isn't true, however I've not been able to confirm this and the users have not given any proof of this happening (they might simply be confusing it since it's a weird string similar between monitors...)
I think the changes from this PR should fix most issues that people have been having with multiple monitors (specially with 3 or more monitors). But it's probably better to not merge this until we can get some users to test it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/LGUG2Z/komorebi/pull/1241
**Author:** [@alex-ds13](https://github.com/alex-ds13)
**Created:** 1/23/2025
**Status:** ❌ Closed
**Base:** `master` ← **Head:** `fix/monitor-preferences`
---
### 📝 Commits (10+)
- [`281b66c`](https://github.com/LGUG2Z/komorebi/commit/281b66cfeb302615e7c230d852b784e9247ec150) fix(wm): properly store tile state when caching ws
- [`163b9a1`](https://github.com/LGUG2Z/komorebi/commit/163b9a1bffdd2a5cf46fdca34e9baa3e28d6b6be) fix(wm): store config on workspace
- [`b1ec872`](https://github.com/LGUG2Z/komorebi/commit/b1ec872ce70c14f50406e14512a6fd8a498ce107) fix(wm): correctly use the display_index_preferences
- [`3f70d38`](https://github.com/LGUG2Z/komorebi/commit/3f70d384d5075d952f3233147642cdb5fac7174c) fix(wm): cache monitor configs for unloaded monitors
- [`ecb7f80`](https://github.com/LGUG2Z/komorebi/commit/ecb7f8099ec730437d25e045887cafe68b60e30c) fix(wm): don't store empty layout_rules on monitor cache
- [`71c382c`](https://github.com/LGUG2Z/komorebi/commit/71c382c3ac8a32cd65a58a497c176a1a131ef449) fix(wm): restore orphaned containers
- [`2f04074`](https://github.com/LGUG2Z/komorebi/commit/2f04074691e056df07a5e18aeec212759410c5c8) fix(wm): skip workspace_config on workspace serde
- [`b89228a`](https://github.com/LGUG2Z/komorebi/commit/b89228a806979acda77e6b5a376c34516b945abc) fix(wm): use serial numbers along device ids
- [`cc0bbfd`](https://github.com/LGUG2Z/komorebi/commit/cc0bbfdfa15feac6a46aa9f657268da8ff053ae5) fix(wm): handle serial id on `load_monitor_information`
- [`f91a34c`](https://github.com/LGUG2Z/komorebi/commit/f91a34c7b82ed42b45d967f2ae7c440be7a613c5) fix(wm): remove workspace_rules from disconnected monitors
### 📊 Changes
**8 files changed** (+377 additions, -76 deletions)
<details>
<summary>View changed files</summary>
📝 `komorebi-bar/src/bar.rs` (+49 -1)
📝 `komorebi-bar/src/komorebi.rs` (+10 -0)
📝 `komorebi-bar/src/main.rs` (+5 -1)
📝 `komorebi/src/monitor_reconciliator/mod.rs` (+58 -20)
📝 `komorebi/src/static_config.rs` (+203 -51)
📝 `komorebi/src/window_manager.rs` (+5 -1)
📝 `komorebi/src/windows_api.rs` (+41 -2)
📝 `komorebi/src/workspace.rs` (+6 -0)
</details>
### 📄 Description
This PR reworks the way the `postload` and the `reload` functions apply the monitor configs to the monitors. Previously it was looping through the monitor configs and applying them to the monitor with the index corresponding to the config's index.
However this isn't correct, since the user might set the preferred indices for 3 monitors (like monitor A, B and C), with the preferred index set to 0 for A, 1 for B and 2 for C, but if only monitors A and C are connected then komorebi would apply config 0 to A and config 1 to C, which is wrong it should be 2 for C.
This PR changes the way the configs are applied on those functions.
Now it loops through the existing monitors (already in order), then checks if the monitor has a preferred config index, if it does it uses that one, if it doesn't then it uses the first monitor config that isn't a preferred index for some other monitor and that hasn't been used yet.
For the situation above it means that it would still apply config 2 to monitor C. And in case there aren't any display_index_preferences set it will still apply the configs in order.
It also changes the way the layout is stored from the current monitor, by making sure to set it to `None` if the workspace is not tiling. Previously any floating workspace would be restored from cache with a tiling BSP layout.
Related to [this discussion](https://discord.com/channels/898554690126630914/1329508394205184104/1329518859383865456) on Discord
However this entire code is based on the premise that the `device_id` is always the same for the same devices. However there have been [comments](https://discord.com/channels/898554690126630914/898554690608967786/1330587647462084609) on discord stating that this isn't true, however I've not been able to confirm this and the users have not given any proof of this happening (they might simply be confusing it since it's a weird string similar between monitors...)
I think the changes from this PR should fix most issues that people have been having with multiple monitors (specially with 3 or more monitors). But it's probably better to not merge this until we can get some users to test it.
<!--
Please follow the Conventional Commits specification.
If you need to update your PR with changes from `master`, please run `git rebase master`.
By opening this PR, you confirm that you have read and understood this project's `CONTRIBUTING.md`.
-->
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/LGUG2Z/komorebi/pull/1241
Author: @alex-ds13
Created: 1/23/2025
Status: ❌ Closed
Base:
master← Head:fix/monitor-preferences📝 Commits (10+)
281b66cfix(wm): properly store tile state when caching ws163b9a1fix(wm): store config on workspaceb1ec872fix(wm): correctly use the display_index_preferences3f70d38fix(wm): cache monitor configs for unloaded monitorsecb7f80fix(wm): don't store empty layout_rules on monitor cache71c382cfix(wm): restore orphaned containers2f04074fix(wm): skip workspace_config on workspace serdeb89228afix(wm): use serial numbers along device idscc0bbfdfix(wm): handle serial id onload_monitor_informationf91a34cfix(wm): remove workspace_rules from disconnected monitors📊 Changes
8 files changed (+377 additions, -76 deletions)
View changed files
📝
komorebi-bar/src/bar.rs(+49 -1)📝
komorebi-bar/src/komorebi.rs(+10 -0)📝
komorebi-bar/src/main.rs(+5 -1)📝
komorebi/src/monitor_reconciliator/mod.rs(+58 -20)📝
komorebi/src/static_config.rs(+203 -51)📝
komorebi/src/window_manager.rs(+5 -1)📝
komorebi/src/windows_api.rs(+41 -2)📝
komorebi/src/workspace.rs(+6 -0)📄 Description
This PR reworks the way the
postloadand thereloadfunctions apply the monitor configs to the monitors. Previously it was looping through the monitor configs and applying them to the monitor with the index corresponding to the config's index.However this isn't correct, since the user might set the preferred indices for 3 monitors (like monitor A, B and C), with the preferred index set to 0 for A, 1 for B and 2 for C, but if only monitors A and C are connected then komorebi would apply config 0 to A and config 1 to C, which is wrong it should be 2 for C.
This PR changes the way the configs are applied on those functions.
Now it loops through the existing monitors (already in order), then checks if the monitor has a preferred config index, if it does it uses that one, if it doesn't then it uses the first monitor config that isn't a preferred index for some other monitor and that hasn't been used yet.
For the situation above it means that it would still apply config 2 to monitor C. And in case there aren't any display_index_preferences set it will still apply the configs in order.
It also changes the way the layout is stored from the current monitor, by making sure to set it to
Noneif the workspace is not tiling. Previously any floating workspace would be restored from cache with a tiling BSP layout.Related to this discussion on Discord
However this entire code is based on the premise that the
device_idis always the same for the same devices. However there have been comments on discord stating that this isn't true, however I've not been able to confirm this and the users have not given any proof of this happening (they might simply be confusing it since it's a weird string similar between monitors...)I think the changes from this PR should fix most issues that people have been having with multiple monitors (specially with 3 or more monitors). But it's probably better to not merge this until we can get some users to test it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.