/* Global data */
static int shellhookid;
static void *cache;
-static win_t *root;
+static HWND root;
static list_t *screens;
/* Conversion functions */
msg, wParam, lParam,
st->vkCode, st->scanCode, st->flags,
ev, mod2int(mod));
- return wm_handle_event(win_focused() ?: root, ev, mod, getptr())
+ return wm_handle_event(win_focused(), ev, mod, getptr())
|| CallNextHookEx(0, msg, wParam, lParam);
}
//printf("sys_unwatch: %p\n", win);
}
-list_t *sys_info(win_t *win)
+list_t *sys_info(void)
{
if (screens == NULL)
EnumDisplayMonitors(NULL, NULL, MonProc, (LPARAM)&screens);
return screens;
}
-win_t *sys_init(void)
+void sys_init(void)
{
HINSTANCE hInst = GetModuleHandle(NULL);
- HWND hwnd = NULL;
/* Load configuration */
no_capture = conf_get_int("main.no-capture", no_capture);
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
/* Create shell hook window */
- if (!(hwnd = CreateWindowEx(0, "wmpus_class", "wmpus", 0,
+ if (!(root = CreateWindowEx(0, "wmpus_class", "wmpus", 0,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
HWND_MESSAGE, NULL, hInst, NULL)))
printf("sys_init: Error Creating Shell Hook Window - %lu\n", GetLastError());
GetModuleHandle("USER32.DLL"), "RegisterShellHookWindow");
if (!RegisterShellHookWindow)
printf("sys_init: Error Finding RegisterShellHookWindow - %lu\n", GetLastError());
- if (!RegisterShellHookWindow(hwnd))
+ if (!RegisterShellHookWindow(root))
printf("sys_init: Error Registering ShellHook Window - %lu\n", GetLastError());
shellhookid = RegisterWindowMessage("SHELLHOOK");
//SetWindowsHookEx(WH_SHELL, ShlProc, hInst, 0);
/* Alternate ways to get input */
- //if (!RegisterHotKey(hwnd, 123, MOD_CONTROL, VK_LBUTTON))
+ //if (!RegisterHotKey(root, 123, MOD_CONTROL, VK_LBUTTON))
// printf("sys_init: Error Registering Hotkey - %lu\n", GetLastError());
//if (!RegisterHotKey(NULL, 123, MOD_CONTROL, VK_LBUTTON))
// printf("sys_init: Error Registering Hotkey - %lu\n", GetLastError());
/* Capture ctrl-c and console widnow close */
SetConsoleCtrlHandler(CtrlProc, TRUE);
-
- return root = win_new(hwnd,0);
}
-void sys_run(win_t *root)
+void sys_run(void)
{
MSG msg = {};
if (!no_capture)
void sys_exit(void)
{
- PostMessage(root->sys->hwnd, WM_QUIT, 0, 0);
+ PostMessage(root, WM_QUIT, 0, 0);
}
-void sys_free(win_t *root)
+void sys_free(void)
{
/* I don't really care about this
* since I don't know how to use