Skip to content

Commit

Permalink
Do not manage non-responding windows
Browse files Browse the repository at this point in the history
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()`
  • Loading branch information
adham-elaraby committed Dec 21, 2023
1 parent ff7f41a commit b069fa7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/dwm-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ ismanageable(HWND hwnd) {
if (hwnd == 0)
return false;

if (IsHungAppWindow(hwnd)) {
return false;
}

if (getclient(hwnd))
return true;

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b069fa7

Please sign in to comment.