Use the preferred id set by the user as the key when caching monitors. This way if a user is having issues with the device_id on their system they can use the serial_number_id on display_index_preferences. If instead a user is having issues with the serial_number_id they can make sure to use the device_id on display_index_preferences. Komorebi will use the preferred one as a key when caching the monitors.
@LGUG2Z This PR also includes a change of the DISPLAY_INDEX_PREFERENCES from a Mutex to RwLock. I believe the RwLock is better since it allows multiple readers at the same time, while the mutex blocks on all calls even if you just want to read or compare some value. For display index preferences (same thing applies to other existing mutexes) most times we access it is a read-only access. We only ever change it when applying a config or when a command is used to change it. Every other use is a read-only use so it doesn't make sense to block on those situations.
If you don't think this is a necessary change I can remove it from this PR though! Just say the word!
🔄 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/1343
**Author:** [@alex-ds13](https://github.com/alex-ds13)
**Created:** 3/13/2025
**Status:** ✅ Merged
**Merged:** 3/13/2025
**Merged by:** [@LGUG2Z](https://github.com/LGUG2Z)
**Base:** `master` ← **Head:** `fix/use-preferred-id-on-cache`
---
### 📝 Commits (1)
- [`c68f79b`](https://github.com/LGUG2Z/komorebi/commit/c68f79b5c3219946466cc6c431c02d2474c10659) fix(wm): use preferred id when caching monitors
### 📊 Changes
**6 files changed** (+38 additions, -17 deletions)
<details>
<summary>View changed files</summary>
📝 `komorebi/src/lib.rs` (+3 -2)
📝 `komorebi/src/monitor_reconciliator/mod.rs` (+23 -3)
📝 `komorebi/src/process_command.rs` (+1 -1)
📝 `komorebi/src/static_config.rs` (+8 -8)
📝 `komorebi/src/window_manager.rs` (+1 -1)
📝 `komorebi/src/windows_api.rs` (+2 -2)
</details>
### 📄 Description
Use the preferred id set by the user as the key when caching monitors. This way if a user is having issues with the `device_id` on their system they can use the `serial_number_id` on `display_index_preferences`. If instead a user is having issues with the `serial_number_id` they can make sure to use the `device_id` on `display_index_preferences`. Komorebi will use the preferred one as a key when caching the monitors.
@LGUG2Z This PR also includes a change of the `DISPLAY_INDEX_PREFERENCES` from a `Mutex` to `RwLock`. I believe the `RwLock` is better since it allows multiple readers at the same time, while the mutex blocks on all calls even if you just want to read or compare some value. For display index preferences (same thing applies to other existing mutexes) most times we access it is a read-only access. We only ever change it when applying a config or when a command is used to change it. Every other use is a read-only use so it doesn't make sense to block on those situations.
If you don't think this is a necessary change I can remove it from this PR though! Just say the word!
<!--
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/1343
Author: @alex-ds13
Created: 3/13/2025
Status: ✅ Merged
Merged: 3/13/2025
Merged by: @LGUG2Z
Base:
master← Head:fix/use-preferred-id-on-cache📝 Commits (1)
c68f79bfix(wm): use preferred id when caching monitors📊 Changes
6 files changed (+38 additions, -17 deletions)
View changed files
📝
komorebi/src/lib.rs(+3 -2)📝
komorebi/src/monitor_reconciliator/mod.rs(+23 -3)📝
komorebi/src/process_command.rs(+1 -1)📝
komorebi/src/static_config.rs(+8 -8)📝
komorebi/src/window_manager.rs(+1 -1)📝
komorebi/src/windows_api.rs(+2 -2)📄 Description
Use the preferred id set by the user as the key when caching monitors. This way if a user is having issues with the
device_idon their system they can use theserial_number_idondisplay_index_preferences. If instead a user is having issues with theserial_number_idthey can make sure to use thedevice_idondisplay_index_preferences. Komorebi will use the preferred one as a key when caching the monitors.@LGUG2Z This PR also includes a change of the
DISPLAY_INDEX_PREFERENCESfrom aMutextoRwLock. I believe theRwLockis better since it allows multiple readers at the same time, while the mutex blocks on all calls even if you just want to read or compare some value. For display index preferences (same thing applies to other existing mutexes) most times we access it is a read-only access. We only ever change it when applying a config or when a command is used to change it. Every other use is a read-only use so it doesn't make sense to block on those situations.If you don't think this is a necessary change I can remove it from this PR though! Just say the word!
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.