Commented out an unnecessary hook and added a compile time

switch to disable grabbing of keyboard on win32 to facilitate
debugging.
This commit is contained in:
crs 2003-02-16 19:51:46 +00:00
parent 60fdb1f529
commit 9a7e452a3e
1 changed files with 34 additions and 6 deletions

View File

@ -16,6 +16,14 @@
#include "ProtocolTypes.h" #include "ProtocolTypes.h"
#include <zmouse.h> #include <zmouse.h>
//
// debugging compile flag. when not zero the server doesn't grab
// the keyboard when the mouse leaves the server screen. this
// makes it possible to use the debugger (via the keyboard) when
// all user input would normally be caught by the hook procedures.
//
#define NO_GRAB_KEYBOARD 0
// //
// extra mouse wheel stuff // extra mouse wheel stuff
// //
@ -258,6 +266,7 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam)
return CallNextHookEx(g_mouse, code, wParam, lParam); return CallNextHookEx(g_mouse, code, wParam, lParam);
} }
/*
static static
LRESULT CALLBACK LRESULT CALLBACK
cbtHook(int code, WPARAM wParam, LPARAM lParam) cbtHook(int code, WPARAM wParam, LPARAM lParam)
@ -270,6 +279,7 @@ cbtHook(int code, WPARAM wParam, LPARAM lParam)
return CallNextHookEx(g_cbt, code, wParam, lParam); return CallNextHookEx(g_cbt, code, wParam, lParam);
} }
*/
static static
LRESULT CALLBACK LRESULT CALLBACK
@ -409,6 +419,7 @@ getLowLevelProc(void*)
MSG msg; MSG msg;
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
#if !NO_GRAB_KEYBOARD
// install low-level keyboard hook // install low-level keyboard hook
g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL, g_keyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL,
&keyboardLLHook, &keyboardLLHook,
@ -420,6 +431,10 @@ getLowLevelProc(void*)
SetEvent(g_hookEventLL); SetEvent(g_hookEventLL);
return 1; return 1;
} }
#else
// keep compiler quiet
&keyboardLLHook;
#endif
// install low-level mouse hook // install low-level mouse hook
g_mouseLL = SetWindowsHookEx(WH_MOUSE_LL, g_mouseLL = SetWindowsHookEx(WH_MOUSE_LL,
@ -428,8 +443,10 @@ getLowLevelProc(void*)
0); 0);
if (g_mouseLL == NULL) { if (g_mouseLL == NULL) {
// indicate failure and exit // indicate failure and exit
if (g_keyboardLL != NULL) {
UnhookWindowsHookEx(g_keyboardLL); UnhookWindowsHookEx(g_keyboardLL);
g_keyboardLL = NULL; g_keyboardLL = NULL;
}
g_hookThreadIDLL = 0; g_hookThreadIDLL = 0;
SetEvent(g_hookEventLL); SetEvent(g_hookEventLL);
return 1; return 1;
@ -634,6 +651,7 @@ install()
g_wheelSupport = getWheelSupport(); g_wheelSupport = getWheelSupport();
// install keyboard hook // install keyboard hook
#if !NO_GRAB_KEYBOARD
g_keyboard = SetWindowsHookEx(WH_KEYBOARD, g_keyboard = SetWindowsHookEx(WH_KEYBOARD,
&keyboardHook, &keyboardHook,
g_hinstance, g_hinstance,
@ -642,6 +660,10 @@ install()
g_threadID = NULL; g_threadID = NULL;
return 0; return 0;
} }
#else
// keep compiler quiet
&keyboardHook;
#endif
// install mouse hook // install mouse hook
g_mouse = SetWindowsHookEx(WH_MOUSE, g_mouse = SetWindowsHookEx(WH_MOUSE,
@ -650,12 +672,15 @@ install()
0); 0);
if (g_mouse == NULL) { if (g_mouse == NULL) {
// uninstall keyboard hook before failing // uninstall keyboard hook before failing
if (g_keyboard != NULL) {
UnhookWindowsHookEx(g_keyboard); UnhookWindowsHookEx(g_keyboard);
g_keyboard = NULL; g_keyboard = NULL;
}
g_threadID = NULL; g_threadID = NULL;
return 0; return 0;
} }
/*
// install CBT hook // install CBT hook
g_cbt = SetWindowsHookEx(WH_CBT, g_cbt = SetWindowsHookEx(WH_CBT,
&cbtHook, &cbtHook,
@ -663,13 +688,16 @@ install()
0); 0);
if (g_cbt == NULL) { if (g_cbt == NULL) {
// uninstall keyboard and mouse hooks before failing // uninstall keyboard and mouse hooks before failing
if (g_keyboard != NULL) {
UnhookWindowsHookEx(g_keyboard); UnhookWindowsHookEx(g_keyboard);
UnhookWindowsHookEx(g_mouse);
g_keyboard = NULL; g_keyboard = NULL;
}
UnhookWindowsHookEx(g_mouse);
g_mouse = NULL; g_mouse = NULL;
g_threadID = NULL; g_threadID = NULL;
return 0; return 0;
} }
*/
// install GetMessage hook (unless already installed) // install GetMessage hook (unless already installed)
if (g_wheelSupport == kWheelOld && g_getMessage == NULL) { if (g_wheelSupport == kWheelOld && g_getMessage == NULL) {