[BUG]: broken `komorebic state`
Describe the bug
After the computer is woken from sleep, the komorebic state changes (using a laptop with 2 monitors).
To Reproduce
At the time of writing, I am running version 871a538 of Komorebi
Steps to reproduce the behavior:
- Run 'komorebic state'
- Let the computer go to sleep
- Wake the computer from sleep
- Run 'komorebic state'
- See bug
Expected behavior When running 'komorebic state' after waking the computer from sleep, it gives the same result even with multiple monitors.
Proposed short term solution I proposed the enhancement #803, that could lessen the issue
Screenshots, Videos and Logs I am using Zebar to visualize the issue. The buttons represent the workspaces on the 2 monitors (MONITOR5 and MONITOR6).
The state goes from having 2 monitors (MONITOR6, MONITOR5) to listing 3 monitors (MONITOR5, MONITOR6, MONITOR5), ending up in a broken state.
Initial state (before sleep)
Output of 'komorebic state'
{
"monitors": {
"elements": [
{
"id": 17763244,
"name": "DISPLAY6",
"device": null,
"device_id": null,
"size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "W1",
"containers": {
"elements": [
{
"id": "_OKrk2--SMg8xXXbyfprp"
},
{
"id": "YebDXVJN3GvrW-Ow0TwHr"
},
{
"id": "X2QdD5gkXFn4DZ_tHuf32"
},
{
"id": "b4lt4hb3wrw7HW9cakKQl"
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 4807,
"top": 55,
"right": 1905,
"bottom": 2023
},
{
"left": 3850,
"top": 55,
"right": 947,
"bottom": 2023
},
{
"left": 6722,
"top": 55,
"right": 947,
"bottom": 1006
},
{
"left": 6722,
"top": 1071,
"right": 947,
"bottom": 1006
}
],
"resize_dimensions": [
null,
null,
null,
null
],
"tile": true
},
{
"name": "W2",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
},
{
"name": "W3",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
},
{
"id": 46206136,
"name": "DISPLAY5",
"device": null,
"device_id": null,
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "P1",
"containers": {
"elements": [
{
"id": "xCZamNqUXdxb0TEP3IiOd"
},
{
"id": "kGMvbS7sGwRF8MbjQqY_R"
},
{
"id": "54Jv4HdRGmBKH4UG5h0zo"
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 967,
"top": 55,
"right": 1905,
"bottom": 2023
},
{
"left": 10,
"top": 55,
"right": 947,
"bottom": 2023
},
{
"left": 2882,
"top": 55,
"right": 947,
"bottom": 2023
}
],
"resize_dimensions": [
null,
null,
null
],
"tile": true
},
{
"name": "P2",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
},
{
"name": "P3",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
}
],
"focused": 1
},
"is_paused": false,
"resize_delta": 50,
"new_window_behaviour": "Create",
"cross_monitor_move_behaviour": "Insert",
"unmanaged_window_operation_behaviour": "Op",
"work_area_offset": {
"left": 0,
"top": 45,
"right": 0,
"bottom": 45
},
"focus_follows_mouse": null,
"mouse_follows_focus": true,
"has_pending_raise_op": false
}
Broken state (after sleep)
Output of 'komorebic state'
{
"monitors": {
"elements": [
{
"id": 46206136,
"name": "DISPLAY5",
"device": null,
"device_id": null,
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "P1",
"containers": {
"elements": [
{
"id": "8aNL2jZDsyPjRt9cJhpMT"
},
{
"id": "-zaVR8I6ywTTTsffCQKcs"
}
],
"focused": 1
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 1925,
"top": 55,
"right": 1905,
"bottom": 2023
},
{
"left": 10,
"top": 55,
"right": 1905,
"bottom": 2023
}
],
"resize_dimensions": [
null,
null
],
"tile": true
},
{
"name": "P2",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
},
{
"name": "P3",
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
},
{
"id": 17763244,
"name": "DISPLAY6",
"device": null,
"device_id": null,
"size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"workspaces": {
"elements": [
{
"name": null,
"containers": {
"elements": [
{
"id": "rDtx1fwn6mCEa3dEfZH06"
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 3850,
"top": 55,
"right": 3820,
"bottom": 2023
}
],
"resize_dimensions": [
null
],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
},
{
"id": 46206136,
"name": "DISPLAY5",
"device": null,
"device_id": null,
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"workspaces": {
"elements": [
{
"name": null,
"containers": {
"elements": [],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "BSP"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [],
"resize_dimensions": [],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
}
],
"focused": 0
},
"is_paused": false,
"resize_delta": 50,
"new_window_behaviour": "Create",
"cross_monitor_move_behaviour": "Insert",
"unmanaged_window_operation_behaviour": "Op",
"work_area_offset": {
"left": 0,
"top": 45,
"right": 0,
"bottom": 45
},
"focus_follows_mouse": null,
"mouse_follows_focus": true,
"has_pending_raise_op": false
}
Operating System
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22631 N/A Build 22631
komorebic check Output
No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\{UserName}
Looking for configuration files in C:\Users\{UserName}
Found komorebi.json; this file can be passed to the start command with the --config flag
Found C:\Users\{UserName}\.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag
Additional context I would be forever grateful if my issue can be verified by others, perhaps for PC as well. There can be connection race issues when a laptop is used with 2 monitors. I can also make a few more tests at requests to narrow down the bug.
I think it is also noteworthy, that after the state is broken (waking from the first sleep), the state stays the same even after another sleep.
https://github.com/LGUG2Z/komorebi/commit/f6c59c5dfcf901815bebfee1c4836038e96c96cd
I think this should fix a fair few monitor issues, but the code is a mess
@LGUG2Z I appreciate the honesty :) I will put the code to the test
@LGUG2Z I am running the "wip" commit you link above.
I have a global offset in my config that does not seem to be respected the same way anymore. I use the UltrawideVerticalStack layout.
"stackbar": {
"height": 40,
"mode": "OnStack",
"tabs": {
"width": 300,
"focused_text": "#bfaa69",
"unfocused_text": "#f2bdf3",
"background": "#121826"
}
},
"global_work_area_offset":
{
"bottom": 45,
"left": 0,
"right": 0,
"top": 45
},
Single window
2 windows
Stacked windows
What I would expect is to have the offset on the "single window" and the "Stacked window" as well. Can this be related to this change?
As for the bug with the state, I need to do more testing. I could see you've been very busy with Komorebi lately, thank you very much for your hard work!
The same is true when I use the monitor offset. The setting is only respected if there are multiple unstacked windows on the workspace.
"monitors": [
{
"work_area_offset":
{
"bottom": 45,
"left": 0,
"right": 0,
"top": 45
},
"workspaces": [
{ "name": "W1", "layout": "UltrawideVerticalStack" },
{ "name": "W2", "layout": "BSP" },
{ "name": "W3", "layout": "BSP" }
]
},
{
"work_area_offset":
{
"bottom": 45,
"left": 0,
"right": 0,
"top": 45
},
"workspaces": [
{ "name": "P1", "layout": "UltrawideVerticalStack" },
{ "name": "P2", "layout": "UltrawideVerticalStack" },
{ "name": "P3", "layout": "BSP" }
]
}
],
I have a global offset in my config that does not seem to be respected the same way anymore. I use the UltrawideVerticalStack layout.
Can you share the values recorded in komorebic state for work_area_offset (at the top level), work_area_offset (at the monitor level) and single_window_work_area_offset (at the monitor level) for each of these 3 situations in the screenshots?
wip is also updated with much nicer code now :) https://github.com/LGUG2Z/komorebi/commit/952bc13c296e1c59937579940abf9ddf6ed14668
I built the 952bc13 commit and executed the komorebic state in the 3 window configurations. I decided to include a bit more code just to be sure.
The summary is basically that the top level setting is present and both monitor level settings are null in all 3.
komorebic.json
[...]
"stackbar": {
"height": 40,
"mode": "OnStack",
"tabs": {
"width": 300,
"focused_text": "#bfaa69",
"unfocused_text": "#f2bdf3",
"background": "#121826"
}
},
"global_work_area_offset":
{
"bottom": 45,
"left": 0,
"right": 0,
"top": 45
},
"monitors": [
{
"workspaces": [
{ "name": "P1", "layout": "UltrawideVerticalStack" },
{ "name": "P2", "layout": "UltrawideVerticalStack" },
{ "name": "P3", "layout": "BSP" }
]
},
{
"workspaces": [
{ "name": "W1", "layout": "UltrawideVerticalStack" },
{ "name": "W2", "layout": "BSP" },
{ "name": "W3", "layout": "BSP" }
]
}
],
[...]
single window
{
"monitors": {
"elements": [
{
"id": 226363881,
"name": "DISPLAY5",
"device": "DEL4277",
"device_id": "DEL4277-5&1047835a&1&UID4352",
"size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {},
"workspace_names": {}
},
{
"id": 15337991,
"name": "DISPLAY6",
"device": "DEL4279",
"device_id": "DEL4279-5&1047835a&1&UID4354",
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "W1",
"containers": {
"elements": [
{
"id": "V-VaiLCyqR4EFNjDlto-Y",
"windows": {
"elements": [
{
"hwnd": 722656,
"title": "Windows PowerShell",
"exe": "WindowsTerminal.exe",
"class": "CASCADIA_HOSTING_WINDOW_CLASS",
"rect": {
"left": 17,
"top": 17,
"right": 3806,
"bottom": 2054
}
}
],
"focused": 0
}
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 10,
"top": 10,
"right": 3820,
"bottom": 2068
}
],
"resize_dimensions": [
null
],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
}
],
"focused": 1
},
"is_paused": false,
"resize_delta": 50,
"new_window_behaviour": "Create",
"cross_monitor_move_behaviour": "Insert",
"unmanaged_window_operation_behaviour": "Op",
"work_area_offset": {
"left": 0,
"top": 45,
"right": 0,
"bottom": 45
},
"focus_follows_mouse": null,
"mouse_follows_focus": true,
"has_pending_raise_op": false
}
2 windows
{
"monitors": {
"elements": [
{
"id": 226363881,
"name": "DISPLAY5",
"device": "DEL4277",
"device_id": "DEL4277-5&1047835a&1&UID4352",
"size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {},
"workspace_names": {}
},
{
"id": 15337991,
"name": "DISPLAY6",
"device": "DEL4279",
"device_id": "DEL4279-5&1047835a&1&UID4354",
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "W1",
"containers": {
"elements": [
{
"id": "V-VaiLCyqR4EFNjDlto-Y",
"windows": {
"elements": [
{
"hwnd": 722656,
"title": "Windows PowerShell",
"exe": "WindowsTerminal.exe",
"class": "CASCADIA_HOSTING_WINDOW_CLASS",
"rect": {
"left": 1932,
"top": 62,
"right": 1891,
"bottom": 2009
}
}
],
"focused": 0
}
},
{
"id": "XtUjI6soiV-1zXyNHwSjI",
"windows": {
"elements": [
{
"hwnd": 593460,
"title": "new 5 - Notepad++",
"exe": "notepad++.exe",
"class": "Notepad++",
"rect": {
"left": 17,
"top": 62,
"right": 1891,
"bottom": 2009
}
}
],
"focused": 0
}
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 1925,
"top": 55,
"right": 1905,
"bottom": 2023
},
{
"left": 10,
"top": 55,
"right": 1905,
"bottom": 2023
}
],
"resize_dimensions": [
null,
null
],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
}
],
"focused": 1
},
"is_paused": false,
"resize_delta": 50,
"new_window_behaviour": "Create",
"cross_monitor_move_behaviour": "Insert",
"unmanaged_window_operation_behaviour": "Op",
"work_area_offset": {
"left": 0,
"top": 45,
"right": 0,
"bottom": 45
},
"focus_follows_mouse": null,
"mouse_follows_focus": true,
"has_pending_raise_op": false
}
Stacked monitors
{
"monitors": {
"elements": [
{
"id": 226363881,
"name": "DISPLAY5",
"device": "DEL4277",
"device_id": "DEL4277-5&1047835a&1&UID4352",
"size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 3840,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {},
"workspace_names": {}
},
{
"id": 15337991,
"name": "DISPLAY6",
"device": "DEL4279",
"device_id": "DEL4279-5&1047835a&1&UID4354",
"size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2160
},
"work_area_size": {
"left": 0,
"top": 0,
"right": 3840,
"bottom": 2088
},
"work_area_offset": null,
"single_window_work_area_offset": null,
"workspaces": {
"elements": [
{
"name": "W1",
"containers": {
"elements": [
{
"id": "XtUjI6soiV-1zXyNHwSjI",
"windows": {
"elements": [
{
"hwnd": 593460,
"title": "new 7 - Notepad++",
"exe": "notepad++.exe",
"class": "Notepad++",
"rect": {
"left": 17,
"top": 62,
"right": 1891,
"bottom": 2009
}
},
{
"hwnd": 722656,
"title": "Windows PowerShell",
"exe": "WindowsTerminal.exe",
"class": "CASCADIA_HOSTING_WINDOW_CLASS",
"rect": {
"left": 17,
"top": 62,
"right": 3806,
"bottom": 2009
}
}
],
"focused": 1
}
}
],
"focused": 0
},
"monocle_container": null,
"maximized_window": null,
"floating_windows": [],
"layout": {
"Default": "UltrawideVerticalStack"
},
"layout_rules": [],
"layout_flip": null,
"workspace_padding": 5,
"container_padding": 5,
"latest_layout": [
{
"left": 10,
"top": 10,
"right": 3820,
"bottom": 2068
}
],
"resize_dimensions": [
null
],
"tile": true
}
],
"focused": 0
},
"workspace_names": {}
}
],
"focused": 1
},
"is_paused": false,
"resize_delta": 50,
"new_window_behaviour": "Create",
"cross_monitor_move_behaviour": "Insert",
"unmanaged_window_operation_behaviour": "Op",
"work_area_offset": {
"left": 0,
"top": 45,
"right": 0,
"bottom": 45
},
"focus_follows_mouse": null,
"mouse_follows_focus": true,
"has_pending_raise_op": false
}
As for the broken state, the new commit seems to be working better, but I need a bit more time to test it properly.
Also, when I set the monitor level work_area_offset in the config then it is present in the state on the monitor level, but it is only respected when there are multiple windows on the workspace (same as the top level setting).
The single_window_work_area_offset is always null.
Okay I have just reproduced this 🤞 Time to dig...
Fixed the offsets bug on master (and rebased to the monitor-madness branch)
https://github.com/LGUG2Z/komorebi/commit/d364b00b1520ad5327bdb3002a61829fd6c84ed2
This commit is getting closer to the desired state for monitor connection and reconnection
- Bounded channel that acts on events (+ backpressure for all the events that get spammed on connect/disconnect)
- Resolution Change and Display Connection Change events are handled separately
- Monitor configurations are cached on
- Loading/reloading the static config file if
display_index_preferencesis set - On monitor disconnection
- Loading/reloading the static config file if
- Improved (I think?) deduping to not end up with more monitors in the state than are actually connected
Really like the fitting branch name. I can confirm that as of the d364b00 commit, the offset issue has been fixed.
I will put Komorebi through a few sleeps to check the state.
The last couple of days has been busy for you, like a big spring cleaning. Take good care of yourself, my friend (if I may) :)
I found a few things while running the d364b00 commit, would you prefer I open new issues linking to the monitor-madness branch? I think it would make sense to keep this issue "clean".
Yeah please add them in a separate issue if they are unrelated to monitors jumping around in the state 🙏
The state is the same after sleep.
Thank you very much for fixing it. 🎉