From bac1f24a53aaf53ba22cd348f600176ba59e80fb Mon Sep 17 00:00:00 2001 From: crs Date: Thu, 29 Jul 2004 21:50:17 +0000 Subject: [PATCH] Synergy now steals window activation when using low level hooks and a console window is the active window. This is to work around console windows preventing the hook from detecting the shift key. --- lib/platform/CMSWindowsDesks.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/platform/CMSWindowsDesks.cpp b/lib/platform/CMSWindowsDesks.cpp index 8c71b4b5..18e8bb0f 100644 --- a/lib/platform/CMSWindowsDesks.cpp +++ b/lib/platform/CMSWindowsDesks.cpp @@ -558,6 +558,10 @@ CMSWindowsDesks::deskEnter(CDesk* desk) SetWindowPos(desk->m_window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW); + + // this is here only because of the "ConsoleWindowClass" stuff in + // deskLeave. + EnableWindow(desk->m_window, desk->m_lowLevel ? FALSE : TRUE); } void @@ -600,6 +604,26 @@ CMSWindowsDesks::deskLeave(CDesk* desk, HKL keyLayout) SetActiveWindow(desk->m_window); } + // if the active window is a console then activate our window. + // we do this because for some reason our hook reports unshifted + // characters when the shift is down and a console window is + // active. interestingly we do see the shift key go down and up. + // note that we must enable the window to activate it and we + // need to disable the window on deskEnter. + // FIXME -- figure out the real problem here and solve it. + else { + HWND foreground = GetForegroundWindow(); + if (foreground != NULL) { + char className[40]; + if (GetClassName(foreground, className, + sizeof(className) / sizeof(className[0])) && + strcmp(className, "ConsoleWindowClass") == 0) { + EnableWindow(desk->m_window, TRUE); + SetActiveWindow(desk->m_window); + } + } + } + // switch to requested keyboard layout ActivateKeyboardLayout(keyLayout, 0); }