Reverted change to detach threads in hook DLL. It was breaking

double clicking.
This commit is contained in:
crs 2004-11-01 22:26:52 +00:00
parent 65a86cb13b
commit f10ef9a97c
1 changed files with 19 additions and 22 deletions

View File

@ -121,6 +121,16 @@ int _fltused=0;
static static
void void
detachThread()
{
if (g_attachedThread != 0 && g_hookThread != g_attachedThread) {
AttachThreadInput(g_hookThread, g_attachedThread, FALSE);
g_attachedThread = 0;
}
}
static
bool
attachThreadToForeground() attachThreadToForeground()
{ {
// only attach threads if using low level hooks. a low level hook // only attach threads if using low level hooks. a low level hook
@ -135,26 +145,17 @@ attachThreadToForeground()
// skip if no change // skip if no change
if (g_attachedThread != threadID) { if (g_attachedThread != threadID) {
// detach from previous thread // detach from previous thread
if (g_attachedThread != 0 && g_attachedThread != g_hookThread) { detachThread();
AttachThreadInput(g_hookThread, g_attachedThread, FALSE);
}
// attach to new thread // attach to new thread
g_attachedThread = threadID; if (threadID != 0 && threadID != g_hookThread) {
if (g_attachedThread != 0 && g_attachedThread != g_hookThread) { AttachThreadInput(g_hookThread, threadID, TRUE);
AttachThreadInput(g_hookThread, g_attachedThread, TRUE); g_attachedThread = threadID;
} }
return true;
} }
} }
} return false;
static
void
detachThread()
{
if (g_attachedThread != 0) {
AttachThreadInput(g_hookThread, g_attachedThread, FALSE);
g_attachedThread = 0;
}
} }
#if !NO_GRAB_KEYBOARD #if !NO_GRAB_KEYBOARD
@ -420,9 +421,7 @@ bool
keyboardHookHandler(WPARAM wParam, LPARAM lParam) keyboardHookHandler(WPARAM wParam, LPARAM lParam)
{ {
attachThreadToForeground(); attachThreadToForeground();
bool result = doKeyboardHookHandler(wParam, lParam); return doKeyboardHookHandler(wParam, lParam);
detachThread();
return result;
} }
#endif #endif
@ -533,9 +532,7 @@ bool
mouseHookHandler(WPARAM wParam, SInt32 x, SInt32 y, SInt32 data) mouseHookHandler(WPARAM wParam, SInt32 x, SInt32 y, SInt32 data)
{ {
attachThreadToForeground(); attachThreadToForeground();
bool result = doMouseHookHandler(wParam, x, y, data); return doMouseHookHandler(wParam, x, y, data);
detachThread();
return result;
} }
#if !NO_GRAB_KEYBOARD #if !NO_GRAB_KEYBOARD