From 69ab8679820d5e78c4dd5133e4fc07ee2244bb9c Mon Sep 17 00:00:00 2001 From: cy7717 Date: Fri, 5 Sep 2025 11:08:52 +0800 Subject: [PATCH] mod Signed-off-by: cy7717 --- .../include/input_method_panel.h | 1 + .../src/input_method_panel.cpp | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frameworks/native/inputmethod_ability/include/input_method_panel.h b/frameworks/native/inputmethod_ability/include/input_method_panel.h index bc995a06d..9b9df4408 100644 --- a/frameworks/native/inputmethod_ability/include/input_method_panel.h +++ b/frameworks/native/inputmethod_ability/include/input_method_panel.h @@ -102,6 +102,7 @@ private: private: ChangeHandler handler_ = nullptr; }; + std::string GetDisplayName(uint64_t displayId); void RegisterKeyboardPanelInfoChangeListener(); void UnregisterKeyboardPanelInfoChangeListener(); void HandleKbPanelInfoChange(const Rosen::KeyboardPanelInfo &keyboardPanelInfo); diff --git a/frameworks/native/inputmethod_ability/src/input_method_panel.cpp b/frameworks/native/inputmethod_ability/src/input_method_panel.cpp index 37aeb8c67..57098ae6c 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_panel.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_panel.cpp @@ -526,10 +526,24 @@ int32_t InputMethodPanel::GetDisplayId(uint64_t &displayId) IMSA_HILOGE("display id invalid!"); return ErrorCode::ERROR_WINDOW_MANAGER; } + if (GetDisplayName(displayId) == "") { + IMSA_HILOGE("CYYYYY calling displayid!"); + displayId = InputMethodAbility::GetInstance().GetInputAttribute().callingDisplayId; + } IMSA_HILOGD("GetDisplayId success dispalyId = %{public}" PRIu64 "", displayId); return ErrorCode::NO_ERROR; } +std::string InputMethodPanel::GetDisplayName(uint64_t displayId) +{ + auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); + if (display == nullptr) { + IMSA_HILOGE("get display err:%{public}" PRIu64 "!", displayId); + return ""; + } + return display->GetName(); +} + int32_t InputMethodPanel::AdjustKeyboard() { isAdjustInfoInitialized_.store(false); @@ -2128,7 +2142,12 @@ sptr InputMethodPanel::GetCurDisplay() uint64_t InputMethodPanel::GetCurDisplayId() { - return InputMethodAbility::GetInstance().GetInputAttribute().callingDisplayId; + auto displayId = InputMethodAbility::GetInstance().GetInputAttribute().callingDisplayId; + if (GetDisplayName(displayId) == "") { + IMSA_HILOGE("CYYYYY main displayid!"); + return 0; + } + return displayId; } bool InputMethodPanel::IsInMainDisplay() -- Gitee