Merge pull request !10178 from Laiganlu/FA
This commit is contained in:
openharmony_ci 2024-10-28 11:07:31 +00:00 committed by Gitee
commit 29572e5934
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 38 additions and 31 deletions

View File

@ -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

View File

@ -402,6 +402,14 @@ public:
* @return WM_OK means get success, others means get failed.
*/
virtual WMError GetGestureBackEnabled(bool& enable) { return WMError::WM_OK; }
/**
* @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) {}
};
}
}

View File

@ -331,7 +331,6 @@ protected:
bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
void DispatchKeyEventCallback(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed);
bool FilterKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
void RegisterFrameLayoutCallback();
bool IsVerticalOrientation(Orientation orientation) const;
void CopyUniqueDensityParameter(sptr<WindowSessionImpl> parentWindow);
sptr<WindowSessionImpl> FindMainWindowWithContext();
@ -412,6 +411,7 @@ protected:
/*
* Window Layout
*/
void FlushLayoutSize(int32_t width, int32_t height) override;
sptr<FutureCallback> layoutCallback_ = nullptr;
private:

View File

@ -828,6 +828,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)
{
@ -1253,42 +1274,12 @@ WMError WindowSessionImpl::InitUIContent(const std::string& contentInfo, napi_en
{
std::unique_lock<std::shared_mutex> 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<int32_t>(windowRect.width_), static_cast<int32_t>(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)
{