From 92b1df75d1abf090a5856bb94c26293d0097a53e Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Fri, 25 Oct 2024 16:28:40 +0800 Subject: [PATCH] FIX FA Signed-off-by: Laiganlu --- interfaces/innerkits/wm/window.h | 8 +++++ previewer/include/window.h | 8 +++++ wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 51 +++++++++++++------------------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index e0d56e5006..180972d551 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2258,6 +2258,14 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Flush layout size. + * + * @param width The width after layout + * @param height The height after layout + */ + virtual void FlushLayoutSize(int32_t width, int32_t height) {} + /** * @brief get callingWindow windowStatus. * @param windowStatus diff --git a/previewer/include/window.h b/previewer/include/window.h index 42d8bca27a..700d272750 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -402,6 +402,14 @@ public: * @return the value true means to enable gesture back, and false means the opposite. */ virtual bool GetGestureBackEnabled() const { return true; } + + /** + * @brief Flush layout size. + * + * @param width The width after layout + * @param height The height after layout + */ + virtual void FlushLayoutSize(int32_t width, int32_t height) {} }; } } diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index c79b9c7453..c2fa9c0dc3 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -323,7 +323,6 @@ protected: bool IsKeyboardEvent(const std::shared_ptr& keyEvent) const; void DispatchKeyEventCallback(const std::shared_ptr& keyEvent, bool& isConsumed); bool FilterKeyEvent(const std::shared_ptr& keyEvent); - void RegisterFrameLayoutCallback(); bool IsVerticalOrientation(Orientation orientation) const; void CopyUniqueDensityParameter(sptr parentWindow); sptr FindMainWindowWithContext(); @@ -403,6 +402,7 @@ protected: /* * Window Layout */ + void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; private: diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 10b901c99d..8b2b4f1ddf 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -804,6 +804,27 @@ void WindowSessionImpl::NotifyRotationAnimationEnd() } } +void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) +{ + if (!WindowHelper::IsMainWindow(GetType())) { + return; + } + if (windowSizeChanged_ || enableFrameLayoutFinishCb_) { + WSRect rect = {0, 0, width, height}; + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, + "NotifyFrameLayoutFinishFromApp, id: %u, rect: %s, notifyListener: %d", + GetWindowId(), rect.ToString().c_str(), enableFrameLayoutFinishCb_.load()); + TLOGI(WmsLogTag::WMS_LAYOUT, + "NotifyFrameLayoutFinishFromApp, id: %{public}u, rect: %{public}s, notifyListener: %{public}d", + GetWindowId(), rect.ToString().c_str(), enableFrameLayoutFinishCb_.load()); + if (auto session = GetHostSession()) { + session->NotifyFrameLayoutFinishFromApp(enableFrameLayoutFinishCb_, rect); + } + windowSizeChanged_ = false; + enableFrameLayoutFinishCb_ = false; + } +} + void WindowSessionImpl::GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, bool& hideCloseButton) { @@ -1233,42 +1254,12 @@ WMError WindowSessionImpl::InitUIContent(const std::string& contentInfo, napi_en { std::unique_lock lock(uiContentMutex_); uiContent_ = std::move(uiContent); - RegisterFrameLayoutCallback(); WLOGFI("Initialized, isUIExtensionSubWindow:%{public}d, isUIExtensionAbilityProcess:%{public}d", uiContent_->IsUIExtensionSubWindow(), uiContent_->IsUIExtensionAbilityProcess()); } return WMError::WM_OK; } -void WindowSessionImpl::RegisterFrameLayoutCallback() -{ - if (!WindowHelper::IsMainWindow(GetType()) || windowSystemConfig_.IsPcWindow()) { - return; - } - uiContent_->SetLastestFrameLayoutFinishCallback([weakThis = wptr(this)]() { - auto window = weakThis.promote(); - if (window == nullptr) { - return; - } - if (window->windowSizeChanged_ || window->enableFrameLayoutFinishCb_) { - auto windowRect = window->GetRect(); - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, - "NotifyFrameLayoutFinish, id: %u, rect: %s, notifyListener: %d", - window->GetWindowId(), windowRect.ToString().c_str(), window->enableFrameLayoutFinishCb_.load()); - TLOGI(WmsLogTag::WMS_LAYOUT, - "NotifyFrameLayoutFinish, id: %{public}u, rect: %{public}s, notifyListener: %{public}d", - window->GetWindowId(), windowRect.ToString().c_str(), window->enableFrameLayoutFinishCb_.load()); - WSRect rect = { windowRect.posX_, windowRect.posY_, - static_cast(windowRect.width_), static_cast(windowRect.height_) }; - if (auto session = window->GetHostSession()) { - session->NotifyFrameLayoutFinishFromApp(window->enableFrameLayoutFinishCb_, rect); - } - window->windowSizeChanged_ = false; - window->enableFrameLayoutFinishCb_ = false; - } - }); -} - WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, napi_env env, napi_value storage, WindowSetUIContentType setUIContentType, BackupAndRestoreType restoreType, AppExecFwk::Ability* ability) {