LGUG2Z / komorebi

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

[BUG]: Breakage if Explorer has been restarted with taskkill or crashes #924

Open Cynosphere opened 3 months ago

Cynosphere commented 3 months ago

Describe the bug Switching workspaces via taskbar breaks if Explorer has been restarted while komorebi is running.

To Reproduce Steps to reproduce the behavior:

  1. Open a couple windows
  2. Move some to another workspace
  3. Restart Explorer
  4. Try to navigate to a window on a workspace that isn't the current one

Observed behavior The selected window shows up on the current workspace and the selected border becomes unresponsive. Switching workspaces still works and everything existing will be tiled properly. New windows do not get tiled.

Only way to fix is to stop and restart komorebi.

Expected behavior Selecting the window takes you to the workspace it is on and the border doesn't become unresponsive.

Operating System

OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.19045 N/A Build 19045

komorebic check Output

No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\User

Looking for configuration files in C:\Users\User

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

Found C:\Users\User\.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 N/A

Cynosphere commented 3 months ago

It only seems to be breaking when using the context menu entry from Winaero Tweaker, since that calls cmd to run taskkill and then launch it.

komorebic log output:

2024-07-26T19:10:40.151490Z ERROR komorebi::process_event: there is no container/window
2024-07-26T19:10:40.168399Z  INFO process_event{event=Show(ObjectShow, Window { hwnd: 29888088, animation: Animation { hwnd: 29888088 } })}:focus_window{idx=0}: komorebi::container: focusing window
2024-07-26T19:10:40.170116Z  INFO process_event{event=Show(ObjectShow, Window { hwnd: 29888088, animation: Animation { hwnd: 29888088 } })}:focus_container{idx=1}: komorebi::workspace: focusing container
2024-07-26T19:10:40.173032Z  INFO process_event{event=Show(ObjectShow, Window { hwnd: 29888088, animation: Animation { hwnd: 29888088 } })}:update_focused_workspace{follow_focus=false trigger_focus=false}: komorebi::window_manager: updating
2024-07-26T19:10:40.313078Z  INFO process_event{event=Show(ObjectShow, Window { hwnd: 29888088, animation: Animation { hwnd: 29888088 } })}: komorebi::process_event: processed: (hwnd: 29888088, title: C:\Windows\system32\cmd.exe, exe: cmd.exe, class: ConsoleWindowClass)
2024-07-26T19:10:40.422351Z  INFO process_event{event=TitleUpdate(ObjectNameChange, Window { hwnd: 29888088, animation: Animation { hwnd: 29888088 } })}: komorebi::process_event: processed: (hwnd: 29888088, title: 
C:\Windows\system32\cmd.exe, exe: cmd.exe, class: ConsoleWindowClass)
2024-07-26T19:10:40.727205Z  INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 10950080, animation: Animation { hwnd: 10950080 } })}:focus_window{idx=0}: komorebi::container: focusing window    
2024-07-26T19:10:40.730750Z ERROR process_event{event=FocusChange(SystemForeground, Window { hwnd: 10950080, animation: Animation { hwnd: 10950080 } })}: komorebi: panicked at komorebi\src\com\mod.rs:48:90:        
called `Result::unwrap()` on an `Err` value: Error { code: HRESULT(0x80040154), message: "Class not registered" } panic.file="komorebi\\src\\com\\mod.rs" panic.line=48 panic.column=90
2024-07-26T19:10:41.101634Z  INFO focus_window{idx=0}: komorebi::container: focusing window
2024-07-26T19:10:41.101901Z  INFO focus_container{idx=0}: komorebi::workspace: focusing container
2024-07-26T19:10:41.102128Z  INFO focus_window{idx=0}: komorebi::container: focusing window
2024-07-26T19:10:41.102328Z  INFO focus_container{idx=0}: komorebi::workspace: focusing container
2024-07-26T19:10:41.130517Z  INFO komorebi::reaper: reaped 2 orphan window(s) and 0 orphaned container(s) on monitor: 0, workspace: 0

Restaring Explorer through Task Manager or Process Hacker doesn't cause any breakage.

LGUG2Z commented 3 months ago

I don't actually understand any of the code in this module or how COM works 😅

https://github.com/LGUG2Z/komorebi/blob/b5eafc6b9678dd70ef0387f38fc52bc35014a615/komorebi/src/com/mod.rs#L1-L3

I'm guessing that these class registrations are tied to specific instances of explorer.exe. I'll leave this open if anyone wants to dig, but I guess the general guidance should be that if you restart explorer.exe, you should also restart komorebi.exe.