Bug 1648534 - Read HKLM's EnableDesktopModeAutoInvoke entry if no entry in HKCU. r=masayuki

This is regression by bug 1618759 and bug 1197722.

By bug 1197722, we use registry value whether opening software keyboard even if
desktop mode. But this fix isn't enough.

Also, before landing bug 1618759, since TSF manages software keyboard state on
newer Windows 10 version such as Windows 10 RS1, bug 1197722's fix isn't used.
Then, after landing bug 1618759, since we use `EnableDesktopModeAutoInvoke`
again, this issue occurs.

Since `EnableDesktopModeAutoInvoke` is available if in HKLM, we should read
HKLM's key too.

Differential Revision: https://phabricator.services.mozilla.com/D83489
This commit is contained in:
Makoto Kato 2020-07-17 03:02:15 +00:00
Родитель bf437dbf1f
Коммит 61c5bb1a5e
1 изменённых файлов: 29 добавлений и 16 удалений

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

@ -1011,6 +1011,30 @@ bool IMEHandler::IsInTabletMode() {
return isInTabletMode;
}
static bool ReadEnableDesktopModeAutoInvoke(uint32_t aRoot,
nsIWindowsRegKey* aRegKey,
uint32_t& aValue) {
nsresult rv;
rv = aRegKey->Open(aRoot, u"SOFTWARE\\Microsoft\\TabletTip\\1.7"_ns,
nsIWindowsRegKey::ACCESS_QUERY_VALUE);
if (NS_FAILED(rv)) {
Preferences::SetString(kOskDebugReason,
L"AIOSKIDM: failed opening regkey.");
return false;
}
// EnableDesktopModeAutoInvoke is an opt-in option from the Windows
// Settings to "Automatically show the touch keyboard in windowed apps
// when there's no keyboard attached to your device." If the user has
// opted-in to this behavior, the tablet-mode requirement is skipped.
rv = aRegKey->ReadIntValue(u"EnableDesktopModeAutoInvoke"_ns, &aValue);
if (NS_FAILED(rv)) {
Preferences::SetString(kOskDebugReason,
L"AIOSKIDM: failed reading value of regkey.");
return false;
}
return true;
}
// static
bool IMEHandler::AutoInvokeOnScreenKeyboardInDesktopMode() {
nsresult rv;
@ -1022,23 +1046,12 @@ bool IMEHandler::AutoInvokeOnScreenKeyboardInDesktopMode() {
L"nsIWindowsRegKey not available");
return false;
}
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
u"SOFTWARE\\Microsoft\\TabletTip\\1.7"_ns,
nsIWindowsRegKey::ACCESS_QUERY_VALUE);
if (NS_FAILED(rv)) {
Preferences::SetString(kOskDebugReason,
L"AIOSKIDM: failed opening regkey.");
return false;
}
// EnableDesktopModeAutoInvoke is an opt-in option from the Windows
// Settings to "Automatically show the touch keyboard in windowed apps
// when there's no keyboard attached to your device." If the user has
// opted-in to this behavior, the tablet-mode requirement is skipped.
uint32_t value;
rv = regKey->ReadIntValue(u"EnableDesktopModeAutoInvoke"_ns, &value);
if (NS_FAILED(rv)) {
Preferences::SetString(kOskDebugReason,
L"AIOSKIDM: failed reading value of regkey.");
if (!ReadEnableDesktopModeAutoInvoke(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
regKey, value) &&
!ReadEnableDesktopModeAutoInvoke(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
regKey, value)) {
return false;
}
if (!!value) {