Skip to content

Commit

Permalink
Dont manage hanging and debugged windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nir9 committed Jan 14, 2024
1 parent f4d88de commit b121a4c
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions src/dwm-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct Client {
bool ignoreborder;
bool border;
bool wasvisible;
bool ishanging;
bool isfixed, isurgent; // XXX: useless?
bool iscloaked; // WinStore apps
Client *next;
Expand Down Expand Up @@ -640,13 +641,19 @@ getclienttitle(HWND hwnd) {
return buf;
}

HANDLE
getclientprocess(HWND hwnd) {
DWORD processid = 0;
GetWindowThreadProcessId(hwnd, &processid);
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processid);
return hProc;
}

LPWSTR
getclientprocessname(HWND hwnd) {
DWORD processid = 0;
DWORD buf_size = MAX_PATH;
static wchar_t buf[MAX_PATH];
GetWindowThreadProcessId(hwnd, &processid);
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processid);
HANDLE hProc = getclientprocess(hwnd);
if (hProc) {
if (QueryFullProcessImageNameW(hProc, 0, buf, &buf_size)) {
CloseHandle(hProc);
Expand All @@ -658,6 +665,18 @@ getclientprocessname(HWND hwnd) {
return NULL;
}

BOOL
isclientdebugged(HWND hwnd) {
BOOL debuggerPresent = false;
HANDLE hProc = getclientprocess(hwnd);
if (!CheckRemoteDebuggerPresent(hProc, &debuggerPresent)) {
CloseHandle(hProc);
return false;
}

CloseHandle(hProc);
return debuggerPresent;
}

HWND
getroot(HWND hwnd) {
Expand Down Expand Up @@ -697,6 +716,10 @@ ismanageable(HWND hwnd) {
return false;
}

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

if (getclient(hwnd))
return true;

Expand Down Expand Up @@ -1344,6 +1367,19 @@ void
showhide(Client *c) {
if (!c)
return;

if (isclientdebugged(c->hwnd)) {
c->ishanging = true;
unmanage(c);
return;
}

if (IsHungAppWindow(c->hwnd)) {
c->ishanging = true;
unmanage(c);
return;
}

/* XXX: is the order of showing / hidding important? */
if (!ISVISIBLE(c)) {
if (IsWindowVisible(c->hwnd)) {
Expand Down Expand Up @@ -1517,9 +1553,11 @@ writelog(const Arg *arg) {
void
unmanage(Client *c) {
debug(L" unmanage %s\n", getclienttitle(c->hwnd));
if (c->wasvisible)

// Don't want to touch Window related functions on hanging windows
if (c->wasvisible && !c->ishanging)
setvisibility(c->hwnd, true);
if (!c->isfloating)
if (!c->isfloating && !c->ishanging)
setborder(c, true);
detach(c);
detachstack(c);
Expand Down

0 comments on commit b121a4c

Please sign in to comment.