X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=sys-win32.c;h=c0989dea5dfdb9b87a4d9dcf931d457a178443d5;hb=84fdb5249282e858b32f59f49a877a07350a48eb;hp=34d5c508bd062b77b508b1b3772b18c09cbaf7b5;hpb=7e8ce091da421353576edbd2a4a4e620fe0a62bd;p=wmpus diff --git a/sys-win32.c b/sys-win32.c index 34d5c50..c0989de 100644 --- a/sys-win32.c +++ b/sys-win32.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Andy Spencer + * Copyright (c) 2011-2012, Andy Spencer * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,6 +26,7 @@ #include "util.h" #include "conf.h" +#include "types.h" #include "sys.h" #include "wm.h" @@ -46,7 +47,7 @@ typedef struct { /* Global data */ static int shellhookid; static void *cache; -static win_t *root; +static HWND root; static list_t *screens; /* Conversion functions */ @@ -199,7 +200,7 @@ LRESULT CALLBACK KbdProc(int msg, WPARAM wParam, LPARAM lParam) 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); } @@ -400,17 +401,16 @@ void sys_unwatch(win_t *win, event_t ev, mod_t mod) //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); @@ -431,7 +431,7 @@ win_t *sys_init(void) 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()); @@ -441,7 +441,7 @@ win_t *sys_init(void) 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"); @@ -451,18 +451,16 @@ win_t *sys_init(void) //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) @@ -476,10 +474,10 @@ void sys_run(win_t *root) 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