https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ec0695c26ba520b0fbfb2…
commit ec0695c26ba520b0fbfb2e3f0791d3c20376c21b
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Dec 27 11:43:01 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Dec 27 11:43:01 2023 +0900
[MSCTF][SDK] Implement InitLangChangeHotKey (#6234)
Supporting TIPs and Language Bar...
JIRA issue: CORE-19361
- Implement InitLangChangeHotKey function.
- Add some global variables about hot-keys.
- Fix CicRegKey in <cicero/cicreg.h>.
---
dll/win32/msctf/utils.cpp | 131 +++++++++++++++++++++++++++++++++++-
sdk/include/reactos/cicero/cicreg.h | 4 +-
2 files changed, 130 insertions(+), 5 deletions(-)
diff --git a/dll/win32/msctf/utils.cpp b/dll/win32/msctf/utils.cpp
index 4066714f89e..dfad480ea0b 100644
--- a/dll/win32/msctf/utils.cpp
+++ b/dll/win32/msctf/utils.cpp
@@ -78,6 +78,14 @@ CicMutex g_mutexTMD;
// File mapping
CicFileMappingStatic g_SharedMemory;
+// Hot-Keys
+UINT g_uLangHotKeyModifiers = 0;
+UINT g_uLangHotKeyVKey = 0;
+UINT g_uLangHotKeyVKey2 = 0;
+UINT g_uKeyTipHotKeyModifiers = 0;
+UINT g_uKeyTipHotKeyVKey = 0;
+UINT g_uKeyTipHotKeyVKey2 = 0;
+
/**
* @implemented
*/
@@ -346,11 +354,126 @@ TF_IsCtfmonRunning(VOID)
}
/**
- * @unimplemented
+ * @implemented
*/
-VOID InitLangChangeHotKey(VOID)
+BOOL InitLangChangeHotKey(VOID)
{
- //FIXME
+ CicRegKey regKey;
+ TCHAR szLanguage[2], szLayout[2];
+ LSTATUS error;
+
+ szLanguage[0] = szLayout[0] = TEXT('3');
+ szLanguage[1] = szLayout[1] = TEXT('\0');
+
+ error = regKey.Open(HKEY_CURRENT_USER, "Keyboard Layout\\Toggle");
+ if (error == ERROR_SUCCESS)
+ {
+ error = regKey.QuerySz(TEXT("Language Hotkey"), szLanguage,
_countof(szLanguage));
+ if (error != ERROR_SUCCESS)
+ {
+ if (g_dwOSInfo & CIC_OSINFO_NT)
+ {
+ error = regKey.QuerySz(TEXT("Hotkey"), szLanguage,
_countof(szLanguage));
+ if (error != ERROR_SUCCESS)
+ szLanguage[0] = TEXT('1');
+ }
+ else
+ {
+ error = regKey.QuerySz(NULL, szLanguage, _countof(szLanguage));
+ if (error != ERROR_SUCCESS)
+ szLanguage[0] = TEXT('1');
+ }
+
+ if (PRIMARYLANGID(GetSystemDefaultLCID()) == LANG_CHINESE)
+ szLanguage[0] = TEXT('1');
+ }
+
+ error = regKey.QuerySz(TEXT("Layout Hotkey"), szLayout,
_countof(szLayout));
+ if (error != ERROR_SUCCESS)
+ {
+ szLayout[0] = TEXT('1');
+ if (szLanguage[0] != TEXT('2'))
+ szLayout[0] = TEXT('2');
+ if (GetSystemMetrics(SM_MIDEASTENABLED))
+ szLayout[0] = TEXT('3');
+ }
+
+ szLanguage[1] = TEXT('\0');
+ szLayout[1] = TEXT('\0');
+ }
+
+ if (szLanguage[0] == szLayout[0])
+ {
+ if (szLanguage[0] == TEXT('1'))
+ szLayout[0] = TEXT('2');
+ else if (szLanguage[0] == TEXT('2'))
+ szLayout[0] = TEXT('1');
+ else
+ szLayout[0] = TEXT('3');
+ }
+
+ ::EnterCriticalSection(&g_csInDllMain);
+
+ switch (szLanguage[0])
+ {
+ case TEXT('2'):
+ g_uLangHotKeyModifiers = MOD_SHIFT | MOD_CONTROL;
+ g_uLangHotKeyVKey2 = VK_CONTROL;
+ g_uLangHotKeyVKey = VK_SHIFT;
+ break;
+
+ case TEXT('3'):
+ g_uLangHotKeyVKey = 0;
+ g_uLangHotKeyModifiers = 0;
+ g_uLangHotKeyVKey2 = 0;
+ break;
+
+ case TEXT('4'):
+ g_uLangHotKeyVKey = VK_NUMPAD0;
+ g_uLangHotKeyModifiers = 0;
+ g_uLangHotKeyVKey2 = 0;
+ break;
+
+ case TEXT('1'):
+ default:
+ g_uLangHotKeyModifiers = MOD_SHIFT | MOD_ALT;
+ g_uLangHotKeyVKey2 = VK_MENU;
+ g_uLangHotKeyVKey = VK_SHIFT;
+ break;
+ }
+
+ switch (szLayout[0])
+ {
+ case TEXT('2'):
+ g_uKeyTipHotKeyModifiers = MOD_SHIFT | MOD_CONTROL;
+ g_uKeyTipHotKeyVKey = VK_SHIFT;
+ g_uKeyTipHotKeyVKey2 = VK_CONTROL;
+ break;
+
+ case TEXT('3'):
+ g_uKeyTipHotKeyModifiers = 0;
+ g_uKeyTipHotKeyVKey = 0;
+ g_uKeyTipHotKeyVKey2 = 0;
+ break;
+
+ case TEXT('4'):
+ g_uKeyTipHotKeyModifiers = 0;
+ g_uKeyTipHotKeyVKey = VK_OEM_3;
+ g_uKeyTipHotKeyVKey2 = 0;
+ break;
+
+ case TEXT('1'):
+ default:
+ g_uKeyTipHotKeyModifiers = 0x40 | MOD_SHIFT;
+ g_uKeyTipHotKeyVKey = VK_SHIFT;
+ g_uKeyTipHotKeyVKey2 = VK_MENU;
+ break;
+ }
+
+ ::LeaveCriticalSection(&g_csInDllMain);
+
+ TRACE("HotKey: %c, %c\n", szLanguage[0], szLayout[0]);
+ return TRUE;
}
/**
@@ -408,6 +531,8 @@ BOOL ProcessAttach(HINSTANCE hinstDLL) // FIXME: Call me from DllMain
}
cicGetOSInfo(&g_uACP, &g_dwOSInfo);
+ TRACE("cicGetOSInfo: %u, 0x%lX\n", g_uACP, g_dwOSInfo);
+
InitUniqueString();
//FIXME
diff --git a/sdk/include/reactos/cicero/cicreg.h b/sdk/include/reactos/cicero/cicreg.h
index f6c090bef4e..ec3718da046 100644
--- a/sdk/include/reactos/cicero/cicreg.h
+++ b/sdk/include/reactos/cicero/cicreg.h
@@ -46,7 +46,7 @@ public:
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue,
sizeof(dwValue));
}
- LSTATUS QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax);
+ LSTATUS QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax);
LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue)
{
@@ -124,7 +124,7 @@ CicRegKey::Create(
}
inline LSTATUS
-CicRegKey::QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
+CicRegKey::QuerySz(LPCTSTR pszValueName, LPTSTR pszValue, DWORD cchValueMax)
{
DWORD cchSaveMax = cchValueMax;