diff --git a/server/MetasequoiaImeEngine b/server/MetasequoiaImeEngine index b028f8c6..acd6e600 160000 --- a/server/MetasequoiaImeEngine +++ b/server/MetasequoiaImeEngine @@ -1 +1 @@ -Subproject commit b028f8c6fc84f899a815b6c8bb046af826faa2eb +Subproject commit acd6e600e8b23d39e30a0fbf57c07709fc527c60 diff --git a/server/src/ai/ai_assistant.cpp b/server/src/ai/ai_assistant.cpp index 28990189..814d74d4 100644 --- a/server/src/ai/ai_assistant.cpp +++ b/server/src/ai/ai_assistant.cpp @@ -43,12 +43,7 @@ std::string Fetch(const AiAssistant::Request &request, uint64_t generation) if (!config.enabled || config.token.empty() || config.endpoint.empty() || config.model.empty() || request.pinyin_segments.empty() || g_generation.load() != generation) { - OutputDebugStringA(fmt::format("[ai-assistant] request skipped: enabled={}, token_configured={}, " - "endpoint_configured={}, model_configured={}, segment_count={}, " - "generation_current={}\n", - config.enabled, !config.token.empty(), !config.endpoint.empty(), - !config.model.empty(), request.pinyin_segments.size(), - g_generation.load() == generation).c_str()); + (void)0; return {}; } @@ -70,11 +65,7 @@ std::string Fetch(const AiAssistant::Request &request, uint64_t generation) } // Deliberately exclude API token and system prompt from logs. - OutputDebugStringA(fmt::format("[ai-assistant] sending request: generation={}, provider={}, endpoint={}, " - "model={}, pinyin={}, context={}, candidate_limit={}\n", - generation, config.provider, config.endpoint, config.model, - nlohmann::json(request.pinyin_segments).dump(), - nlohmann::json(request.context).dump(), config.candidate_limit).c_str()); + (void)0; CURL *curl = curl_easy_init(); if (!curl) return {}; @@ -98,18 +89,15 @@ std::string Fetch(const AiAssistant::Request &request, uint64_t generation) curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(curl); - OutputDebugStringA(fmt::format("[ai-assistant] response: generation={}, curl_code={}, http_status={}, body={}\n", - generation, static_cast(result), status, response).c_str()); + (void)0; if (result != CURLE_OK || status < 200 || status >= 300) { - OutputDebugStringA(fmt::format("[ai-assistant] request failed: generation={}, curl_error={}, " - "http_status={}\n", generation, curl_easy_strerror(result), status).c_str()); + (void)0; return {}; } if (g_generation.load() != generation) { - OutputDebugStringA(fmt::format("[ai-assistant] response discarded as stale: response_generation={}, " - "current_generation={}\n", generation, g_generation.load()).c_str()); + (void)0; return {}; } @@ -121,19 +109,16 @@ std::string Fetch(const AiAssistant::Request &request, uint64_t generation) const auto &candidates = result_json.at("candidates"); if (!candidates.is_array() || candidates.empty()) { - OutputDebugStringA(fmt::format("[ai-assistant] parsed an empty candidate list: generation={}\n", - generation).c_str()); + (void)0; return {}; } const std::string candidate = candidates.at(0).value("text", std::string{}); - OutputDebugStringA(fmt::format("[ai-assistant] parsed best candidate: generation={}, candidate={}\n", - generation, candidate).c_str()); + (void)0; return candidate; } catch (const std::exception &error) { - OutputDebugStringA(fmt::format("[ai-assistant] response parse failed: generation={}, error={}\n", - generation, error.what()).c_str()); + (void)0; return {}; } } @@ -154,9 +139,7 @@ void WorkerLoop() const std::string candidate = cached->second; const uint64_t cached_generation = observed; lock.unlock(); - OutputDebugStringA(fmt::format("[ai-assistant] cache hit: generation={}, pinyin={}, candidate={}\n", - cached_generation, - nlohmann::json(request.pinyin_segments).dump(), candidate).c_str()); + (void)0; if (g_running && g_generation.load() == cached_generation && g_callback) g_callback(candidate, request.identity, cached_generation); continue; @@ -178,9 +161,7 @@ void WorkerLoop() std::lock_guard cache_lock(g_mutex); g_candidate_cache[BuildCacheKey(request)] = candidate; } - OutputDebugStringA(fmt::format("[ai-assistant] cache stored: generation={}, pinyin={}, candidate={}\n", - observed, nlohmann::json(request.pinyin_segments).dump(), - candidate).c_str()); + (void)0; g_callback(candidate, request.identity, observed); } } @@ -209,9 +190,7 @@ void Stop() void OnInputChanged(Request request) { { std::lock_guard lock(g_mutex); g_latest = std::move(request); g_last_input = std::chrono::steady_clock::now(); ++g_generation; - OutputDebugStringA(fmt::format("[ai-assistant] input updated: generation={}, identity={}, segment_count={}\n", - g_generation.load(), g_latest.identity, - g_latest.pinyin_segments.size()).c_str()); } + (void)0; } g_cv.notify_one(); } void Clear() { OnInputChanged({}); } diff --git a/server/src/cloud/cloud_ime.cpp b/server/src/cloud/cloud_ime.cpp index 33834c6d..4e9c6fb7 100644 --- a/server/src/cloud/cloud_ime.cpp +++ b/server/src/cloud/cloud_ime.cpp @@ -161,16 +161,16 @@ std::string FetchCloudCandidate(const std::string &pinyin, uint64_t generation) std::string response; if (!HttpGet(L"inputtools.google.com", path, response)) { - OutputDebugString(fmt::format(L"[msime]: 请求云输入法失败").c_str()); + (void)0; return ""; } if (!g_running || g_generation.load() != generation) return ""; - // OutputDebugString(fmt::format(L"[msime]: cloud response: {}", string_to_wstring(response)).c_str()); + // (void)0; std::string candidate = ParseCandidate(response); - // OutputDebugString(fmt::format(L"[msime]: cloud candidate: {}", string_to_wstring(candidate)).c_str()); + // (void)0; return candidate; } diff --git a/server/src/config/ime_config.cpp b/server/src/config/ime_config.cpp index 9590d061..322a98d2 100644 --- a/server/src/config/ime_config.cpp +++ b/server/src/config/ime_config.cpp @@ -340,7 +340,7 @@ bool LoadImeConfig() catch (const toml::parse_error &) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: TOML parse error\n"); + (void)0; #endif return false; } @@ -420,7 +420,7 @@ void MigrateLegacyVoiceInputConfig() catch (const toml::parse_error &) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Legacy voice input config migration skipped: TOML parse error\n"); + (void)0; #endif } } @@ -451,17 +451,16 @@ void InitImeConfig() { MigrateLegacyVoiceInputConfig(); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: session_backend = {}", string_to_wstring(g_session_backend)).c_str()); + (void)0; #endif #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: shuangpin_preedit_mode = {}", string_to_wstring(g_shuangpin_preedit_mode)).c_str()); + (void)0; #endif #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: shuangpin_helpcode = {}", g_shuangpin_helpcode_enabled).c_str()); + (void)0; #endif #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: quanpin_helpcode = {}", g_quanpin_helpcode_enabled).c_str()); + (void)0; #endif } } diff --git a/server/src/ipc/event_listener.cpp b/server/src/ipc/event_listener.cpp index f1252e6a..545fefd2 100644 --- a/server/src/ipc/event_listener.cpp +++ b/server/src/ipc/event_listener.cpp @@ -37,15 +37,9 @@ #include "unicode/unicode_query.h" #include -#ifdef FANY_IPC_DEBUG -#define FANY_IPC_LOG_RAW(message) OutputDebugString(message) -#define FANY_IPC_LOGW(message) OutputDebugString((message).c_str()) -#define FANY_IPC_LOGF(...) OutputDebugString(fmt::format(__VA_ARGS__).c_str()) -#else #define FANY_IPC_LOG_RAW(message) ((void)0) #define FANY_IPC_LOGW(message) ((void)0) #define FANY_IPC_LOGF(...) ((void)0) -#endif namespace { @@ -223,11 +217,7 @@ void UpdateAiInput(const std::string &identity, uint64_t client_id = 0, uint64_t const AiAssistantConfig config = GetConfiguredAiAssistant(); const bool usable = config.enabled && g_inputSession && g_inputSession->current_scheme_type() != SchemeType::Wubi && g_inputSession->is_all_complete_pure_pinyin() && !identity.empty(); - OutputDebugStringA(fmt::format("[ai-assistant] trigger check: enabled={}, scheme={}, complete={}, " - "identity={}, usable={}\n", config.enabled, - g_inputSession ? static_cast(g_inputSession->current_scheme_type()) : -1, - g_inputSession && g_inputSession->is_all_complete_pure_pinyin(), identity, - usable).c_str()); + (void)0; AiAssistant::Request request; if (usable) { @@ -1295,7 +1285,7 @@ void EventListenerLoopThread() while (pipe_running) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Main pipe starts to wait"); + (void)0; #endif if (!listeningPipe || listeningPipe == INVALID_HANDLE_VALUE) { @@ -1567,7 +1557,7 @@ void ToTsfPipeEventListenerLoopThread() while (pipe_running) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: ToTsf Pipe starts to wait"); + (void)0; #endif if (!listeningPipe || listeningPipe == INVALID_HANDLE_VALUE) { @@ -1582,7 +1572,7 @@ void ToTsfPipeEventListenerLoopThread() BOOL connected = WaitForPipeClient(listeningPipe); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: ToTsf Pipe connected: {}", connected).c_str()); + (void)0; #endif LogPipeConnectResult(L"to-tsf-pipe", connected); if (connected) @@ -1636,7 +1626,7 @@ void ToTsfWorkerThreadPipeEventListenerLoopThread() while (pipe_running) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: ToTsf Worker Thread Pipe starts to wait"); + (void)0; #endif if (!listeningPipe || listeningPipe == INVALID_HANDLE_VALUE) { @@ -1655,7 +1645,7 @@ void ToTsfWorkerThreadPipeEventListenerLoopThread() if (connected) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: ToTsf Worker Thread Pipe connected: {}", connected).c_str()); + (void)0; #endif if (!pipe_running) { @@ -1965,12 +1955,7 @@ void ApplyAiCandidate(const std::string &candidate, const std::string &identity, if (!enabled || candidate.empty() || !has_session || wubi || !complete || GlobalIme::composition.creating_word.active || current_identity != identity) { - OutputDebugStringA(fmt::format("[ai-assistant] candidate rejected: generation={}, enabled={}, " - "candidate_empty={}, has_session={}, wubi={}, complete={}, creating_word={}, " - "requested_identity={}, current_identity={}\n", generation, enabled, - candidate.empty(), has_session, wubi, complete, - GlobalIme::composition.creating_word.active, identity, - current_identity).c_str()); + (void)0; return; } auto &items = Global::candidate_ui.items; @@ -1980,8 +1965,7 @@ void ApplyAiCandidate(const std::string &candidate, const std::string &identity, if (std::any_of(items.begin(), items.end(), [&](const WordItem &item) { return item.word == candidate; })) { Global::ai_candidate = {true, candidate, query.committed_pinyin}; - OutputDebugStringA(fmt::format("[ai-assistant] candidate skipped as duplicate: generation={}, candidate={}\n", - generation, candidate).c_str()); + (void)0; return; } @@ -1992,8 +1976,7 @@ void ApplyAiCandidate(const std::string &candidate, const std::string &identity, const size_t insert_index = std::min(2, items.size()); items.insert(items.begin() + insert_index, WordItem(identity, candidate, 1, CandidateSource::AiSuggestion)); g_inputSession->cache_dynamic_candidate(query.cache_key, candidate, CandidateSource::AiSuggestion); - OutputDebugStringA(fmt::format("[ai-assistant] candidate inserted: generation={}, index={}, candidate={}, " - "identity={}\n", generation, insert_index + 1, candidate, identity).c_str()); + (void)0; Global::ai_candidate = {true, candidate, query.committed_pinyin}; Global::candidate_ui.item_total_count = static_cast(items.size()); Global::candidate_ui.page_index = 0; @@ -2436,10 +2419,7 @@ void ProcessSelectionKey(UINT keycode, uint64_t client_id, uint64_t activation_e if (creating_word_progress.completed) { /* 最终的造词 */ #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: create_word 造词:{} {}", - string_to_wstring(GlobalIme::composition.creating_word.word), - string_to_wstring(GlobalIme::composition.creating_word.pinyin)) - .c_str()); + (void)0; #endif /* 更新一下被选中的候选项 */ diff --git a/server/src/ipc/ipc.cpp b/server/src/ipc/ipc.cpp index 56ee5a24..0a335926 100644 --- a/server/src/ipc/ipc.cpp +++ b/server/src/ipc/ipc.cpp @@ -24,13 +24,8 @@ #include "utils/common_utils.h" #include "fmt/xchar.h" -#ifdef FANY_IPC_DEBUG -#define FANY_IPC_LOG_RAW(message) OutputDebugString(message) -#define FANY_IPC_LOGF(...) OutputDebugString(fmt::format(__VA_ARGS__).c_str()) -#else #define FANY_IPC_LOG_RAW(message) ((void)0) #define FANY_IPC_LOGF(...) ((void)0) -#endif #define LOW_INTEGRITY_SDDL_SACL \ SDDL_SACL \ @@ -367,7 +362,7 @@ int InitIpc() if (!hMapFile || !pBuf) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Shared-memory IPC unavailable: {}", GetLastError()).c_str()); + (void)0; #endif canUseSharedMemory = false; pBuf = nullptr; @@ -405,7 +400,7 @@ int InitIpc() { // Error handling #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to create event: {}", FANY_IME_EVENT_ARRAY[i]).c_str()); + (void)0; #endif } } @@ -463,14 +458,14 @@ int InitNamedPipe() if (hPipe == INVALID_HANDLE_VALUE) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: CreateNamedPipe failed: {}", GetLastError()).c_str()); + (void)0; #endif FANY_IPC_LOGF(L"[msime]: [ipc] CreateNamedPipe failed for main pipe: gle={}", GetLastError()); } else { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Named pipe created successfully"); + (void)0; #endif FANY_IPC_LOG_RAW(L"[msime]: [ipc] Main named pipe created"); } @@ -478,14 +473,14 @@ int InitNamedPipe() if (hAuxPipe == INVALID_HANDLE_VALUE) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: CreateNamedPipe aux pipe failed: {}", GetLastError()).c_str()); + (void)0; #endif FANY_IPC_LOGF(L"[msime]: [ipc] CreateNamedPipe failed for aux pipe: gle={}", GetLastError()); } else { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Named pipe aux pipe created successfully"); + (void)0; #endif FANY_IPC_LOG_RAW(L"[msime]: [ipc] Aux named pipe created"); } @@ -493,14 +488,14 @@ int InitNamedPipe() if (hToTsfPipe == INVALID_HANDLE_VALUE) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: CreateNamedPipe to tsf pipe failed: {}", GetLastError()).c_str()); + (void)0; #endif FANY_IPC_LOGF(L"[msime]: [ipc] CreateNamedPipe failed for to-tsf pipe: gle={}", GetLastError()); } else { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Named pipe to tsf pipe created successfully"); + (void)0; #endif FANY_IPC_LOG_RAW(L"[msime]: [ipc] To-tsf named pipe created"); } @@ -508,14 +503,14 @@ int InitNamedPipe() if (hToTsfWorkerThreadPipe == INVALID_HANDLE_VALUE) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"CreateNamedPipe to tsf worker thread pipe failed: {}", GetLastError()).c_str()); + (void)0; #endif FANY_IPC_LOGF(L"[msime]: [ipc] CreateNamedPipe failed for to-tsf-worker pipe: gle={}", GetLastError()); } else { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Named pipe to tsf worker thread pipe created successfully"); + (void)0; #endif FANY_IPC_LOG_RAW(L"[msime]: [ipc] To-tsf-worker named pipe created"); } @@ -535,7 +530,7 @@ int InitNamedPipe() { // Error handling #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Create Event To TSF failed: {}", GetLastError()).c_str()); + (void)0; #endif } } @@ -552,8 +547,7 @@ int InitNamedPipe() { // Error handling #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Create Event To TSF Worker Thread failed: {}", GetLastError()).c_str()); + (void)0; #endif } } @@ -1350,7 +1344,7 @@ bool SendToTsfClientViaNamedpipe(uint64_t client_id, uint64_t activation_epoch, if (!endpoint) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: SendToTsfViaNamedpipe Pipe disconnected"); + (void)0; #endif LogPipeDisconnected(L"to-tsf", msg_type); return false; @@ -1358,9 +1352,7 @@ bool SendToTsfClientViaNamedpipe(uint64_t client_id, uint64_t activation_epoch, if (!write_succeeded) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: SendToTsfViaNamedpipe: WriteFile failed, gle={}, written={}", - write_error, bytes_written) - .c_str()); + (void)0; #endif LogPipeWriteFailure(L"to-tsf", msg_type, write_error, bytes_written, sizeof(packet)); if (failed_endpoint_removed) @@ -1430,7 +1422,7 @@ bool SendWorkerPacket(uint64_t client_id, uint64_t activation_epoch, bool requir if (!endpoint) { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: SendToTsfWorkerThreadViaNamedpipe Pipe disconnected"); + (void)0; #endif LogPipeDisconnected(L"to-tsf-worker", msg_type); return false; @@ -1438,10 +1430,7 @@ bool SendWorkerPacket(uint64_t client_id, uint64_t activation_epoch, bool requir if (!write_succeeded) { #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: SendToTsfWorkerThreadViaNamedpipe: WriteFile failed, gle={}, written={}", - write_error, bytes_written) - .c_str()); + (void)0; #endif LogPipeWriteFailure(L"to-tsf-worker", msg_type, write_error, bytes_written, sizeof(packet)); if (failed_endpoint_removed) diff --git a/server/src/log/fanylog.cpp b/server/src/log/fanylog.cpp index 41088c71..6ac05517 100644 --- a/server/src/log/fanylog.cpp +++ b/server/src/log/fanylog.cpp @@ -1,12 +1,6 @@ #include "fanylog.h" -#include "spdlog/spdlog.h" int InitializeSpdLog() { - spdlog::set_default_logger(::logger); - spdlog::flush_on(spdlog::level::info); -#ifdef FANY_DEBUG - spdlog::info("FanyLog initialized."); -#endif return 0; } diff --git a/server/src/log/fanylog.h b/server/src/log/fanylog.h index 129839f7..0f4d3002 100644 --- a/server/src/log/fanylog.h +++ b/server/src/log/fanylog.h @@ -1,17 +1,3 @@ #pragma once -#include "spdlog/spdlog.h" -#include -#include -#include -#include "utils/common_utils.h" -#include "global/globals.h" - -inline std::string LogFilePath = fmt::format( // - "C:/Users/{}/AppData/Local/metasequoiaime/log/{}.log", // - CommonUtils::get_username(), // - wstring_to_string(GlobalIme::ServerName) // -); -inline auto logger = spdlog::basic_logger_mt("file_logger", ::LogFilePath); - -int InitializeSpdLog(); \ No newline at end of file +int InitializeSpdLog(); diff --git a/server/src/main.cpp b/server/src/main.cpp index 0b4df766..273e9345 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -67,13 +67,12 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In CommonUtils::SingleInstanceGuard single_instance(L"Local\\MetasequoiaImeServer_SingleInstance"); if (!single_instance.is_valid()) { - OutputDebugString(fmt::format(L"[msime]: Failed to create single instance mutex.").c_str()); + (void)0; return 0; } if (single_instance.already_running()) { - OutputDebugString( - fmt::format(L"[msime]: Single instance already exists, MetasequoiaImeServer is already running.").c_str()); + (void)0; return 0; } @@ -84,10 +83,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In const HRESULT comResult = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (FAILED(comResult)) { - OutputDebugString( - fmt::format(L"[msime]: Failed to initialize the UI COM STA: 0x{:08X}", - static_cast(comResult)) - .c_str()); + (void)0; return 1; } @@ -110,9 +106,9 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In "Input session backend configured={}, effective={}, scheme={}", configured_backend.empty() ? "legacy" : configured_backend, effective_backend, SchemeTypeToString(g_inputSession->current_scheme_type())); - spdlog::info(session_summary); + (void)0; #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: {}", string_to_wstring(session_summary)).c_str()); + (void)0; #endif RegisterCandidateWindowMessage(); diff --git a/server/src/sciter/candidate_window_sciter.cpp b/server/src/sciter/candidate_window_sciter.cpp index 57723538..7b65bb2f 100644 --- a/server/src/sciter/candidate_window_sciter.cpp +++ b/server/src/sciter/candidate_window_sciter.cpp @@ -57,7 +57,7 @@ int PrepareCandidateWindowSciterHtml() std::wstring bodyPath = bodyHtml; ::BodyString = ReadHtmlFile(bodyPath); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: bodyPath = {}", bodyPath).c_str()); + (void)0; #endif return 0; @@ -179,7 +179,7 @@ void SciterBridgeJs::adjustInitialWindowSize(sciter::value width, sciter::value realHeight = height.get(); } #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Candidate Window size: {} {}", realWidth, realHeight).c_str()); + (void)0; #endif // TODO: Adjust window size ::CANDIDATE_WINDOW_WIDTH = realWidth; diff --git a/server/src/utils/webview_utils.cpp b/server/src/utils/webview_utils.cpp index 8982645c..f35426d5 100644 --- a/server/src/utils/webview_utils.cpp +++ b/server/src/utils/webview_utils.cpp @@ -20,7 +20,7 @@ void MeasureDomUpdateTime(ComPtr webview) auto duration = std::chrono::duration_cast(end - start); std::wstring message = L"DOM update time: " + std::to_wstring(duration.count()) + L" μs"; - spdlog::info(wstring_to_string(message)); + (void)0; } std::pair ParseDivSize(const std::wstring &jsonResult) @@ -45,8 +45,7 @@ std::pair ParseDivSize(const std::wstring &jsonResult) } catch (const std::exception &e) { - OutputDebugStringW(fmt::format(L"[msime-webview] candidate DOM size parse failed: result='{}', error='{}'\n", - jsonResult, string_to_wstring(e.what())).c_str()); + (void)0; } return size; } @@ -55,7 +54,7 @@ void GetContainerSizeCand(ComPtr webview, std::function webview, std::function(errorCode), result != nullptr).c_str()); + (void)0; } callback(size); return S_OK; }).Get()); - OutputDebugStringW(fmt::format(L"[msime-webview] candidate DOM measurement submitted: hr=0x{:08X}\n", - static_cast(submitHr)).c_str()); + (void)0; } void GetContainerSizeMenu(ComPtr webview, std::function)> callback) @@ -115,8 +109,7 @@ void GetContainerSizeMenu(ComPtr webview, std::function webview, int marginTop) script.append(L"px';"); script.append(L"}"); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: script: {}", script).c_str()); + (void)0; #endif webview->ExecuteScript(script.c_str(), nullptr); } diff --git a/server/src/webview2/windows_webview2.cpp b/server/src/webview2/windows_webview2.cpp index 4fed7ece..9833f4f4 100644 --- a/server/src/webview2/windows_webview2.cpp +++ b/server/src/webview2/windows_webview2.cpp @@ -42,7 +42,7 @@ ComPtr smallWindowWebviewEnvironment; void WebviewDebugLog(const std::wstring &message) { - OutputDebugStringW(fmt::format(L"[msime-webview] {}\n", message).c_str()); + (void)0; } struct FloatingToolbarState @@ -77,17 +77,12 @@ void ResetSmallWindowTopmostGate() floatingToolbarNavigationReady = false; smallWindowTopmostRequested = false; smallWindowTopmostApplied = false; - WebviewDebugLog(L"ready-gate reset"); + (void)0; } void LogSmallWindowReadyGateUnlocked(const wchar_t *context) { - WebviewDebugLog(fmt::format( - L"ready-gate [{}]: cand_nav={}, menu_nav={}, ftb_nav={}, topmost_requested={}, topmost_applied={}, " - L"controllers={{cand:{},menu:{},ftb:{}}}", - context ? context : L"?", candidateNavigationReady, menuNavigationReady, floatingToolbarNavigationReady, - smallWindowTopmostRequested, smallWindowTopmostApplied, webviewControllerCandWnd != nullptr, - webviewControllerMenuWnd != nullptr, webviewControllerFtbWnd != nullptr)); + (void)0; } void ApplyLazyTopmostUnlocked(const wchar_t *reason) @@ -96,18 +91,14 @@ void ApplyLazyTopmostUnlocked(const wchar_t *reason) auto pinOne = [flag](HWND hwnd, const wchar_t *name) { if (!hwnd) { - WebviewDebugLog(fmt::format(L"lazy topmost skip {}: hwnd=null", name)); + (void)0; return; } SetLastError(0); const BOOL ok = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, flag); RECT rect{}; GetWindowRect(hwnd, &rect); - WebviewDebugLog(fmt::format( - L"lazy topmost {}: hwnd=0x{:X}, SetWindowPos={}, GetLastError={}, visible={}, " - L"rect=[{},{},{},{}]", - name, reinterpret_cast(hwnd), ok != FALSE, ok ? 0 : GetLastError(), - IsWindowVisible(hwnd) != FALSE, rect.left, rect.top, rect.right, rect.bottom)); + (void)0; }; smallWindowTopmostApplied = true; @@ -116,8 +107,7 @@ void ApplyLazyTopmostUnlocked(const wchar_t *reason) // last so the idle toolbar stays discoverable above other small windows. const bool menu_visible = ::global_hwnd_menu != nullptr && IsWindowVisible(::global_hwnd_menu) != FALSE; - WebviewDebugLog(fmt::format(L"lazy topmost apply: reason={}, menu_visible={}", - reason ? reason : L"?", menu_visible)); + (void)0; pinOne(::global_hwnd, L"candidate"); if (menu_visible) { @@ -147,7 +137,7 @@ void TryApplyPendingLazyTopmost(const wchar_t *reason) ApplyLazyTopmostUnlocked(reason); if (::is_global_wnd_cand_shown && ::global_hwnd) { - WebviewDebugLog(L"lazy topmost follow-up: FineTuneWindow for pending candidate show"); + (void)0; FineTuneWindow(::global_hwnd); } if (::global_hwnd_menu && IsWindowVisible(::global_hwnd_menu)) @@ -160,12 +150,12 @@ void TryApplyPendingLazyTopmost(const wchar_t *reason) webviewControllerMenuWnd->put_Bounds(bounds); webviewControllerMenuWnd->NotifyParentWindowPositionChanged(); } - WebviewDebugLog(L"lazy topmost follow-up: refresh visible menu webview"); + (void)0; } if (::global_hwnd_ftb && IsWindowVisible(::global_hwnd_ftb)) { UpdateSmallWindowWebviewVisibility(::global_hwnd_ftb, true); - WebviewDebugLog(L"lazy topmost follow-up: refresh visible floating-toolbar webview"); + (void)0; } } @@ -173,11 +163,11 @@ void NotifySmallWindowNavigationReady(bool &readyFlag, const wchar_t *which) { if (readyFlag) { - WebviewDebugLog(fmt::format(L"small-window navigation ready ignored (duplicate): {}", which)); + (void)0; return; } readyFlag = true; - WebviewDebugLog(fmt::format(L"small-window navigation ready: {}", which)); + (void)0; LogSmallWindowReadyGateUnlocked(L"after-nav-ready"); TryApplyPendingLazyTopmost(L"pending-after-nav-ready"); } @@ -271,8 +261,7 @@ bool EnsureSmallWindowsTopmost(const wchar_t *reason) } if (!AreSmallWindowWebviewsReadyUnlocked()) { - WebviewDebugLog(fmt::format(L"lazy topmost deferred until webviews ready: reason={}", - reason ? reason : L"?")); + (void)0; LogSmallWindowReadyGateUnlocked(L"topmost-deferred"); return false; } @@ -293,10 +282,7 @@ void RaiseTrayMenuAboveSmallWindows(const wchar_t *reason) constexpr UINT flag = SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE; SetLastError(0); const BOOL ok = SetWindowPos(::global_hwnd_menu, HWND_TOPMOST, 0, 0, 0, 0, flag); - WebviewDebugLog(fmt::format( - L"raise tray menu above peers: reason={}, hwnd=0x{:X}, SetWindowPos={}, GetLastError={}, visible={}", - reason ? reason : L"?", reinterpret_cast(::global_hwnd_menu), ok != FALSE, - ok ? 0 : GetLastError(), IsWindowVisible(::global_hwnd_menu) != FALSE)); + (void)0; } bool AreSmallWindowsTopmostApplied() @@ -345,21 +331,18 @@ void UpdateSmallWindowWebviewVisibility(HWND hwnd, bool visible) } else { - WebviewDebugLog(fmt::format(L"visibility ignored: unknown hwnd=0x{:X}", - reinterpret_cast(hwnd))); + (void)0; return; } if (controller) { const HRESULT hr = controller->put_IsVisible(visible ? TRUE : FALSE); - WebviewDebugLog(fmt::format(L"controller visibility: hwnd=0x{:X}, visible={}, hr=0x{:08X}", - reinterpret_cast(hwnd), visible, static_cast(hr))); + (void)0; } else { - WebviewDebugLog(fmt::format(L"controller visibility deferred: hwnd=0x{:X}, visible={}, controller=null", - reinterpret_cast(hwnd), visible)); + (void)0; } if (lowerMemoryWhenHidden) @@ -375,7 +358,7 @@ std::wstring ReadHtmlFile(const std::wstring &filePath) std::wifstream file(filePath); if (!file) { - WebviewDebugLog(fmt::format(L"HTML read failed: path='{}', GetLastError={}", filePath, GetLastError())); + (void)0; return L""; } // Use Boost Locale to handle UTF-8 @@ -383,7 +366,7 @@ std::wstring ReadHtmlFile(const std::wstring &filePath) std::wstringstream buffer; buffer << file.rdbuf(); std::wstring content = buffer.str(); - WebviewDebugLog(fmt::format(L"HTML read succeeded: path='{}', chars={}", filePath, content.size())); + (void)0; return content; } @@ -511,9 +494,7 @@ int PrepareHtmlForWnds() ::BodyStringCandWnd = ReadHtmlFile(bodyHtmlPathCandWnd); std::wstring measureHtmlPathCandWnd = assetPath + measureHtmlCandWnd; ::MeasureStringCandWnd = ReadHtmlFile(measureHtmlPathCandWnd); - WebviewDebugLog(fmt::format(L"candidate assets prepared: layout={}, theme={}, page_chars={}, body_chars={}, measure_chars={}", - isHorizontal ? L"horizontal" : L"vertical", candThemeSuffix, HTMLStringCandWnd.size(), - BodyStringCandWnd.size(), MeasureStringCandWnd.size())); + (void)0; // // 托盘语言区菜单窗口 @@ -735,9 +716,7 @@ HRESULT OnControllerCreatedCandWnd( // ICoreWebView2Controller *controller // ) { - WebviewDebugLog(fmt::format(L"candidate controller callback: hwnd=0x{:X}, result=0x{:08X}, controller={}", - reinterpret_cast(hwnd), static_cast(result), - controller != nullptr)); + (void)0; if (!controller || FAILED(result)) { ShowErrorMessage(hwnd, L"Failed to create WebView2 controller."); @@ -746,8 +725,7 @@ HRESULT OnControllerCreatedCandWnd( // webviewControllerCandWnd = controller; const HRESULT getWebviewHr = webviewControllerCandWnd->get_CoreWebView2(webviewCandWnd.GetAddressOf()); - WebviewDebugLog(fmt::format(L"get candidate CoreWebView2: hr=0x{:08X}, webview={}", - static_cast(getWebviewHr), webviewCandWnd != nullptr)); + (void)0; if (!webviewCandWnd) { @@ -811,8 +789,7 @@ HRESULT OnControllerCreatedCandWnd( // assetPath.c_str(), // COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY_CORS // ); // - WebviewDebugLog(fmt::format(L"candidate virtual host mapping: folder='{}', hr=0x{:08X}", assetPath, - static_cast(mappingHr))); + (void)0; } // Set transparent background @@ -830,13 +807,11 @@ HRESULT OnControllerCreatedCandWnd( // bounds.right += candidateBoundRightExtra; bounds.bottom += candidateBoundBottomExtra; const HRESULT boundsHr = webviewControllerCandWnd->put_Bounds(bounds); - WebviewDebugLog(fmt::format(L"candidate initial bounds: [{},{},{},{}], hr=0x{:08X}", bounds.left, bounds.top, - bounds.right, bounds.bottom, static_cast(boundsHr))); + (void)0; // Navigate to HTML HRESULT hr = webviewCandWnd->NavigateToString(HTMLStringCandWnd.c_str()); - WebviewDebugLog(fmt::format(L"candidate NavigateToString submitted: html_chars={}, hr=0x{:08X}", - HTMLStringCandWnd.size(), static_cast(hr))); + (void)0; if (FAILED(hr)) { ShowErrorMessage(hwnd, L"Failed to navigate to string."); @@ -887,8 +862,7 @@ HRESULT OnControllerCreatedCandWnd( // catch (const std::exception &e) { #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Exception happens when parsing cand wnd webview2 message").c_str()); + (void)0; #endif return S_OK; } @@ -905,20 +879,14 @@ HRESULT OnControllerCreatedCandWnd( // COREWEBVIEW2_WEB_ERROR_STATUS errorStatus = COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN; const HRESULT successHr = args->get_IsSuccess(&success); const HRESULT statusHr = args->get_WebErrorStatus(&errorStatus); - WebviewDebugLog(fmt::format( - L"candidate navigation completed: success={}, shown={}, isSuccess_hr=0x{:08X}, " - L"status_hr=0x{:08X}, web_error={}", - success != FALSE, ::is_global_wnd_cand_shown, static_cast(successHr), - static_cast(statusHr), static_cast(errorStatus))); + (void)0; if (success) { NotifySmallWindowNavigationReady(candidateNavigationReady, L"candidate"); } else { - WebviewDebugLog(fmt::format( - L"candidate navigation failed: web_error={}, shown={}, topmost_applied={}", - static_cast(errorStatus), ::is_global_wnd_cand_shown, smallWindowTopmostApplied)); + (void)0; } if (success && ::is_global_wnd_cand_shown) { @@ -939,8 +907,7 @@ HRESULT OnControllerCreatedCandWnd( // [](ICoreWebView2 *, ICoreWebView2ProcessFailedEventArgs *args) -> HRESULT { COREWEBVIEW2_PROCESS_FAILED_KIND kind = COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED; const HRESULT hr = args->get_ProcessFailedKind(&kind); - WebviewDebugLog(fmt::format(L"candidate WebView2 process failed: kind={}, hr=0x{:08X}", - static_cast(kind), static_cast(hr))); + (void)0; return S_OK; }).Get(), nullptr); @@ -958,8 +925,7 @@ HRESULT OnControllerCreatedCandWnd( // */ HRESULT OnEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2Environment *env) { - WebviewDebugLog(fmt::format(L"candidate environment dispatch: hwnd=0x{:X}, result=0x{:08X}, env={}", - reinterpret_cast(hwnd), static_cast(result), env != nullptr)); + (void)0; if (FAILED(result) || !env) { ShowErrorMessage(hwnd, L"Failed to create WebView2 environment."); @@ -976,8 +942,7 @@ HRESULT OnEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2Environment }) // .Get() // ); // - WebviewDebugLog(fmt::format(L"candidate controller creation submitted: hr=0x{:08X}", - static_cast(hr))); + (void)0; return hr; } @@ -1004,7 +969,7 @@ HRESULT OnControllerCreatedMenuWnd( // if (!controller || FAILED(result)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to create menu window webview2 controller.").c_str()); + (void)0; #endif return E_FAIL; } @@ -1016,7 +981,7 @@ HRESULT OnControllerCreatedMenuWnd( // if (!webviewMenuWnd) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to get webview2 instance.").c_str()); + (void)0; #endif return E_FAIL; } @@ -1082,7 +1047,7 @@ HRESULT OnControllerCreatedMenuWnd( // BOOL success = FALSE; if (!args || FAILED(args->get_IsSuccess(&success)) || !success) { - WebviewDebugLog(L"menu navigation failed or incomplete"); + (void)0; return S_OK; } NotifySmallWindowNavigationReady(menuNavigationReady, L"menu"); @@ -1113,7 +1078,7 @@ HRESULT OnControllerCreatedMenuWnd( // if (FAILED(hr)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to navigate to string.").c_str()); + (void)0; #endif } @@ -1193,7 +1158,7 @@ HRESULT OnMenuWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2E if (FAILED(result) || !env) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to create menu window webview2 environment.").c_str()); + (void)0; #endif return result; } @@ -1267,7 +1232,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (!controller || FAILED(result)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to create settings window webview2 controller.").c_str()); + (void)0; #endif return E_FAIL; } @@ -1277,7 +1242,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (FAILED(webviewCompositionControllerSettingsWnd.As(&webviewControllerSettingsWnd))) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to get the base WebView2 controller.").c_str()); + (void)0; #endif return E_NOINTERFACE; } @@ -1287,7 +1252,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (!webviewSettingsWnd) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to get webview2 instance.").c_str()); + (void)0; #endif return E_FAIL; } @@ -1336,7 +1301,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (FAILED(compositionResult)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to initialize DirectComposition.").c_str()); + (void)0; #endif return compositionResult; } @@ -1346,7 +1311,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (FAILED(rootVisualResult)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to attach the WebView root visual.").c_str()); + (void)0; #endif return rootVisualResult; } @@ -1365,7 +1330,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (FAILED(hr)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to navigate to string.").c_str()); + (void)0; #endif } @@ -1379,8 +1344,7 @@ HRESULT OnControllerCreatedSettingsWnd( // { // 隐藏窗口 #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Webview2 settings window loaded and already hidden window").c_str()); + (void)0; #endif BOOL cloak = FALSE; DwmSetWindowAttribute(hwnd, DWMWA_CLOAK, &cloak, sizeof(cloak)); @@ -1807,7 +1771,7 @@ HRESULT OnSettingsWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebVi if (FAILED(result) || !env) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to create settings window webview2 environment.").c_str()); + (void)0; #endif return result; } @@ -1816,7 +1780,7 @@ HRESULT OnSettingsWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebVi if (FAILED(env->QueryInterface(IID_PPV_ARGS(&env3))) || !env3) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to get ICoreWebView2Environment3 for composition.").c_str()); + (void)0; #endif return E_NOINTERFACE; } @@ -1961,8 +1925,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (!controller || FAILED(result)) { #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Failed to create floating toolbar window webview2 controller.").c_str()); + (void)0; #endif return E_FAIL; } @@ -1974,7 +1937,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (!webviewFtbWnd) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to get webview2 instance.").c_str()); + (void)0; #endif return E_FAIL; } @@ -2070,7 +2033,7 @@ HRESULT OnControllerCreatedFtbWnd( // } else { - WebviewDebugLog(L"floating-toolbar navigation failed"); + (void)0; } return S_OK; }) @@ -2079,10 +2042,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (FAILED(navigationCompletedResult)) { #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Failed to register floating toolbar navigation callback: 0x{:08X}", - static_cast(navigationCompletedResult)) - .c_str()); + (void)0; #endif return navigationCompletedResult; } @@ -2092,7 +2052,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (FAILED(hr)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Failed to navigate to string.").c_str()); + (void)0; #endif return hr; } @@ -2125,7 +2085,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (mode == "cn") // Change to CN { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to CN").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe(Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToCn, L""); @@ -2133,7 +2093,7 @@ HRESULT OnControllerCreatedFtbWnd( // else if (mode == "en") // Change to EN { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to EN").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe(Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToEn, L""); @@ -2145,7 +2105,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (mode == "fullwidth") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to fullwidth").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe( Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToFullwidth, L""); @@ -2153,7 +2113,7 @@ HRESULT OnControllerCreatedFtbWnd( // else if (mode == "halfwidth") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to halfwidth").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe( Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToHalfwidth, L""); @@ -2165,7 +2125,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (mode == "puncEn") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to puncEn").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe( Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToPuncEn, L""); @@ -2173,7 +2133,7 @@ HRESULT OnControllerCreatedFtbWnd( // else if (mode == "puncCn") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Change to puncCn").c_str()); + (void)0; #endif SendToTsfWorkerThreadViaNamedpipe( Global::DataFromServerMsgTypeToTsfWorkerThread::SwitchToPuncCn, L""); @@ -2194,14 +2154,14 @@ HRESULT OnControllerCreatedFtbWnd( // else if (type == "openSettings") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Open settings").c_str()); + (void)0; #endif OpenSettingsApplication(); } else if (type == "openEmojiPanel") { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Open emoji panel").c_str()); + (void)0; #endif OpenEmojiPanelApplication(); } @@ -2228,8 +2188,7 @@ HRESULT OnFtbWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2En if (FAILED(result) || !env) { #ifdef FANY_DEBUG - OutputDebugString( - fmt::format(L"[msime]: Failed to create floating toolbar window webview2 environment.").c_str()); + (void)0; #endif return result; } @@ -2262,16 +2221,14 @@ void InitSmallWindowWebviews(HWND candHwnd, HWND menuHwnd, HWND ftbHwnd) L"--no-first-run"); const std::wstring appDataPath = GetAppdataPath(); - WebviewDebugLog(fmt::format(L"shared environment creation starting: cand=0x{:X}, user_data='{}'", - reinterpret_cast(candHwnd), appDataPath)); + (void)0; const HRESULT createHr = CreateCoreWebView2EnvironmentWithOptions( nullptr, appDataPath.c_str(), options.Get(), Callback( [candHwnd, menuHwnd, ftbHwnd](HRESULT result, ICoreWebView2Environment *env) -> HRESULT { - WebviewDebugLog(fmt::format(L"shared environment callback: result=0x{:08X}, env={}", - static_cast(result), env != nullptr)); + (void)0; if (FAILED(result) || !env) { ShowErrorMessage(candHwnd, L"Failed to create the shared WebView2 environment."); @@ -2284,18 +2241,14 @@ void InitSmallWindowWebviews(HWND candHwnd, HWND menuHwnd, HWND ftbHwnd) const HRESULT menuResult = OnMenuWindowEnvironmentCreated(menuHwnd, S_OK, env); const HRESULT ftbResult = OnFtbWindowEnvironmentCreated(ftbHwnd, S_OK, env); - WebviewDebugLog(fmt::format( - L"small-window controller submissions: candidate=0x{:08X}, menu=0x{:08X}, ftb=0x{:08X}", - static_cast(candResult), static_cast(menuResult), - static_cast(ftbResult))); + (void)0; if (FAILED(candResult)) return candResult; if (FAILED(menuResult)) return menuResult; return ftbResult; }) .Get()); - WebviewDebugLog(fmt::format(L"shared environment creation submitted: hr=0x{:08X}", - static_cast(createHr))); + (void)0; } void ShutdownWebviews() diff --git a/server/src/window/ime_windows.cpp b/server/src/window/ime_windows.cpp index 398d1bd0..1dd01685 100644 --- a/server/src/window/ime_windows.cpp +++ b/server/src/window/ime_windows.cpp @@ -90,12 +90,7 @@ void LayoutFloatingToolbar(HWND hwnd, bool reset_to_default_corner) const BOOL ok = SetWindowPos(hwnd, nullptr, posX, posY, width, height, SWP_NOZORDER | SWP_NOACTIVATE); SyncHostWebViewBounds(::webviewControllerFtbWnd.Get(), hwnd); - OutputDebugStringW(fmt::format(L"[msime-webview] ftb layout: hwnd=0x{:X}, pos=({},{}), size=({},{}), " - L"scale={}, reset_corner={}, SetWindowPos={}, GetLastError={}, visible={}\n", - reinterpret_cast(hwnd), posX, posY, width, height, scale, - reset_to_default_corner, ok != FALSE, ok ? 0 : GetLastError(), - IsWindowVisible(hwnd) != FALSE) - .c_str()); + (void)0; } void PlaceFloatingToolbarOnScreen(HWND hwnd) @@ -250,11 +245,7 @@ void ApplyConfiguredFloatingToolbarVisibility() const bool should_show = FanyImeUi::ShouldShowFloatingToolbar( GetConfiguredFloatingToolbarEnabled(), fullscreen, g_is_ime_active); const bool is_visible = IsWindowVisible(::global_hwnd_ftb) != FALSE; - OutputDebugStringW(fmt::format(L"[msime-webview] ftb visibility: should_show={}, is_visible={}, " - L"configured={}, fullscreen={}, ime_active={}, hwnd=0x{:X}\n", - should_show, is_visible, GetConfiguredFloatingToolbarEnabled(), fullscreen, - g_is_ime_active, reinterpret_cast(::global_hwnd_ftb)) - .c_str()); + (void)0; if (should_show) { // Keep the dragged position across IME activate / config / fullscreen @@ -322,7 +313,7 @@ LRESULT RegisterIMEWindowsClass(WNDCLASSEX &wcex, HINSTANCE hInstance) if (!RegisterClassEx(&wcex)) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Call to RegisterClassEx failed!").c_str()); + (void)0; #endif return 1; } @@ -361,7 +352,7 @@ int CreateCandidateWindow(HINSTANCE hInstance) if (!hwnd_cand) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Call to CreateWindow for candidate window failed!").c_str()); + (void)0; #endif return 1; } @@ -401,7 +392,7 @@ int CreateCandidateWindow(HINSTANCE hInstance) if (!hwnd_menu) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Call to CreateWindow for menu failed!").c_str()); + (void)0; #endif return 1; } @@ -438,16 +429,14 @@ int CreateCandidateWindow(HINSTANCE hInstance) if (!hwnd_ftb) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Call to CreateWindow for floating toolbar failed!").c_str()); + (void)0; #endif return 1; } PrepareLayeredHostWindow(hwnd_ftb); ::global_hwnd_ftb = hwnd_ftb; FanyNamedPipe::RegisterStatusSnapshotWindow(hwnd_ftb); - OutputDebugStringW(fmt::format(L"[msime-webview] ftb created on screen: hwnd=0x{:X}, pos=({},{}), size=({},{})\n", - reinterpret_cast(hwnd_ftb), ftbX, ftbY, ftbWidth, ftbHeight) - .c_str()); + (void)0; // Cloaked show: WebView2 sees a visible on-monitor host; the user does not. WarmupHostWindowCloaked(hwnd_cand); @@ -478,12 +467,12 @@ int CreateCandidateWindow(HINSTANCE hInstance) if (!g_hHook) { #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Kbd hook for IME failed!").c_str()); + (void)0; #endif return 1; } #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Kbd hook for IME installed.").c_str()); + (void)0; #endif HWINEVENTHOOK hook = SetWinEventHook( // @@ -560,19 +549,11 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA ? std::wstring{} : GetPreeditWithCaretMarker(); std::wstring str = preedit + L"," + Global::CandidateString; - OutputDebugStringW(fmt::format(L"[msime-webview] show candidate requested: hwnd=0x{:X}, caret=({},{}), " - L"preedit_chars={}, candidate_chars={}, webview={}, controller={}, " - L"topmost_applied={}, cand_visible={}\n", - reinterpret_cast(hwnd), Global::Point[0], Global::Point[1], - preedit.size(), Global::CandidateString.size(), webviewCandWnd != nullptr, - webviewControllerCandWnd != nullptr, AreSmallWindowsTopmostApplied(), - IsWindowVisible(hwnd) != FALSE) - .c_str()); + (void)0; LogSmallWindowReadyGate(L"show-candidate"); if (!EnsureSmallWindowsTopmost(L"show-candidate")) { - OutputDebugStringW(L"[msime-webview] show candidate: webviews not ready, topmost queued; " - L"will FineTune after navigation\n"); + (void)0; } InflateMeasureDivCandWnd(str); @@ -586,8 +567,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA if (message == WM_HIDE_MAIN_WINDOW) { - OutputDebugStringW(fmt::format(L"[msime-webview] hide candidate requested: hwnd=0x{:X}\n", - reinterpret_cast(hwnd)).c_str()); + (void)0; // Clear first so any FineTuneWindow callback already queued bails out. ::is_global_wnd_cand_shown = false; FLOAT scale = GetForegroundWindowScale(); @@ -735,7 +715,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA case WM_CLS_DICT_CACHE: { FanyNamedPipe::EnqueueResetInputSessionCacheTask(); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Cleared dictionary buffer cache.").c_str()); + (void)0; #endif break; } @@ -743,7 +723,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA case WM_COMMIT_CANDIDATE: { int one_based = static_cast(wParam); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Really to commit candidate {}", one_based).c_str()); + (void)0; #endif FanyNamedPipe::EnqueueCandidateUiAction(FanyNamedPipe::CandidateUiAction::Commit, one_based); @@ -753,7 +733,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA case WM_PIN_TO_TOP_CANDIDATE: { int one_based = static_cast(wParam); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Really to pin to top candidate {}", one_based).c_str()); + (void)0; #endif FanyNamedPipe::EnqueueCandidateUiAction(FanyNamedPipe::CandidateUiAction::Pin, one_based); @@ -763,7 +743,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA case WM_DELETE_CANDIDATE: { int one_based = static_cast(wParam); #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: Really to delete candidate {}", one_based).c_str()); + (void)0; #endif FanyNamedPipe::EnqueueCandidateUiAction(FanyNamedPipe::CandidateUiAction::Delete, one_based); @@ -772,7 +752,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA case WM_CLEAR_IME_ENGINE_CACHE: { #ifdef FANY_DEBUG - OutputDebugString(L"[msime]: Clearing IME engine cache"); + (void)0; #endif /* 清除候选词缓存 */ FanyNamedPipe::EnqueueResetInputSessionCacheTask(); @@ -839,16 +819,7 @@ LRESULT CALLBACK WndProcMenuWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA ::MENU_WINDOW_HEIGHT, // flag // ); - OutputDebugStringW(fmt::format(L"[msime-webview] show menu: hwnd=0x{:X}, pos=({},{}), size=({},{}), " - L"dip=({:.1f},{:.1f}), scale={}, SetWindowPos={}, GetLastError={}, " - L"webview={}, controller={}, visible={}\n", - reinterpret_cast(::global_hwnd_menu), menuX, menuY, - ::MENU_WINDOW_WIDTH, ::MENU_WINDOW_HEIGHT, ::MENU_CONTENT_WIDTH_DIP, - ::MENU_CONTENT_HEIGHT_DIP, scale, okShowMenu != FALSE, - okShowMenu ? 0 : GetLastError(), webviewMenuWnd != nullptr, - webviewControllerMenuWnd != nullptr, - IsWindowVisible(::global_hwnd_menu) != FALSE) - .c_str()); + (void)0; if (!okShowMenu) { ShowWindow(::global_hwnd_menu, SW_SHOWNOACTIVATE); @@ -893,11 +864,7 @@ LRESULT CALLBACK WndProcMenuWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA ApplyMenuPhysicalSizeFromDips(hwnd, scale, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } SyncHostWebViewBounds(::webviewControllerMenuWnd.Get(), hwnd); - OutputDebugStringW(fmt::format(L"[msime-webview] menu WM_DPICHANGED: size=({},{}), dip=({:.1f},{:.1f}), " - L"scale={}\n", - ::MENU_WINDOW_WIDTH, ::MENU_WINDOW_HEIGHT, ::MENU_CONTENT_WIDTH_DIP, - ::MENU_CONTENT_HEIGHT_DIP, scale) - .c_str()); + (void)0; // Remeasure in case font/layout metrics shifted with the new DPI. SetTimer(hwnd, TIMER_ID_INIT_WEBVIEW_MENU, 1, nullptr); return 0; @@ -937,11 +904,7 @@ LRESULT CALLBACK WndProcMenuWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA flag |= wasVisible ? SWP_SHOWWINDOW : SWP_HIDEWINDOW; FLOAT scale = GetWindowScale(hwnd); ApplyMenuPhysicalSizeFromDips(hwnd, scale, flag); - OutputDebugStringW(fmt::format(L"[msime-webview] menu measured: size=({},{}), " - L"dip=({:.1f},{:.1f}), scale={}\n", - ::MENU_WINDOW_WIDTH, ::MENU_WINDOW_HEIGHT, - ::MENU_CONTENT_WIDTH_DIP, ::MENU_CONTENT_HEIGHT_DIP, scale) - .c_str()); + (void)0; } }); } @@ -1467,7 +1430,7 @@ LRESULT CALLBACK WndProcFtbWindow(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_DPICHANGED: { // Recompute from design DIPs rather than only accepting the suggested // rect. Keep the user's dragged top-left instead of snapping home. - OutputDebugStringW(fmt::format(L"[msime-webview] ftb WM_DPICHANGED: dpi={}\n", HIWORD(wParam)).c_str()); + (void)0; LayoutFloatingToolbar(hwnd, false); return 0; } @@ -1507,15 +1470,10 @@ int FineTuneWindow(HWND hwnd) int caretX = Global::Point[0]; int caretY = Global::Point[1]; - OutputDebugStringW(fmt::format(L"[msime-webview] candidate fine-tune started: hwnd=0x{:X}, caret=({},{}), " - L"scale={}, shown={}, webview={}, controller={}, topmost_applied={}\n", - reinterpret_cast(hwnd), caretX, caretY, scale, - ::is_global_wnd_cand_shown, webviewCandWnd != nullptr, - webviewControllerCandWnd != nullptr, AreSmallWindowsTopmostApplied()) - .c_str()); + (void)0; if (!webviewCandWnd) { - OutputDebugStringW(L"[msime-webview] candidate fine-tune aborted: webviewCandWnd is null\n"); + (void)0; LogSmallWindowReadyGate(L"fine-tune-no-webview"); return 0; } @@ -1532,9 +1490,7 @@ int FineTuneWindow(HWND hwnd) // measure callback was still pending — do not resurrect it. if (!::is_global_wnd_cand_shown || caretY == Global::INVALID_Y) { - OutputDebugStringW(fmt::format(L"[msime-webview] candidate fine-tune abandoned after measurement: " - L"shown={}, caretY={}\n", - ::is_global_wnd_cand_shown, caretY).c_str()); + (void)0; return; } @@ -1549,7 +1505,7 @@ int FineTuneWindow(HWND hwnd) // Empty composition with no candidates means the session already ended. if (GlobalIme::composition.raw_input_with_cases.empty() && Global::CandidateString.empty()) { - OutputDebugStringW(L"[msime-webview] candidate fine-tune abandoned: composition and candidates empty\n"); + (void)0; return; } @@ -1595,15 +1551,7 @@ int FineTuneWindow(HWND hwnd) UpdateSmallWindowWebviewVisibility(hwnd, true); RECT actualRect{}; GetWindowRect(hwnd, &actualRect); - OutputDebugStringW(fmt::format( - L"[msime-webview] candidate window positioned: requested_pos=({},{}), requested_size=({},{}), " - L"flags=0x{:X}, success={}, GetLastError={}, actual_rect=[{},{},{},{}], visible={}, " - L"topmost_applied={}, measure=({:.1f},{:.1f})\n", - properPos->first, properPos->second, newWidth, newHeight, newFlag, positioned != FALSE, - positioned ? 0 : GetLastError(), actualRect.left, actualRect.top, actualRect.right, actualRect.bottom, - IsWindowVisible(hwnd) != FALSE, AreSmallWindowsTopmostApplied(), containerSize.first, - containerSize.second) - .c_str()); + (void)0; }); }); return 0; diff --git a/server/src/window/window_hook.cpp b/server/src/window/window_hook.cpp index 9cf8ee92..e26c3ac7 100644 --- a/server/src/window/window_hook.cpp +++ b/server/src/window/window_hook.cpp @@ -86,7 +86,7 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { // 执行候选项删除逻辑,PostMessage 给窗口过程去执行 #ifdef FANY_DEBUG - OutputDebugString(fmt::format(L"[msime]: To delete candidate {}", idx + 1).c_str()); + (void)0; #endif PostMessage(::global_hwnd, WM_DELETE_CANDIDATE, idx + 1, 0); // This is an IME command, not text intended for the foreground