diff --git a/server/src/ipc/event_listener.cpp b/server/src/ipc/event_listener.cpp index 4bf7d11c..442841db 100644 --- a/server/src/ipc/event_listener.cpp +++ b/server/src/ipc/event_listener.cpp @@ -108,16 +108,6 @@ void WorkerThread() break; } - // case TaskType::IMEActivation: { - // PostMessage(::global_hwnd, WM_IMEACTIVATE, 0, 0); - // break; - // } - - // case TaskType::IMEDeactivation: { - // PostMessage(::global_hwnd, WM_IMEDEACTIVATE, 0, 0); - // break; - // } - case TaskType::IMESwitch: { ::ReadDataFromNamedPipe(0b000001); PostMessage(::global_hwnd, WM_IMESWITCH, Global::Keycode, 0); diff --git a/server/src/webview2/windows_webview2.cpp b/server/src/webview2/windows_webview2.cpp index 312b936d..de4b173e 100644 --- a/server/src/webview2/windows_webview2.cpp +++ b/server/src/webview2/windows_webview2.cpp @@ -946,6 +946,45 @@ void UpdateFtbCnEnState(ComPtr webview, int cnEnState) script.append(L"document.getElementById('cn').style.display = 'none';"); script.append(L"document.getElementById('en').style.display = 'flex';"); + webview->ExecuteScript(script.c_str(), nullptr); + } +} + +/** + * @brief 更新 floating toolbar 窗口的中英文切换状态和标点切换状态 + * + * @param webview + * @param cnEnState 1: 中文, 0: 英文 + */ +void UpdateFtbCnEnAndPuncState(ComPtr webview, int cnEnState) +{ + if (webview == nullptr) + { + return; + } + + if (cnEnState == 1) + { + std::wstring script; + script.reserve(256); + + script.append(L"document.getElementById('cn').style.display = 'flex';"); + script.append(L"document.getElementById('en').style.display = 'none';"); + script.append(L"document.getElementById('puncCn').style.display = 'flex';"); + script.append(L"document.getElementById('puncEn').style.display = 'none';"); + + webview->ExecuteScript(script.c_str(), nullptr); + } + else if (cnEnState == 0) + { + std::wstring script; + script.reserve(256); + + script.append(L"document.getElementById('cn').style.display = 'none';"); + script.append(L"document.getElementById('en').style.display = 'flex';"); + script.append(L"document.getElementById('puncCn').style.display = 'none';"); + script.append(L"document.getElementById('puncEn').style.display = 'flex';"); + webview->ExecuteScript(script.c_str(), nullptr); } } \ No newline at end of file diff --git a/server/src/webview2/windows_webview2.h b/server/src/webview2/windows_webview2.h index d256987b..d84b4d99 100644 --- a/server/src/webview2/windows_webview2.h +++ b/server/src/webview2/windows_webview2.h @@ -82,4 +82,5 @@ inline ComPtr webviewController2FtbWnd; inline std::wstring HTMLStringFtbWnd = LR"()"; void InitWebviewFtbWnd(HWND hwnd); -void UpdateFtbCnEnState(ComPtr webview, int cnEnState); \ No newline at end of file +void UpdateFtbCnEnState(ComPtr webview, int cnEnState); +void UpdateFtbCnEnAndPuncState(ComPtr webview, int cnEnState); \ No newline at end of file diff --git a/server/src/window/ime_windows.cpp b/server/src/window/ime_windows.cpp index 00325d97..4a0b67f3 100644 --- a/server/src/window/ime_windows.cpp +++ b/server/src/window/ime_windows.cpp @@ -393,11 +393,13 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA { if (wParam == 0) // 此时是英文状态 { - UpdateFtbCnEnState(::webviewFtbWnd, 0); // 更新 floating toolbar 的中英文状态为英文 + /* 更新 floating toolbar 的中英文状态为英文,同时更新标点的全角和半角状态 */ + UpdateFtbCnEnAndPuncState(::webviewFtbWnd, 0); } else // 此时是中文状态 { - UpdateFtbCnEnState(::webviewFtbWnd, 1); // 更新 floating toolbar 的中英文状态为中文 + /* 更新 floating toolbar 的中英文状态为中文,同时更新标点的全角和半角状态 */ + UpdateFtbCnEnAndPuncState(::webviewFtbWnd, 1); } return 0; }