From c0cdac16c00f503879ee4012b1a1f98b4593ff5c Mon Sep 17 00:00:00 2001 From: yanansong Date: Wed, 20 Dec 2023 15:41:55 +0800 Subject: [PATCH] add interfce. it can set limit size --- .../interfaces/innerkits/wm/window.h | 11 ++++++ .../interfaces/innerkits/wm/window_option.h | 11 ++++++ .../utils/include/wm_common_inner.h | 1 + window_manager/utils/src/window_property.cpp | 6 +++ window_manager/wm/include/window_impl.h | 2 + window_manager/wm/src/window_impl.cpp | 23 +++++++++++ window_manager/wm/src/window_option.cpp | 39 +++++++++++++++++++ .../wmserver/src/window_controller.cpp | 4 ++ 8 files changed, 97 insertions(+) diff --git a/window_manager/interfaces/innerkits/wm/window.h b/window_manager/interfaces/innerkits/wm/window.h index 2ec00d9..b784e55 100644 --- a/window_manager/interfaces/innerkits/wm/window.h +++ b/window_manager/interfaces/innerkits/wm/window.h @@ -475,6 +475,17 @@ public: * @param configuration configuration for app */ virtual bool IsAllowHaveSystemSubWindow() = 0; + + /** + * @brief Update Limit size of window + * + * @param minWidth min width of window + * @param minHeight min height of window + * @param maxWidth max width of window + * @param maxHeight max height of window + */ + virtual WMError SetLimitSize(uint32_t minWidth, uint32_t minHeight, + uint32_t maxWidth, uint32_t maxHeight) = 0; }; } } diff --git a/window_manager/interfaces/innerkits/wm/window_option.h b/window_manager/interfaces/innerkits/wm/window_option.h index c712275..3b87050 100644 --- a/window_manager/interfaces/innerkits/wm/window_option.h +++ b/window_manager/interfaces/innerkits/wm/window_option.h @@ -52,6 +52,7 @@ public: void SetCallingWindow(uint32_t windowId); void SetMainHandlerAvailable(bool isMainHandlerAvailable); void SetDragHotZoneNone(bool hotZoneNone); + void SetWindowLimitSize(uint32_t minWidth, uint32_t minHeight, uint32_t maxWidth, uint32_t maxHeight); Rect GetWindowRect() const; WindowType GetWindowType() const; @@ -70,6 +71,11 @@ public: uint32_t GetCallingWindow() const; bool GetMainHandlerAvailable() const; bool GetDragHotZoneNone() const; + uint32_t GetWinMinWidth() const; + uint32_t GetWinMinHeight() const; + uint32_t GetWinMaxWidth() const; + uint32_t GetWinMaxHeight() const; + bool LimitSizeUpdated() const; private: Rect windowRect_ { 0, 0, 0, 0 }; @@ -94,6 +100,11 @@ private: }; Orientation requestedOrientation_ { Orientation::UNSPECIFIED }; bool dragHotZoneNone_ = false; + bool limitSizeUpdated_ = false; + uint32_t winMinWidth_ = 320; + uint32_t winMinHeight_ = 240; + uint32_t winMaxWidth_ = 1920; + uint32_t winMaxHeight_ = 1920; }; } // namespace Rosen } // namespace OHOS diff --git a/window_manager/utils/include/wm_common_inner.h b/window_manager/utils/include/wm_common_inner.h index 77267de..4c25ce0 100644 --- a/window_manager/utils/include/wm_common_inner.h +++ b/window_manager/utils/include/wm_common_inner.h @@ -79,6 +79,7 @@ enum class PropertyChangeAction : uint32_t { ACTION_UPDATE_TRANSFORM_PROPERTY = 1 << 13, ACTION_UPDATE_ANIMATION_FLAG = 1 << 14, ACTION_UPDATE_PRIVACY_MODE = 1 << 15, + ACTION_UPDATE_LIMIT_SIZE = 1 << 16, }; struct ModeChangeHotZonesConfig { diff --git a/window_manager/utils/src/window_property.cpp b/window_manager/utils/src/window_property.cpp index b40f852..1f56900 100644 --- a/window_manager/utils/src/window_property.cpp +++ b/window_manager/utils/src/window_property.cpp @@ -800,6 +800,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE: ret = ret && parcel.WriteBool(isPrivacyMode_); break; + case PropertyChangeAction::ACTION_UPDATE_LIMIT_SIZE: + ret = ret && MarshallingWindowSizeLimits(parcel); + break; default: break; } @@ -863,6 +866,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE: SetPrivacyMode(parcel.ReadBool()); break; + case PropertyChangeAction::ACTION_UPDATE_LIMIT_SIZE: + UnmarshallingWindowSizeLimits(parcel, this); + break; default: break; } diff --git a/window_manager/wm/include/window_impl.h b/window_manager/wm/include/window_impl.h index 30a3b7b..5cd0f11 100644 --- a/window_manager/wm/include/window_impl.h +++ b/window_manager/wm/include/window_impl.h @@ -268,6 +268,8 @@ public: virtual WMError NotifyMemoryLevel(int32_t level) const override; virtual bool IsAllowHaveSystemSubWindow() override; void RestoreSplitWindowMode(uint32_t mode); + virtual WMError SetLimitSize(uint32_t minWidth, uint32_t minHeight, + uint32_t maxWidth, uint32_t maxHeight) override; private: template using EnableIfSame = typename std::enable_if, Ret>::type; diff --git a/window_manager/wm/src/window_impl.cpp b/window_manager/wm/src/window_impl.cpp index b473ae7..3fe3753 100755 --- a/window_manager/wm/src/window_impl.cpp +++ b/window_manager/wm/src/window_impl.cpp @@ -87,6 +87,15 @@ WindowImpl::WindowImpl(const sptr& option) property_->SetTurnScreenOn(option->IsTurnScreenOn()); property_->SetKeepScreenOn(option->IsKeepScreenOn()); property_->SetBrightness(option->GetBrightness()); + if (option->LimitSizeUpdated()) { + WindowSizeLimits limits; + limits.minWidth_ = option->GetWinMinWidth(); + limits.minHeight_ = option->GetWinMinHeight(); + limits.maxWidth_ = option->GetWinMaxWidth(); + limits.maxHeight_ = option->GetWinMaxHeight(); + property_->SetSizeLimits(limits); + } + AdjustWindowAnimationFlag(); auto& sysBarPropMap = option->GetSystemBarProperty(); for (auto it : sysBarPropMap) { @@ -3230,5 +3239,19 @@ bool WindowImpl::IsAllowHaveSystemSubWindow() } return true; } + +WMError WindowImpl::SetLimitSize(uint32_t minWidth, uint32_t minHeight, uint32_t maxWidth, uint32_t maxHeight) +{ + if (!IsWindowValid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + WindowSizeLimits limits; + limits.minWidth_ = minWidth; + limits.minHeight_ = minHeight; + limits.maxWidth_ = maxWidth; + limits.maxHeight_ = maxHeight; + property_->SetSizeLimits(limits); + return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_LIMIT_SIZE); +} } // namespace Rosen } // namespace OHOS diff --git a/window_manager/wm/src/window_option.cpp b/window_manager/wm/src/window_option.cpp index a6fab16..3ae2887 100644 --- a/window_manager/wm/src/window_option.cpp +++ b/window_manager/wm/src/window_option.cpp @@ -229,6 +229,45 @@ bool WindowOption::GetDragHotZoneNone() const { return dragHotZoneNone_; } + +void WindowOption::SetWindowLimitSize(uint32_t minWidth, uint32_t minHeight, uint32_t maxWidth, uint32_t maxHeight) +{ + if (minWidth != 0 && minHeight != 0) { + winMinWidth_ = minWidth; + winMinHeight_ = minHeight; + limitSizeUpdated_ = true; + } + if (maxWidth != 0 && maxHeight != 0) { + winMaxWidth_ = maxWidth; + winMaxHeight_ = maxHeight; + limitSizeUpdated_ = true; + } +} + +uint32_t WindowOption::GetWinMinWidth() const +{ + return winMinWidth_; +} + +uint32_t WindowOption::GetWinMinHeight() const +{ + return winMinHeight_; +} + +uint32_t WindowOption::GetWinMaxWidth() const +{ + return winMaxWidth_; +} + +uint32_t WindowOption::GetWinMaxHeight() const +{ + return winMaxHeight_; +} + +bool WindowOption::LimitSizeUpdated() const +{ + return limitSizeUpdated_; +} } // namespace Rosen } // namespace OHOS diff --git a/window_manager/wmserver/src/window_controller.cpp b/window_manager/wmserver/src/window_controller.cpp index 67c1779..cb2d48a 100644 --- a/window_manager/wmserver/src/window_controller.cpp +++ b/window_manager/wmserver/src/window_controller.cpp @@ -1260,6 +1260,10 @@ WMError WindowController::UpdateProperty(sptr& property, Propert node->GetWindowProperty()->SetPrivacyMode(property->GetPrivacyMode()); break; } + case PropertyChangeAction::ACTION_UPDATE_LIMIT_SIZE: { + node->GetWindowProperty()->SetSizeLimits(property->GetSizeLimits()); + break; + } default: break; } -- Gitee