Skip to content

Commit

Permalink
WinEvent: Now cleaning cloaked windows (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
nir9 authored Dec 12, 2020
1 parent 299cb55 commit fef9b20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ tags
.clangd/
build/
compile_commands.json

dwm-win32.log
27 changes: 20 additions & 7 deletions src/dwm-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#define die(...) if (TRUE) { eprint(true, __VA_ARGS__); eprint(true, L"Win32 Last Error: %d", GetLastError()); cleanup(NULL); exit(EXIT_FAILURE); }


#define EVENT_OBJECT_CLOAKED 0x8017
#define EVENT_OBJECT_UNCLOAKED 0x8018

enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
Expand Down Expand Up @@ -1033,16 +1034,28 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

void CALLBACK
wineventproc(HWINEVENTHOOK heventhook, DWORD event, HWND hwnd, LONG object, LONG child, DWORD eventthread, DWORD eventtime_ms) {
if (object != OBJID_WINDOW || child != CHILDID_SELF || event != EVENT_OBJECT_UNCLOAKED || hwnd == NULL)
if (object != OBJID_WINDOW || child != CHILDID_SELF || hwnd == NULL)
return;

Client *c = getclient(hwnd);

if (!c && ismanageable(hwnd)) {
c = manage(hwnd);
managechildwindows(c);
setselected(c);
arrange();
switch (event)
{
case EVENT_OBJECT_UNCLOAKED:
if (!c && ismanageable(hwnd)) {
c = manage(hwnd);
managechildwindows(c);
setselected(c);
arrange();
}

break;

case EVENT_OBJECT_CLOAKED:
if (c)
unmanage(c);

break;
}
}

Expand Down Expand Up @@ -1244,7 +1257,7 @@ setup(lua_State *L, HINSTANCE hInstance) {
/* Grab a dynamic id for the SHELLHOOK message to be used later */
shellhookid = RegisterWindowMessageW(L"SHELLHOOK");

wineventhook = SetWinEventHook(EVENT_OBJECT_UNCLOAKED, EVENT_OBJECT_UNCLOAKED, NULL, wineventproc, 0, 0, WINEVENT_OUTOFCONTEXT);
wineventhook = SetWinEventHook(EVENT_OBJECT_CLOAKED, EVENT_OBJECT_UNCLOAKED, NULL, wineventproc, 0, 0, WINEVENT_OUTOFCONTEXT);

if (!wineventhook)
die(L"Could not SetWinEventHook");
Expand Down

0 comments on commit fef9b20

Please sign in to comment.