diff --git a/window_manager/interfaces/innerkits/wm/window.h b/window_manager/interfaces/innerkits/wm/window.h index 2ec00d9c78fa875e2758eb30db2a0da98496cb59..b784e5560c1b28fb1e2804305d33c73f52f3d0bc 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 c712275e3630397f9c54d11a927fd57d05f815ed..3b870509857188213a0edbfe1d7fe37461411b99 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 77267de1899628328060cefc345f06d8cceb5329..4c25ce00c7ac9439d7c4ec52c2f7db575cf523dd 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 b40f852801efd8285d0ac1921b4864b3530dc33a..1f56900616ed43330c7bbeede832bc763ff0c933 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 30a3b7be13dd7235679f94faf5762ca984a0de14..5cd0f11c2ddfc68a24f68b0dec9406a1fdf344ed 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 b473ae7ff22e429d2dd42f0658bba53a2d29c930..3fe375309b826a982ceb5ac59e856df8d8b31126 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 a6fab16a0b228d1f1dc04fdd14d9a7a94c104065..3ae28874b4b51d5d41a82b217f144b1d3f275d93 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 67c177964e76a59edefb0555f326acc60ef5a23e..cb2d48a0806676a99a845e8eb49c4d254ea467f5 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; }