From b069fa7e4658f6616221da718b0a3cf959cbd5b0 Mon Sep 17 00:00:00 2001 From: Adham Ramy Date: Thu, 21 Dec 2023 13:25:24 +0300 Subject: [PATCH] Do not manage non-responding windows adds check for Hung windows in `ismanageable()` and calls `unmanage()`. The `WM_TIMER` calls the `IsHungAppWindow` on all the managed windows at the user defined interval, and calls `unmanage()` --- src/dwm-win32.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/dwm-win32.c b/src/dwm-win32.c index 0831cea..a9494f5 100644 --- a/src/dwm-win32.c +++ b/src/dwm-win32.c @@ -725,6 +725,10 @@ ismanageable(HWND hwnd) { if (hwnd == 0) return false; + if (IsHungAppWindow(hwnd)) { + return false; + } + if (getclient(hwnd)) return true; @@ -860,6 +864,12 @@ manage(HWND hwnd) { c->iscloaked = iscloaked(hwnd); c->isminimized = IsIconic(hwnd); + // Check if the window is hung + if (IsHungAppWindow(hwnd)) { + unmanage(c); + return NULL; + } + static WINDOWPLACEMENT wp = { .length = sizeof(WINDOWPLACEMENT), .showCmd = SW_RESTORE, @@ -972,7 +982,18 @@ LRESULT CALLBACK barhandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) buttonpress(msg, &MAKEPOINTS(lParam)); break; case WM_TIMER: + // check for hung windows every time the timer runs + // Iterate over all managed windows + for (Client* c = clients; c; c = c->next) { + // Check if the window is hung + if (IsHungAppWindow(c->hwnd)) { + // Unmanage the window + unmanage(c); + } + } + drawbar(); + default: return DefWindowProc(hwnd, msg, wParam, lParam); }