forked from nir9/lightwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wm_dll.c
29 lines (23 loc) · 899 Bytes
/
wm_dll.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// This DLL is loaded into many processes on the computer, therefore we need to keep the logic here as simple as possible to avoid slowing down the system
#define LIGHTWM_DLL
#include <Windows.h>
#include <stdio.h>
#include "messages.h"
#include "error.h"
#include "shared_mem.h"
DWORD lightwmMainThreadId = 0;
__declspec(dllexport) LRESULT CALLBACK ShellProc(int code, WPARAM wparam, LPARAM lparam) {
if (code == HSHELL_WINDOWCREATED || code == HSHELL_WINDOWDESTROYED) {
PostThreadMessageW(lightwmMainThreadId, LWM_WINDOW_EVENT, 0, 0);
}
return CallNextHookEx(NULL, code, wparam, lparam);
}
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
{
if (ulReasonForCall == DLL_PROCESS_ATTACH) {
if (!retrieveDwordFromSharedMemory(&lightwmMainThreadId)) {
reportGeneralError(L"Error retrieving the thread id from shared memory");
}
}
return TRUE;
}