mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
add dock window immersive
Signed-off-by: leafly2021 <figo.yefei@huawei.com> Change-Id: Ic3bc9aa2746a161ae1d8b02ecc55c7eb338a1611
This commit is contained in:
@@ -59,11 +59,26 @@ public:
|
||||
return ((IsMainWindow(type)) && (mode == WindowMode::WINDOW_MODE_FLOATING));
|
||||
}
|
||||
|
||||
static inline bool IsMainFullScreenWindow(WindowType type, WindowMode mode)
|
||||
{
|
||||
return ((IsMainWindow(type)) && (mode == WindowMode::WINDOW_MODE_FULLSCREEN));
|
||||
}
|
||||
|
||||
static inline bool IsFloatintWindow(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_FLOATING;
|
||||
}
|
||||
|
||||
static inline bool IsAvoidAreaWindow(WindowType type)
|
||||
{
|
||||
return (type == WindowType::WINDOW_TYPE_STATUS_BAR || type == WindowType::WINDOW_TYPE_NAVIGATION_BAR);
|
||||
}
|
||||
|
||||
static inline bool IsFullScreenWindow(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
}
|
||||
|
||||
static inline bool IsSplitWindowMode(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
|
||||
@@ -30,6 +30,13 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
using DisplayGroupWindowTree = std::map<DisplayId,
|
||||
std::map<WindowRootNodeType, std::unique_ptr<std::vector<sptr<WindowNode>>>>>;
|
||||
enum class DockWindowShowState : uint32_t {
|
||||
NOT_SHOWN = 0,
|
||||
SHOWN_IN_BOTTOM = 1,
|
||||
SHOWN_IN_LEFT = 2,
|
||||
SHOWN_IN_RIGHT = 3,
|
||||
SHOWN_IN_TOP = 4,
|
||||
};
|
||||
class WindowLayoutPolicy : public RefBase {
|
||||
public:
|
||||
WindowLayoutPolicy() = delete;
|
||||
@@ -59,6 +66,7 @@ protected:
|
||||
AvoidPosType GetAvoidPosType(const Rect& rect, DisplayId displayId) const;
|
||||
void CalcAndSetNodeHotZone(Rect layoutOutRect, const sptr<WindowNode>& node) const;
|
||||
void LimitFloatingWindowSize(const sptr<WindowNode>& node, const Rect& displayRect, Rect& winRect) const;
|
||||
void LimitMainFloatingWindowPositionWithDrag(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void LimitMainFloatingWindowPosition(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void ComputeDecoratedRequestRect(const sptr<WindowNode>& node) const;
|
||||
bool IsVerticalDisplay(DisplayId displayId) const;
|
||||
@@ -77,6 +85,7 @@ protected:
|
||||
void UpdateMultiDisplayFlag();
|
||||
void PostProcessWhenDisplayChange();
|
||||
void UpdateDisplayRectAndDisplayGroupInfo(const std::map<DisplayId, Rect>& displayRectMap);
|
||||
DockWindowShowState GetDockWindowShowState(DisplayId displayId, Rect& dockWinRect) const;
|
||||
|
||||
const std::set<WindowType> avoidTypes_ {
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
sptr<AvoidAreaController> GetAvoidController() const;
|
||||
sptr<DisplayGroupController> GetMutiDisplayController() const;
|
||||
sptr<WindowNode> GetRootNode(WindowRootNodeType type) const;
|
||||
void NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable);
|
||||
|
||||
private:
|
||||
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
|
||||
|
||||
@@ -186,17 +186,6 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
|
||||
}
|
||||
node->GetWindowProperty()->CopyFrom(property);
|
||||
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
|
||||
WindowHelper::IsAppWindow(node->GetWindowType()) && !node->isPlayAnimationShow_) {
|
||||
WM_SCOPED_TRACE_BEGIN("controller:MinimizeStructuredAppWindowsExceptSelf");
|
||||
WMError res = windowRoot_->MinimizeStructuredAppWindowsExceptSelf(node);
|
||||
WM_SCOPED_TRACE_END();
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("Minimize other structured window failed");
|
||||
MinimizeApp::ClearNodesWithReason(MinimizeReason::OTHER_WINDOW);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
// Need 'check permission'
|
||||
// Need 'adjust property'
|
||||
WMError res = windowRoot_->AddWindowNode(property->GetParentId(), node);
|
||||
@@ -213,7 +202,6 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
|
||||
sysBarWinId_[node->GetWindowType()] = node->GetWindowId();
|
||||
ReSizeSystemBarPropertySizeIfNeed(node);
|
||||
}
|
||||
|
||||
StopBootAnimationIfNeed(node->GetWindowType());
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
return WMError::WM_OK;
|
||||
|
||||
@@ -469,6 +469,74 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
|
||||
}
|
||||
}
|
||||
|
||||
DockWindowShowState WindowLayoutPolicy::GetDockWindowShowState(DisplayId displayId, Rect& dockWinRect) const
|
||||
{
|
||||
auto& displayWindowTree = displayGroupWindowTree_[displayId];
|
||||
auto& nodeVec = *(displayWindowTree[WindowRootNodeType::ABOVE_WINDOW_NODE]);
|
||||
for (auto& node : nodeVec) {
|
||||
if (node->GetWindowType() != WindowType::WINDOW_TYPE_LAUNCHER_DOCK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dockWinRect = node->GetWindowRect();
|
||||
auto displayRect = displayGroupInfo_->GetDisplayRect(displayId);
|
||||
WLOGFI("begin dockWinRect :[%{public}d, %{public}d, %{public}u, %{public}u]",
|
||||
dockWinRect.posX_, dockWinRect.posY_, dockWinRect.width_, dockWinRect.height_);
|
||||
if (dockWinRect.height_ < dockWinRect.width_) {
|
||||
if (static_cast<uint32_t>(dockWinRect.posY_) + dockWinRect.height_ == displayRect.height_) {
|
||||
return DockWindowShowState::SHOWN_IN_BOTTOM;
|
||||
} else {
|
||||
return DockWindowShowState::NOT_SHOWN;
|
||||
}
|
||||
} else {
|
||||
if (dockWinRect.posX_ == 0) {
|
||||
return DockWindowShowState::SHOWN_IN_LEFT;
|
||||
} else if (static_cast<uint32_t>(dockWinRect.posX_) + dockWinRect.width_ == displayRect.width_) {
|
||||
return DockWindowShowState::SHOWN_IN_RIGHT;
|
||||
} else {
|
||||
return DockWindowShowState::NOT_SHOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
return DockWindowShowState::NOT_SHOWN;
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LimitMainFloatingWindowPositionWithDrag(const sptr<WindowNode>& node, Rect& winRect) const
|
||||
{
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
float virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId());
|
||||
uint32_t windowTitleBarH = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * virtualPixelRatio);
|
||||
const Rect lastRect = node->GetWindowRect();
|
||||
// fix rect in case of moving window when dragging
|
||||
winRect = WindowHelper::GetFixedWindowRectByLimitSize(winRect, lastRect,
|
||||
IsVerticalDisplay(node->GetDisplayId()), virtualPixelRatio);
|
||||
|
||||
// if is mutiDisplay, the limit rect should be full limitRect when move or drag
|
||||
Rect limitRect;
|
||||
if (isMultiDisplay_) {
|
||||
limitRect = displayGroupLimitRect_;
|
||||
} else {
|
||||
limitRect = limitRectMap_[node->GetDisplayId()];
|
||||
}
|
||||
winRect = WindowHelper::GetFixedWindowRectByLimitPosition(winRect, lastRect,
|
||||
virtualPixelRatio, limitRect);
|
||||
Rect dockWinRect;
|
||||
DockWindowShowState dockShownState = GetDockWindowShowState(node->GetDisplayId(), dockWinRect);
|
||||
if (dockShownState == DockWindowShowState::SHOWN_IN_BOTTOM) {
|
||||
WLOGFI("dock window show in bottom");
|
||||
winRect.posY_ = std::min(dockWinRect.posY_ - static_cast<int32_t>(windowTitleBarH), winRect.posY_);
|
||||
} else if (dockShownState == DockWindowShowState::SHOWN_IN_LEFT) {
|
||||
WLOGFI("dock window show in left");
|
||||
winRect.posX_ = std::max(static_cast<int32_t>(dockWinRect.width_ + windowTitleBarH - winRect.width_),
|
||||
winRect.posX_);
|
||||
} else if (dockShownState == DockWindowShowState::SHOWN_IN_RIGHT) {
|
||||
WLOGFI("dock window show in right");
|
||||
winRect.posX_ = std::min(dockWinRect.posX_ - static_cast<int32_t>(windowTitleBarH),
|
||||
winRect.posX_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr<WindowNode>& node, Rect& winRect) const
|
||||
{
|
||||
float virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId());
|
||||
@@ -484,14 +552,30 @@ void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr<WindowNode>&
|
||||
|
||||
// limit position of the main floating window(window which support dragging)
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
Rect dockWinRect;
|
||||
DockWindowShowState dockShownState = GetDockWindowShowState(node->GetDisplayId(), dockWinRect);
|
||||
winRect.posY_ = std::max(limitRect.posY_, winRect.posY_);
|
||||
winRect.posY_ = std::min(limitRect.posY_ + static_cast<int32_t>(limitRect.height_ - windowTitleBarH),
|
||||
winRect.posY_);
|
||||
|
||||
if (dockShownState == DockWindowShowState::SHOWN_IN_BOTTOM) {
|
||||
WLOGFI("dock window show in bottom");
|
||||
winRect.posY_ = std::min(dockWinRect.posY_ + static_cast<int32_t>(dockWinRect.height_ - windowTitleBarH),
|
||||
winRect.posY_);
|
||||
}
|
||||
winRect.posX_ = std::max(limitRect.posX_ + static_cast<int32_t>(windowTitleBarH - winRect.width_),
|
||||
winRect.posX_);
|
||||
if (dockShownState == DockWindowShowState::SHOWN_IN_LEFT) {
|
||||
WLOGFI("dock window show in left");
|
||||
winRect.posX_ = std::max(static_cast<int32_t>(dockWinRect.width_ + windowTitleBarH - winRect.width_),
|
||||
winRect.posX_);
|
||||
}
|
||||
winRect.posX_ = std::min(limitRect.posX_ + static_cast<int32_t>(limitRect.width_ - windowTitleBarH),
|
||||
winRect.posX_);
|
||||
if (dockShownState == DockWindowShowState::SHOWN_IN_RIGHT) {
|
||||
WLOGFI("dock window show in right");
|
||||
winRect.posX_ = std::min(dockWinRect.posX_ - static_cast<int32_t>(windowTitleBarH),
|
||||
winRect.posX_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -238,29 +238,14 @@ 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();
|
||||
float virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId());
|
||||
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) { // if divider, limit position
|
||||
LimitMoveBounds(winRect, node->GetDisplayId());
|
||||
}
|
||||
|
||||
// if drag or move window, limit size and position
|
||||
if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::MOVE) {
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
const Rect lastRect = node->GetWindowRect();
|
||||
// fix rect in case of moving window when dragging
|
||||
winRect = WindowHelper::GetFixedWindowRectByLimitSize(winRect, lastRect,
|
||||
IsVerticalDisplay(node->GetDisplayId()), virtualPixelRatio);
|
||||
|
||||
// if is mutiDisplay, the limit rect should be full limitRect when move or drag
|
||||
Rect limitRect;
|
||||
if (isMultiDisplay_) {
|
||||
limitRect = displayGroupLimitRect_;
|
||||
} else {
|
||||
limitRect = limitRectMap_[node->GetDisplayId()];
|
||||
}
|
||||
winRect = WindowHelper::GetFixedWindowRectByLimitPosition(winRect, lastRect,
|
||||
virtualPixelRatio, limitRect);
|
||||
}
|
||||
LimitMainFloatingWindowPositionWithDrag(node, winRect);
|
||||
} else {
|
||||
// Limit window to the maximum window size if size change is other reason, such as init window rect when show
|
||||
LimitFloatingWindowSize(node, displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), winRect);
|
||||
|
||||
@@ -300,6 +300,9 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
|
||||
} else {
|
||||
NotifyIfSystemBarTintChanged(node->GetDisplayId());
|
||||
}
|
||||
if (WindowHelper::IsMainFullScreenWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
NotifyDockWindowStateChanged(node, true);
|
||||
}
|
||||
UpdateWindowVisibilityInfos(infos);
|
||||
DumpScreenWindowTree();
|
||||
NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_REMOVED);
|
||||
@@ -837,6 +840,30 @@ void WindowNodeContainer::NotifySystemBarTints(std::vector<DisplayId> displayIdV
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNodeContainer::NotifyDockWindowStateChanged(sptr<WindowNode>& node, bool isEnable)
|
||||
{
|
||||
WM_FUNCTION_TRACE();
|
||||
WLOGFI("begin isEnable: %{public}d", isEnable);
|
||||
if (!isEnable) {
|
||||
for (auto& windowNode : appWindowNode_->children_) {
|
||||
if (windowNode->GetWindowId() == node->GetWindowId()) {
|
||||
continue;
|
||||
}
|
||||
if (!WindowHelper::IsFloatintWindow(windowNode->GetWindowMode())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemBarProperty prop;
|
||||
prop.enable_ = isEnable;
|
||||
SystemBarRegionTint tint;
|
||||
tint.type_ = WindowType::WINDOW_TYPE_LAUNCHER_DOCK;
|
||||
tint.prop_ = prop;
|
||||
SystemBarRegionTints tints;
|
||||
tints.push_back(tint);
|
||||
WindowManagerAgentController::GetInstance().UpdateSystemBarRegionTints(node->GetDisplayId(), tints);
|
||||
}
|
||||
|
||||
bool WindowNodeContainer::IsTopWindow(uint32_t windowId, sptr<WindowNode>& rootNode) const
|
||||
{
|
||||
if (rootNode->children_.empty()) {
|
||||
@@ -1617,6 +1644,14 @@ WMError WindowNodeContainer::SetWindowMode(sptr<WindowNode>& node, WindowMode ds
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
windowPair->UpdateIfSplitRelated(node);
|
||||
if (WindowHelper::IsMainWindow(node->GetWindowType())) {
|
||||
if (WindowHelper::IsFloatintWindow(node->GetWindowMode())) {
|
||||
NotifyDockWindowStateChanged(node, true);
|
||||
} else {
|
||||
NotifyDockWindowStateChanged(node, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
|
||||
WindowHelper::IsAppWindow(node->GetWindowType())) {
|
||||
// minimize other app window
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "window_manager_service.h"
|
||||
#include "wm_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -209,6 +210,7 @@ WMError WindowRoot::SaveWindow(const sptr<WindowNode>& node)
|
||||
|
||||
WMError WindowRoot::MinimizeStructuredAppWindowsExceptSelf(sptr<WindowNode>& node)
|
||||
{
|
||||
WM_SCOPED_TRACE("root:MinimizeStructuredAppWindowsExceptSelf");
|
||||
auto container = GetOrCreateWindowNodeContainer(node->GetDisplayId());
|
||||
if (container == nullptr) {
|
||||
WLOGFE("MinimizeAbility failed, window container could not be found");
|
||||
@@ -364,6 +366,16 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, boo
|
||||
WLOGFE("add window failed, window container could not be found");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
|
||||
WindowHelper::IsAppWindow(node->GetWindowType()) && !node->isPlayAnimationShow_) {
|
||||
container->NotifyDockWindowStateChanged(node, false);
|
||||
WMError res = MinimizeStructuredAppWindowsExceptSelf(node);
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("Minimize other structured window failed");
|
||||
MinimizeApp::ClearNodesWithReason(MinimizeReason::OTHER_WINDOW);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if (fromStartingWin) {
|
||||
return container->ShowStartingWindow(node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user