Bug 855975 part.3 Wrap MapVirtualKeyEx() API for converting VK to ScanCode with widget::KeyboardLayout r=jimm

This commit is contained in:
Masayuki Nakano 2013-05-29 15:34:47 +09:00
Родитель 529c849332
Коммит e5373c9e94
3 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -697,6 +697,13 @@ KeyboardLayout::IsPrintableCharKey(uint8_t aVirtualKey)
return GetKeyIndex(aVirtualKey) >= 0;
}
WORD
KeyboardLayout::ComputeScanCodeForVirtualKeyCode(uint8_t aVirtualKeyCode) const
{
return static_cast<WORD>(
::MapVirtualKeyEx(aVirtualKeyCode, MAPVK_VK_TO_VSC, GetLayout()));
}
bool
KeyboardLayout::IsDeadKey(uint8_t aVirtualKey,
const ModifierKeyState& aModKeyState) const

Просмотреть файл

@ -467,6 +467,11 @@ public:
return mIsPendingToRestoreKeyboardLayout ? ::GetKeyboardLayout(0) :
mKeyboardLayout;
}
/**
* This wraps MapVirtualKeyEx() API with MAPVK_VK_TO_VSC.
*/
WORD ComputeScanCodeForVirtualKeyCode(uint8_t aVirtualKeyCode) const;
};
} // namespace widget

Просмотреть файл

@ -5862,10 +5862,8 @@ nsWindow::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
}
::SetKeyboardState(kbdState);
ModifierKeyState modKeyState;
UINT scanCode = ::MapVirtualKeyEx(argumentKeySpecific ?
argumentKeySpecific : aNativeKeyCode,
MAPVK_VK_TO_VSC,
keyboardLayout->GetLayout());
UINT scanCode = keyboardLayout->ComputeScanCodeForVirtualKeyCode(
argumentKeySpecific ? argumentKeySpecific : aNativeKeyCode);
LPARAM lParam = static_cast<LPARAM>(scanCode << 16);
// Add extended key flag to the lParam for right control key and right alt
// key.
@ -5910,10 +5908,8 @@ nsWindow::SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
}
::SetKeyboardState(kbdState);
ModifierKeyState modKeyState;
UINT scanCode = ::MapVirtualKeyEx(argumentKeySpecific ?
argumentKeySpecific : aNativeKeyCode,
MAPVK_VK_TO_VSC,
keyboardLayout->GetLayout());
UINT scanCode = keyboardLayout->ComputeScanCodeForVirtualKeyCode(
argumentKeySpecific ? argumentKeySpecific : aNativeKeyCode);
LPARAM lParam = static_cast<LPARAM>(scanCode << 16);
// Add extended key flag to the lParam for right control key and right alt
// key.