diff --git a/frameworks/kits/extension/src/js_inputmethod_extension.cpp b/frameworks/kits/extension/src/js_inputmethod_extension.cpp index ae1e179119c5a7edfcd8b374a201dd806d2965e7..f6a5b978c545adf714a066102f684194289af2e6 100644 --- a/frameworks/kits/extension/src/js_inputmethod_extension.cpp +++ b/frameworks/kits/extension/src/js_inputmethod_extension.cpp @@ -428,29 +428,29 @@ void JsInputMethodExtension::OnDestroy(Rosen::DisplayId displayId) void JsInputMethodExtension::CheckNeedAdjustKeyboard(Rosen::DisplayId displayId) { - if (displayId != Rosen::DisplayManager::GetInstance().GetDefaultDisplayId()) { - return; - } - auto foldStatus = Rosen::DisplayManager::GetInstance().GetFoldStatus(); auto displayPtr = Rosen::DisplayManager::GetInstance().GetDefaultDisplaySync(); if (displayPtr == nullptr) { return; } + auto defaultDisplayId = displayPtr->GetId(); + if (displayId != defaultDisplayId) { + return; + } + auto foldStatus = Rosen::DisplayManager::GetInstance().GetFoldStatus(); + auto width = displayPtr->GetWidth(); + auto height = displayPtr->GetHeight(); + auto rotation = displayPtr->GetRotation(); IMSA_HILOGD("display width: %{public}d, height: %{public}d, rotation: %{public}d, foldStatus: %{public}d", - displayPtr->GetWidth(), - displayPtr->GetHeight(), - displayPtr->GetRotation(), - foldStatus); + width, height, rotation, foldStatus); if (!cacheDisplay_.IsEmpty()) { - if ((cacheDisplay_.displayWidth != displayPtr->GetWidth() || - cacheDisplay_.displayHeight != displayPtr->GetHeight()) && + if ((cacheDisplay_.displayWidth != width || + cacheDisplay_.displayHeight != height) && cacheDisplay_.displayFoldStatus == foldStatus && - cacheDisplay_.displayRotation == displayPtr->GetRotation()) { + cacheDisplay_.displayRotation == rotation) { InputMethodAbility::GetInstance().AdjustKeyboard(); } } - cacheDisplay_.SetCacheDisplay( - displayPtr->GetWidth(), displayPtr->GetHeight(), displayPtr->GetRotation(), foldStatus); + cacheDisplay_.SetCacheDisplay(width, height, rotation, foldStatus); } void JsInputMethodExtension::OnChange(Rosen::DisplayId displayId) diff --git a/frameworks/kits/extension_cj/src/cj_inputmethod_extension.cpp b/frameworks/kits/extension_cj/src/cj_inputmethod_extension.cpp index 45e94bc3c63fc9eb1d81657bcf6b2ff4d6434beb..7a40715cd3fc3deca57603f9b59ce91f1cfdacd4 100644 --- a/frameworks/kits/extension_cj/src/cj_inputmethod_extension.cpp +++ b/frameworks/kits/extension_cj/src/cj_inputmethod_extension.cpp @@ -186,26 +186,29 @@ void CjInputMethodExtension::OnDestroy(Rosen::DisplayId displayId) void CjInputMethodExtension::CheckNeedAdjustKeyboard(Rosen::DisplayId displayId) { - if (displayId != Rosen::DisplayManager::GetInstance().GetDefaultDisplayId()) { - return; - } - auto foldStatus = Rosen::DisplayManager::GetInstance().GetFoldStatus(); auto displayPtr = Rosen::DisplayManager::GetInstance().GetDefaultDisplaySync(); if (displayPtr == nullptr) { return; } + auto defaultDisplayId = displayPtr->GetId(); + if (displayId != defaultDisplayId) { + return; + } + auto foldStatus = Rosen::DisplayManager::GetInstance().GetFoldStatus(); + auto width = displayPtr->GetWidth(); + auto height = displayPtr->GetHeight(); + auto rotation = displayPtr->GetRotation(); IMSA_HILOGD("display width: %{public}d, height: %{public}d, rotation: %{public}d, foldStatus: %{public}d", - displayPtr->GetWidth(), displayPtr->GetHeight(), displayPtr->GetRotation(), foldStatus); + width, height, rotation, foldStatus); if (!cacheDisplay_.IsEmpty()) { - if ((cacheDisplay_.displayWidth != displayPtr->GetWidth() || - cacheDisplay_.displayHeight != displayPtr->GetHeight()) && + if ((cacheDisplay_.displayWidth != width || + cacheDisplay_.displayHeight != height) && cacheDisplay_.displayFoldStatus == foldStatus && - cacheDisplay_.displayRotation == displayPtr->GetRotation()) { + cacheDisplay_.displayRotation == rotation) { InputMethodAbility::GetInstance().AdjustKeyboard(); } } - cacheDisplay_.SetCacheDisplay( - displayPtr->GetWidth(), displayPtr->GetHeight(), displayPtr->GetRotation(), foldStatus); + cacheDisplay_.SetCacheDisplay(width, height, rotation, foldStatus); } void CjInputMethodExtension::OnChange(Rosen::DisplayId displayId) diff --git a/frameworks/native/inputmethod_ability/src/input_method_panel.cpp b/frameworks/native/inputmethod_ability/src/input_method_panel.cpp index 5c2307489598b32a2d7e477b6bb2394a5defb6f5..995f7b528c442ad29258912a17c3b4de2a5c74cb 100644 --- a/frameworks/native/inputmethod_ability/src/input_method_panel.cpp +++ b/frameworks/native/inputmethod_ability/src/input_method_panel.cpp @@ -1567,11 +1567,13 @@ bool InputMethodPanel::IsSizeValid(uint32_t width, uint32_t height) float ratio = panelType_ == PanelType::SOFT_KEYBOARD && panelFlag_ == PanelFlag::FLG_FIXED ? FIXED_SOFT_KEYBOARD_PANEL_RATIO : NON_FIXED_SOFT_KEYBOARD_PANEL_RATIO; - if (static_cast(height) > defaultDisplay->GetHeight() * ratio || - static_cast(width) > defaultDisplay->GetWidth()) { + auto defaultDisplayHeight = defaultDisplay->GetHeight(); + auto defaultDisplayWidth = defaultDisplay->GetWidth(); + if (static_cast(height) > defaultDisplayHeight * ratio || + static_cast(width) > defaultDisplayWidth) { IMSA_HILOGE("param is invalid, defaultDisplay height: %{public}d, defaultDisplay width %{public}d, target " "height: %{public}u, target width: %{public}u!", - defaultDisplay->GetHeight(), defaultDisplay->GetWidth(), height, width); + defaultDisplayHeight, defaultDisplayWidth, height, width); return false; } return true;