glazewm icon indicating copy to clipboard operation
glazewm copied to clipboard

Restore window/workspace state on next startup after a forceful exit

Open tgharib opened this issue 3 years ago • 15 comments

GlazeWM just froze on my PC, which is fine. I don't mind occassionaly restarting GlazeWM. Unfortunately, after having needed to kill it in Task Manager, all my windows except one window are hidden. I suppose this is because before the crash, I was on a workspace with only one window. After starting GlazeWM again, all the hidden windows remain hidden and I essentially lost all my unsaved progress.

There should be a more graceful way of handling crashes. Maybe unhide all windows on GlazeWM start? nog actually saves all windows in a text file so on restart, not only does it unhide hidden windows but it also puts them in the right workspaces.

tgharib avatar Jun 03 '22 03:06 tgharib

If you find yourself in the same situation as I was where unsaved progress was hidden, then WinLister by NirSoft has the ability to unhide hidden windows.

tgharib avatar Jun 03 '22 04:06 tgharib

I agree forceful exits should be handled better - there shouldn't be a need to use a 3rd party tool to handle these shortcomings.

Killing the WM via Task Manager unfortunately prevents it from performing any cleanup. I've had the same happen before when a managed window goes fully unresponsive, since the Windows API methods for moving/resizing windows are synchronous and will wait until completion. Is there an error log in C:\Users\<YOUR_USER>\.glaze-wm\errors.log?

Many background processes actually make use of hidden windows (it's common for 100+ hidden windows to be running at once), so unhiding all windows will likely cause these to freak out. The idea of saving window/workspace state to a text file sounds pretty solid though. I think it would mean updating the text file after every state-altering command, and there's also the edge case where the user config is changed before the next startup. A cool side benefit of implementing something like this is that it would make it easy to implement a user config reload feature further down the line.

lars-berger avatar Jun 03 '22 08:06 lars-berger

Is there an error log in C:\Users\<YOUR_USER>\.glaze-wm\errors.log?

Unfortunately, losing unsaved progress after a crash is a deal-breaker for me so I uninstalled, and then I reflexively removed ~/.glaze-wm. Opps.

I should add that komorebi tackles this issue by simply minimizing windows rather than hiding them. I'm not implying this method is superior but I figured listing more possible solutions is better.

tgharib avatar Jun 03 '22 14:06 tgharib

This is still an issue in komorebi for users who want to hide instead of minimize windows. The way I went about it is a little clunky, but hey, it works. 🤷

Every time an event occurs, komorebi updates a local JSON file with the list of all known HWNDs across all workspaces. Then, if there is a crash or the process must be killed forcefully, the user can run the restore-windows command to restore whatever HWNDs were saved in that file before the crash/kill.

For regular process terminations (ie. ctrl-c), komorebi uses a ctrl-c signal handler to restore all known HWNDs before finally processing the ctrl-c and exiting the process.

Hope this helps!

LGUG2Z avatar Jun 19 '22 23:06 LGUG2Z

Any updates on this? I really like this WM but this is honestly a dealbreaker. having to go through a big hassle to unhide the apps is too much. I am willing to work on a fix, any leads on how to start or how you want the fix to be implemented?

M7mdisk avatar Jan 21 '23 15:01 M7mdisk

+1

Me and my SO both have been running GlazeWM for the past 1-2 weeks without many issues, but funnily enough we both had this happen today.

michaelowens avatar Feb 02 '23 23:02 michaelowens

@M7mdisk I agree with your point. This is the most serious, dealbreaking bug that exists in GWM. I had intentions to investigate and hopefully fix it one day down the road, but I have some other priorities that I'd like to work on fist.

If your willing to take the lead on this, that would be awesome. If your looking for some guidance, feel free to join the community discord and shoot me a ping.

HolbyFPV avatar Feb 03 '23 02:02 HolbyFPV

Any progress on this? I am not even able to restore the windows as suggested by @tgharib, which makes it quite painful to work with a crash.

arminveres avatar Feb 15 '23 13:02 arminveres

Any progress on this? I am not even able to restore the windows as suggested by @tgharib, which makes it quite painful to work with a crash.

No one has started work on this yet. If anyone wants to take a stab at it, feel free to join the discord. Otherwise, I will try and fix it soon.

HolbyFPV avatar Feb 15 '23 23:02 HolbyFPV

Any news on this? It's the biggest issue I have with glazewm right now...

SebSa avatar Jun 14 '23 14:06 SebSa

Any progress on this? I am not even able to restore the windows as suggested by @tgharib, which makes it quite painful to work with a crash.

@tgharib I've just downloaded GUIPropView and it seems to work. It's somewhat helpful if I really need to restore the window. Make sure to check Child > Display Hidden Windows after running the application. Then right-click the window you wish to restore and select Show Selected Window and then again select Switch To. Hope you might find this helpful.

dipta10 avatar Jun 16 '23 20:06 dipta10

Using GuiProdView I also had to enable TopLevel > Display Hidden Windows to see all hidden windows.

olivier-norture avatar Sep 27 '23 08:09 olivier-norture

Hidden windows are restored on crash in the current build.

HolbyFPV avatar Sep 27 '23 09:09 HolbyFPV

Hidden windows are restored on crash in the current build.

Doesn't work for me, I lose windows even on a close command. And I'm on version 2.1.1, which afaik is the latest

yavko avatar Mar 19 '24 21:03 yavko

Hidden windows are restored on crash in the current build.

Doesn't work for me, I lose windows even on a close command. And I'm on version 2.1.1, which afaik is the latest

Appreciate the feedback. Re-opening this issue while we investigate a better solution.

HolbyFPV avatar Apr 13 '24 05:04 HolbyFPV