From 51fb19d502053c571bb8b5502197be1ebb774283 Mon Sep 17 00:00:00 2001 From: jiangdayuan Date: Sat, 26 Feb 2022 17:06:59 +0800 Subject: [PATCH] fix window title bug Signed-off-by: jiangdayuan Change-Id: I49611ab076f250ae7288b0555e8521084982b785 --- adapter/ohos/entrance/ui_content_impl.cpp | 22 +++++++++++++++++++ adapter/ohos/entrance/ui_content_impl.h | 1 + .../container_modal_component.cpp | 3 --- .../container_modal_element.cpp | 3 +-- .../container_modal/container_modal_element.h | 1 - interfaces/innerkits/ace/ui_content.h | 2 ++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 46b34d9cc8c..cf0f4559fa7 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -524,6 +524,28 @@ void UIContentImpl::UpdateViewportConfig(const ViewportConfig& config, OHOS::Ros updateConfig_ = true; } +void UIContentImpl::UpdateWindowMode(OHOS::Rosen::WindowMode mode) +{ + LOGI("UpdateWindowMode, window mode is %{public}d", mode); + auto container = Platform::AceContainer::GetContainer(instanceId_); + if (!container) { + LOGE("UpdateWindowMode failed, get container(id=%{public}d) failed", instanceId_); + return; + } + auto pipelineContext = container->GetPipelineContext(); + if (!pipelineContext) { + LOGE("UpdateWindowMode failed, pipeline context is null."); + return; + } + if (mode == OHOS::Rosen::WindowMode::WINDOW_MODE_FULLSCREEN || + mode == OHOS::Rosen::WindowMode::WINDOW_MODE_SPLIT_PRIMARY || + mode == OHOS::Rosen::WindowMode::WINDOW_MODE_SPLIT_SECONDARY) { + pipelineContext->ShowContainerTitle(false); + } else { + pipelineContext->ShowContainerTitle(true); + } +} + void UIContentImpl::DumpInfo(const std::vector& params, std::vector& info) { auto container = Platform::AceContainer::GetContainer(instanceId_); diff --git a/adapter/ohos/entrance/ui_content_impl.h b/adapter/ohos/entrance/ui_content_impl.h index a1d473e5a60..5ffade5531a 100644 --- a/adapter/ohos/entrance/ui_content_impl.h +++ b/adapter/ohos/entrance/ui_content_impl.h @@ -60,6 +60,7 @@ public: bool ProcessVsyncEvent(uint64_t timeStampNanos) override; void UpdateConfiguration(const std::shared_ptr& config) override; void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) override; + void UpdateWindowMode(OHOS::Rosen::WindowMode mode) override; void DumpInfo(const std::vector& params, std::vector& info) override; diff --git a/frameworks/core/components/container_modal/container_modal_component.cpp b/frameworks/core/components/container_modal/container_modal_component.cpp index 5defb31cc83..e7fc5d2bde2 100644 --- a/frameworks/core/components/container_modal/container_modal_component.cpp +++ b/frameworks/core/components/container_modal/container_modal_component.cpp @@ -198,7 +198,6 @@ std::list> ContainerModalComponent::BuildTitleChildren(bool is auto context = contextWptr.Upgrade(); if (context) { context->FireWindowSplitCallBack(); - context->ShowContainerTitle(false); } }); auto buttonResourceId = isFloating ? InternalResource::ResourceId::CONTAINER_MODAL_WINDOW_RECOVER @@ -210,11 +209,9 @@ std::list> ContainerModalComponent::BuildTitleChildren(bool is if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { LOGI("recover button clicked"); context->FireWindowRecoverCallBack(); - context->ShowContainerTitle(true); } else { LOGI("maximize button clicked"); context->FireWindowMaximizeCallBack(); - context->ShowContainerTitle(false); } } }); diff --git a/frameworks/core/components/container_modal/container_modal_element.cpp b/frameworks/core/components/container_modal/container_modal_element.cpp index e31668bf41b..04276331ae4 100644 --- a/frameworks/core/components/container_modal/container_modal_element.cpp +++ b/frameworks/core/components/container_modal/container_modal_element.cpp @@ -169,7 +169,6 @@ void ContainerModalElement::ShowTitle(bool isShow) if (floatingTitleDisplay_) { floatingTitleDisplay_->UpdateVisibleType(VisibleType::GONE); } - isFirstShowTitle_ = false; } void ContainerModalElement::PerformBuild() @@ -267,7 +266,7 @@ void ContainerModalElement::Update() bool ContainerModalElement::CanShowFloatingTitle() { auto context = context_.Upgrade(); - if (!context || !floatingTitleDisplay_ || !controller_ || isFirstShowTitle_) { + if (!context || !floatingTitleDisplay_ || !controller_) { LOGI("Show floating title failed, context, floatingTitleDisplay_ or controller is null."); return false; } diff --git a/frameworks/core/components/container_modal/container_modal_element.h b/frameworks/core/components/container_modal/container_modal_element.h index cd698f40af4..3431ff327ce 100644 --- a/frameworks/core/components/container_modal/container_modal_element.h +++ b/frameworks/core/components/container_modal/container_modal_element.h @@ -42,7 +42,6 @@ private: RefPtr floatingTitleBox_; RefPtr titleChildrenRow_; RefPtr floatingTitleChildrenRow_; - bool isFirstShowTitle_ = true; }; } // namespace OHOS::Ace diff --git a/interfaces/innerkits/ace/ui_content.h b/interfaces/innerkits/ace/ui_content.h index bd4fd67a067..a4b0ebc431e 100644 --- a/interfaces/innerkits/ace/ui_content.h +++ b/interfaces/innerkits/ace/ui_content.h @@ -34,6 +34,7 @@ class Configuration; namespace Rosen { class Window; enum class WindowSizeChangeReason : uint32_t; +enum class WindowMode : uint32_t; } namespace MMI { @@ -77,6 +78,7 @@ public: virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0; virtual void UpdateConfiguration(const std::shared_ptr& config) = 0; virtual void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) = 0; + virtual void UpdateWindowMode(OHOS::Rosen::WindowMode mode) = 0; virtual void DumpInfo(const std::vector& params, std::vector& info) = 0; }; -- Gitee