check the return value of GetKeyboardLayout for 0 and take the keyboard layout of the desktop HWND instead

Issue #386
This commit is contained in:
syed.amer@gilani.eu 2010-02-25 14:21:47 +00:00
parent 25d8110ed2
commit 588f257530
1 changed files with 8 additions and 0 deletions

View File

@ -854,6 +854,14 @@ CMSWindowsKeyState::pollActiveGroup() const
// get keyboard layout for the thread
HKL hkl = GetKeyboardLayout(targetThread);
if (!hkl) {
// GetKeyboardLayout failed. Maybe targetWindow is a console window.
// We're getting the keyboard layout of the desktop instead.
targetWindow = GetDesktopWindow();
targetThread = GetWindowThreadProcessId(targetWindow, NULL);
hkl = GetKeyboardLayout(targetThread);
}
// get group
GroupMap::const_iterator i = m_groupMap.find(hkl);
if (i == m_groupMap.end()) {