diff --git a/wayland_adapter/framework/core/wayland_surface.cpp b/wayland_adapter/framework/core/wayland_surface.cpp index d8b177e8128d22043e5139b1c3d865af60ab884b..98340024a9eaeb42917752dfd1b6ea927aaff56c 100644 --- a/wayland_adapter/framework/core/wayland_surface.cpp +++ b/wayland_adapter/framework/core/wayland_surface.cpp @@ -403,7 +403,12 @@ void WaylandSurface::Commit() if (!isSubSurface_ && window_ == nullptr) { CreateWindow(); } - + if (window_ != nullptr && updateWindowLimitSize_ && !windowOptionExt_->fixedWindowSize && + windowOptionExt_->limitSizeGot) { + window_->SetLimitSize(windowOptionExt_->minWidth, windowOptionExt_->minHeight, + windowOptionExt_->maxWidth, windowOptionExt_->maxHeight); + updateWindowLimitSize_ = false; + } HandleCommit(); for (auto &cb : commitCallbacks_) { cb(); @@ -502,6 +507,9 @@ void WaylandSurface::CreateWindow() static int count = 0; std::string windowName = "WaylandWindow" + std::to_string(count++); + if (windowOptionExt_->fixedWindowSize) { + windowOption_->SetDragHotZoneNone(true); + } window_ = OHOS::Rosen::Window::Create(windowName, windowOption_); if (window_ == nullptr) { LOG_ERROR("Window::Create failed"); diff --git a/wayland_adapter/framework/core/wayland_surface.h b/wayland_adapter/framework/core/wayland_surface.h index e97939ce734c81e022a8087f4510e6a49e8525e7..65cd8f83a18f578913d5409ae23bc230626b8d9c 100644 --- a/wayland_adapter/framework/core/wayland_surface.h +++ b/wayland_adapter/framework/core/wayland_surface.h @@ -145,6 +145,7 @@ private: std::mutex bitmapMutex_; SkBitmap srcBitmap_; std::vector> pengindCb_; + bool updateWindowLimitSize_ = true; }; } // namespace Wayland } // namespace FT diff --git a/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp b/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp index dbf9d998a9f2bd141fef6ef3de4882427aedace5..876f08094c484d872f34f4fd8715f594f3741710 100644 --- a/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp +++ b/wayland_adapter/framework/stable/wayland_xdg_toplevel.cpp @@ -194,24 +194,27 @@ void WaylandXdgToplevel::SetMaxSize(int32_t width, int32_t height) { maxW_ = width; maxH_ = height; - if (maxW_ == 0 || maxH_ == 0 ){ - return; - } + windowOptionExt_->maxWidth = width; + windowOptionExt_->maxHeight = height; + windowOptionExt_->limitSizeGot = true; if (minW_ == maxW_ && minH_ == maxH_) { - windowOption_->SetDragHotZoneNone(true); + if (maxW_ != 0 && maxH_!= 0) { + windowOptionExt_->fixedWindowSize = true; + } } - LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); } void WaylandXdgToplevel::SetMinSize(int32_t width, int32_t height) { minW_ = width; minH_ = height; - if (minW_ == 0 || minH_ == 0 ){ - return; - } + windowOptionExt_->minWidth = width; + windowOptionExt_->minHeight = height; + windowOptionExt_->limitSizeGot = true; if (minW_ == maxW_ && minH_ == maxH_) { - windowOption_->SetDragHotZoneNone(true); + if (maxW_ != 0 && maxH_!= 0) { + windowOptionExt_->fixedWindowSize = true; + } } LOG_DEBUG("Window %{public}s.", windowTitle_.c_str()); } diff --git a/wayland_adapter/framework/stable/wayland_xdg_toplevel.h b/wayland_adapter/framework/stable/wayland_xdg_toplevel.h index 08fe41c90b7c47a0888e06b6ec1a5a22b92284a5..92ac42079603cd03e868f8e9b1a996d08a90322e 100644 --- a/wayland_adapter/framework/stable/wayland_xdg_toplevel.h +++ b/wayland_adapter/framework/stable/wayland_xdg_toplevel.h @@ -84,6 +84,9 @@ private: uint32_t minH_ = 0; uint32_t maxW_ = 0; uint32_t maxH_ = 0; + bool toplevelFixedSize_ = false; + bool minSizeGot_ = false; + bool maxSizeGot_ = false; }; } // namespace Wayland } // namespace FT diff --git a/wayland_adapter/utils/include/wayland_utils.h b/wayland_adapter/utils/include/wayland_utils.h index 7b58f2807a56a911ab466325081887a1fb120fe6..ce0b314c6bd2246234b140f48a2f029703fb8736 100644 --- a/wayland_adapter/utils/include/wayland_utils.h +++ b/wayland_adapter/utils/include/wayland_utils.h @@ -47,6 +47,12 @@ struct WindowOptionExt { bool maximizeAfterShow = false; bool fullscreenAfterShow = false; bool minimizeAfterShow = false; + bool fixedWindowSize = false; + bool limitSizeGot = false; + uint32_t minWidth = 0; + uint32_t minHeight = 0; + uint32_t maxWidth = 0; + uint32_t maxHeight = 0; std::string title; };