Bug 1221947 - part 2: add TOUCH cause to IME Handling and use it to avoid checking for a keyboard, r=masayuki

This commit is contained in:
Gijs Kruitbosch 2015-11-12 16:36:19 +00:00
parent ac523312ef
commit 2128e4b37b
4 changed files with 20 additions and 2 deletions

View File

@ -352,7 +352,9 @@ nsFocusManager::GetRedirectedFocus(nsIContent* aContent)
InputContextAction::Cause
nsFocusManager::GetFocusMoveActionCause(uint32_t aFlags)
{
if (aFlags & nsIFocusManager::FLAG_BYMOUSE) {
if (aFlags & nsIFocusManager::FLAG_BYTOUCH) {
return InputContextAction::CAUSE_TOUCH;
} else if (aFlags & nsIFocusManager::FLAG_BYMOUSE) {
return InputContextAction::CAUSE_MOUSE;
} else if (aFlags & nsIFocusManager::FLAG_BYKEY) {
return InputContextAction::CAUSE_KEY;

View File

@ -307,7 +307,9 @@ struct InputContextAction final
// The cause is user's keyboard operation.
CAUSE_KEY,
// The cause is user's mouse operation.
CAUSE_MOUSE
CAUSE_MOUSE,
// The cause is user's touch operation (implies mouse)
CAUSE_TOUCH
};
Cause mCause;

View File

@ -39,6 +39,9 @@ namespace widget {
******************************************************************************/
bool IMEHandler::sPluginHasFocus = false;
InputContextAction::Cause IMEHandler::sLastContextActionCause =
InputContextAction::CAUSE_UNKNOWN;
#ifdef NS_ENABLE_TSF
bool IMEHandler::sIsInTSFMode = false;
bool IMEHandler::sIsIMMEnabled = true;
@ -349,6 +352,7 @@ IMEHandler::SetInputContext(nsWindow* aWindow,
InputContext& aInputContext,
const InputContextAction& aAction)
{
sLastContextActionCause = aAction.mCause;
// FYI: If there is no composition, this call will do nothing.
NotifyIME(aWindow, IMENotification(REQUEST_TO_COMMIT_COMPOSITION));
@ -692,6 +696,14 @@ IMEHandler::IsKeyboardPresentOnSlate()
return true;
}
// Before we check for a keyboard, we should check if the last input was touch,
// in which case we ignore whether or not a keyboard is present:
if (sLastContextActionCause == InputContextAction::CAUSE_TOUCH) {
Preferences::SetString(kOskDebugReason,
L"IKPOS: Used touch to focus control, ignoring keyboard presence");
return false;
}
const GUID KEYBOARD_CLASS_GUID =
{ 0x4D36E96B, 0xE325, 0x11CE,
{ 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } };

View File

@ -113,6 +113,8 @@ public:
private:
static bool sPluginHasFocus;
static InputContextAction::Cause sLastContextActionCause;
#ifdef NS_ENABLE_TSF
static decltype(SetInputScopes)* sSetInputScopes;
static void SetInputScopeForIMM32(nsWindow* aWindow,