diff --git a/frameworks/native/inputmethod_ability/include/input_method_panel.h b/frameworks/native/inputmethod_ability/include/input_method_panel.h index bc995a06d9735a976339bc595b3cda88dce6ae9c..9b9df44084bb435ace0fe35bd3f52cee50810d97 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 37aeb8c6778cb219acb02ec1cd6e110769bb2be5..57098ae6c07a2b593e2badcf88acccd972850618 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()