From 39c5cecb5a7d7add77680dd8afbb55cfebaa5941 Mon Sep 17 00:00:00 2001 From: leafly2021 Date: Fri, 21 Jan 2022 13:05:54 +0800 Subject: [PATCH] add isDecorEnable to prop Signed-off-by: leafly2021 Change-Id: I301c36b4d986c57d68c441e10e2916d893253646 --- interfaces/innerkits/wm/window.h | 2 +- utils/include/window_property.h | 3 +++ utils/src/window_property.cpp | 16 ++++++++++++++++ wm/include/window_impl.h | 3 +-- wm/src/window_impl.cpp | 8 ++++---- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 7e2d70aa..93406adc 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -97,7 +97,7 @@ public: NativeValue* storage, bool isdistributed = false) = 0; virtual const std::string& GetContentInfo() = 0; - virtual bool IsDecorEnable() = 0; + virtual bool IsDecorEnable() const = 0; virtual WMError Maximize() = 0; virtual WMError Minimize() = 0; virtual WMError Recover() = 0; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 10ca0bba..11c9e0e8 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -44,6 +44,7 @@ public: void SetParentId(uint32_t parentId); void SetWindowFlags(uint32_t flags); void SetSystemBarProperty(WindowType type, const SystemBarProperty& state); + void SetDecorEnable(bool decorEnable); Rect GetWindowRect() const; WindowType GetWindowType() const; @@ -59,6 +60,7 @@ public: uint32_t GetParentId() const; uint32_t GetWindowFlags() const; const std::unordered_map& GetSystemBarProperty() const; + bool GetDecorEnable() const; virtual bool Marshalling(Parcel& parcel) const override; static sptr Unmarshalling(Parcel& parcel); @@ -81,6 +83,7 @@ private: { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() }, { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() }, }; + bool isDecorEnable_ { false }; bool MapMarshalling(Parcel& parcel) const; static void MapUnmarshalling(Parcel& parcel, sptr& property); }; diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index f04d0554..c112ffa7 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -86,6 +86,11 @@ void WindowProperty::SetSystemBarProperty(WindowType type, const SystemBarProper } } +void WindowProperty::SetDecorEnable(bool decorEnable) +{ + isDecorEnable_ = decorEnable; +} + void WindowProperty::ResumeLastWindowMode() { mode_ = lastMode_; @@ -151,6 +156,11 @@ const std::unordered_map& WindowProperty::GetSyst return sysBarPropMap_; } +bool WindowProperty::GetDecorEnable() const +{ + return isDecorEnable_; +} + // TODO void WindowProperty::SetWindowId(uint32_t windowId) { @@ -272,6 +282,11 @@ bool WindowProperty::Marshalling(Parcel& parcel) const if (!MapMarshalling(parcel)) { return false; } + + // write isDecorEnable_ + if (!parcel.WriteBool(isDecorEnable_)) { + return false; + } return true; } @@ -293,6 +308,7 @@ sptr WindowProperty::Unmarshalling(Parcel& parcel) property->SetWindowId(parcel.ReadUint32()); property->SetParentId(parcel.ReadUint32()); MapUnmarshalling(parcel, property); + property->SetDecorEnable(parcel.ReadBool()); return property; } } diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 1169bcda..40377cd7 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -69,7 +69,7 @@ public: virtual WMError MoveTo(int32_t x, int32_t y) override; virtual WMError Resize(uint32_t width, uint32_t height) override; - virtual bool IsDecorEnable() override; + virtual bool IsDecorEnable() const override; virtual WMError Maximize() override; virtual WMError Minimize() override; virtual WMError Recover() override; @@ -147,7 +147,6 @@ private: std::unique_ptr uiContent_; std::shared_ptr abilityContext_; // give up when context offer getToken std::shared_ptr context_; - bool isDecorEnable_ = false; const float STATUS_BAR_RATIO = 0.07; const float NAVIGATION_BAR_RATIO = 0.07; const float SYSTEM_ALARM_WINDOW_WIDTH_RATIO = 0.8; diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 74741926..3bda4f56 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -218,9 +218,9 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo, return WMError::WM_ERROR_NULLPTR; } if (WindowHelper::IsMainWindow(property_->GetWindowType())) { - isDecorEnable_ = true; + property_->SetDecorEnable(true); } else { - isDecorEnable_ = false; + property_->SetDecorEnable(false); } if (isdistributed) { uiContent_->Restore(this, contentInfo, storage); @@ -426,9 +426,9 @@ WMError WindowImpl::Resize(uint32_t width, uint32_t height) return SingletonContainer::Get().Resize(property_->GetWindowId(), width, height); } -bool WindowImpl::IsDecorEnable() +bool WindowImpl::IsDecorEnable() const { - return isDecorEnable_; + return property_->GetDecorEnable(); } WMError WindowImpl::Maximize()