mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-20 01:13:32 -04:00
!1178 限制整个分屏条一直在屏幕范围内
Merge pull request !1178 from 王良江/br_wlj_limit_dockslice
This commit is contained in:
@@ -55,7 +55,7 @@ private:
|
||||
void LayoutWindowNode(const sptr<WindowNode>& node) override;
|
||||
void LayoutWindowTree(DisplayId displayId) override;
|
||||
void InitLimitRects(DisplayId displayId);
|
||||
void LimitMoveBounds(Rect& rect, DisplayId displayId) const;
|
||||
void LimitDividerMoveBounds(Rect& rect, DisplayId displayId) const;
|
||||
void InitCascadeRect(DisplayId displayId);
|
||||
void SetCascadeRect(const sptr<WindowNode>& node);
|
||||
void ApplyWindowRectConstraints(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
|
||||
@@ -204,26 +204,22 @@ void WindowLayoutPolicyCascade::SetSplitDividerWindowRects(std::map<DisplayId, R
|
||||
restoringDividerWindowRects_ = dividerWindowRects;
|
||||
}
|
||||
|
||||
void WindowLayoutPolicyCascade::LimitMoveBounds(Rect& rect, DisplayId displayId) const
|
||||
void WindowLayoutPolicyCascade::LimitDividerMoveBounds(Rect& rect, DisplayId displayId) const
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio(displayId);
|
||||
uint32_t minHorizontalSplitW = static_cast<uint32_t>(MIN_HORIZONTAL_SPLIT_WIDTH * virtualPixelRatio);
|
||||
uint32_t minVerticalSplitH = static_cast<uint32_t>(MIN_VERTICAL_SPLIT_HEIGHT * virtualPixelRatio);
|
||||
|
||||
const Rect& limitRect = limitRectMap_[displayId];
|
||||
if (rect.width_ < rect.height_) {
|
||||
if (rect.posX_ < (limitRect.posX_ + static_cast<int32_t>(minHorizontalSplitW))) {
|
||||
rect.posX_ = limitRect.posX_ + static_cast<int32_t>(minHorizontalSplitW);
|
||||
} else if (rect.posX_ >
|
||||
(limitRect.posX_ + static_cast<int32_t>(limitRect.width_ - minHorizontalSplitW))) {
|
||||
rect.posX_ = limitRect.posX_ + static_cast<int32_t>(limitRect.width_ - minHorizontalSplitW);
|
||||
if (rect.posX_ < limitRect.posX_) {
|
||||
rect.posX_ = limitRect.posX_;
|
||||
} else if (rect.posX_ + static_cast<int32_t>(rect.width_) >
|
||||
limitRect.posX_ + static_cast<int32_t>(limitRect.width_)) {
|
||||
rect.posX_ = limitRect.posX_ + static_cast<int32_t>(limitRect.width_ - rect.width_);
|
||||
}
|
||||
} else {
|
||||
if (rect.posY_ < (limitRect.posY_ + static_cast<int32_t>(minVerticalSplitH))) {
|
||||
rect.posY_ = limitRect.posY_ + static_cast<int32_t>(minVerticalSplitH);
|
||||
} else if (rect.posY_ >
|
||||
(limitRect.posY_ + static_cast<int32_t>(limitRect.height_ - minVerticalSplitH))) {
|
||||
rect.posY_ = limitRect.posY_ + static_cast<int32_t>(limitRect.height_ - minVerticalSplitH);
|
||||
if (rect.posY_ < limitRect.posY_) {
|
||||
rect.posY_ = limitRect.posY_;
|
||||
} else if (rect.posY_ + static_cast<int32_t>(rect.height_) >
|
||||
limitRect.posY_ + static_cast<int32_t>(limitRect.height_)) {
|
||||
rect.posY_ = limitRect.posY_ + static_cast<int32_t>(limitRect.height_ - rect.height_);
|
||||
}
|
||||
}
|
||||
WLOGFI("limit divider move bounds:[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
@@ -260,13 +256,16 @@ void WindowLayoutPolicyCascade::ApplyWindowRectConstraints(const sptr<WindowNode
|
||||
WLOGFI("Before apply constraints winRect:[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
auto reason = node->GetWindowSizeChangeReason();
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE &&
|
||||
reason == WindowSizeChangeReason::DRAG_END) {
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
if (!IsVerticalDisplay(displayId)) {
|
||||
UpdateDockSlicePosition(displayId, winRect.posX_);
|
||||
} else {
|
||||
UpdateDockSlicePosition(displayId, winRect.posY_);
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
// make sure the divider is entirely within display
|
||||
LimitDividerMoveBounds(winRect, displayId);
|
||||
if (reason == WindowSizeChangeReason::DRAG_END) {
|
||||
if (!IsVerticalDisplay(displayId)) {
|
||||
UpdateDockSlicePosition(displayId, winRect.posX_);
|
||||
} else {
|
||||
UpdateDockSlicePosition(displayId, winRect.posY_);
|
||||
}
|
||||
}
|
||||
}
|
||||
LimitFloatingWindowSize(node, displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), winRect);
|
||||
|
||||
Reference in New Issue
Block a user