fix toggle split window states bug

Signed-off-by: xiaojianfeng <xiaojianfeng3@huawei.com>
Change-Id: Iab9fcb834ac0ee71fe3a38efedec4b661de07515
This commit is contained in:
xiaojianfeng
2022-06-28 15:12:13 +08:00
parent 7f1856ad64
commit 6961ba0814
6 changed files with 56 additions and 49 deletions
+1 -2
View File
@@ -2023,8 +2023,7 @@ void WindowImpl::UpdateWindowState(WindowState state)
WLOGFD("MinimizeAbility, id: %{public}u", GetWindowId());
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(abilityContext->GetToken(), true);
} else {
state_ = WindowState::STATE_HIDDEN;
NotifyAfterBackground();
Hide(static_cast<uint32_t>(WindowStateChangeReason::TOGGLING));
}
break;
}
+2
View File
@@ -76,6 +76,7 @@ public:
void MinimizeAllAppWindows(DisplayId displayId);
void MinimizeOldestAppWindow();
WMError ToggleShownStateForAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc, bool restore);
void BackUpAllAppWindows();
void RestoreAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc);
bool IsAppWindowsEmpty() const;
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
@@ -160,6 +161,7 @@ private:
std::vector<uint32_t> backupWindowIds_;
std::map<uint32_t, WindowMode> backupWindowMode_;
std::map<DisplayId, Rect> backupDividerWindowRect_;
std::map<DisplayId, std::set<WindowMode>> backupDisplaySplitWindowMode_;
sptr<WindowZorderPolicy> zorderPolicy_ = new WindowZorderPolicy();
std::unordered_map<WindowLayoutMode, sptr<WindowLayoutPolicy>> layoutPolicies_;
WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE;
+2 -8
View File
@@ -17,6 +17,7 @@
#define OHOS_ROSEN_WINDOW_PAIR_H
#include <refbase.h>
#include "class_var_definition.h"
#include "window_inner_manager.h"
#include "window_node.h"
#include "window_layout_policy.h"
@@ -171,13 +172,6 @@ public:
*/
bool IsDockSliceInExitSplitModeArea(const std::vector<int32_t>& exitSplitPoints);
/**
* Set all app windows are restoring.
*
* @param ratio Indicates whether all app windows are restoring.
*/
void SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring);
void SetInitalDividerRect(const Rect& rect);
private:
@@ -252,8 +246,8 @@ private:
sptr<WindowNode> divider_;
WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY};
DisplayGroupWindowTree& displayGroupWindowTree_;
bool isAllAppWindowsRestoring_ { false };
Rect initalDividerRect_ {0, 0, 0, 0};
DEFINE_VAR_DEFAULT_FUNC_SET(bool, AllSplitAppWindowsRestoring, isAllSplitAppWindowsRestoring, false)
};
} // namespace Rosen
} // namespace OHOS
+49 -27
View File
@@ -1387,44 +1387,29 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows(
std::function<bool(uint32_t, WindowMode)> restoreFunc, bool restore)
{
WLOGFI("ToggleShownStateForAllAppWindows");
sptr<WindowNode> recentWindowNode = nullptr;
for (auto node : aboveAppWindowNode_->children_) {
if (node->GetWindowType() == WindowType::WINDOW_TYPE_LAUNCHER_RECENT) {
return WMError::WM_DO_NOTHING;
recentWindowNode = node;
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
return WMError::WM_OK;
}
}
}
// to do, backup reentry: 1.ToggleShownStateForAllAppWindows fast; 2.this display should reset backupWindowIds_.
if (!restore && appWindowNode_->children_.empty() && !backupWindowIds_.empty()) {
backupWindowIds_.clear();
backupWindowMode_.clear();
backupDisplaySplitWindowMode_.clear();
backupDividerWindowRect_.clear();
}
if (!restore && !appWindowNode_->children_.empty() && backupWindowIds_.empty()) {
WLOGFI("backup");
std::set<DisplayId> displayIdSet;
backupWindowMode_.clear();
for (auto& appNode : appWindowNode_->children_) {
// exclude exceptional window
if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) {
WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId());
continue;
}
// minimize window
WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId());
backupWindowIds_.emplace_back(appNode->GetWindowId());
backupWindowMode_[appNode->GetWindowId()] = appNode->GetWindowMode();
displayIdSet.insert(appNode->GetDisplayId());
if (appNode->GetWindowToken()) {
appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
}
}
backupDividerWindowRect_.clear();
for (auto displayId : displayIdSet) {
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) {
continue;
}
backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect();
if (recentWindowNode != nullptr && recentWindowNode->GetWindowToken() != nullptr) {
WLOGFI("hide recent");
recentWindowNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
}
BackUpAllAppWindows();
} else if (restore && !backupWindowIds_.empty()) {
WLOGFI("restore");
RestoreAllAppWindows(restoreFunc);
@@ -1434,6 +1419,40 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows(
return WMError::WM_OK;
}
void WindowNodeContainer::BackUpAllAppWindows()
{
std::set<DisplayId> displayIdSet;
backupWindowMode_.clear();
backupDisplaySplitWindowMode_.clear();
for (auto& appNode : appWindowNode_->children_) {
// exclude exceptional window
if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) {
WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId());
continue;
}
// minimize window
WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId());
backupWindowIds_.emplace_back(appNode->GetWindowId());
auto windowMode = appNode->GetWindowMode();
backupWindowMode_[appNode->GetWindowId()] = windowMode;
if (WindowHelper::IsSplitWindowMode(windowMode)) {
backupDisplaySplitWindowMode_[appNode->GetWindowId()].insert(windowMode);
}
displayIdSet.insert(appNode->GetDisplayId());
if (appNode->GetWindowToken()) {
appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
}
}
backupDividerWindowRect_.clear();
for (auto displayId : displayIdSet) {
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) {
continue;
}
backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect();
}
}
void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc)
{
std::vector<uint32_t> backupWindowIds(backupWindowIds_);
@@ -1442,7 +1461,10 @@ void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, Wind
for (auto displayId : displayIds) {
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
if (windowPair != nullptr) {
windowPair->SetAllAppWindowsRestoring(true);
if (backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_PRIMARY) > 0 &&
backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_SECONDARY) > 0) {
windowPair->SetAllSplitAppWindowsRestoring(true);
}
windowPairs.emplace_back(windowPair);
}
}
@@ -1454,7 +1476,7 @@ void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, Wind
WLOGFD("restore %{public}u", windowId);
}
for (auto windowPair : windowPairs) {
windowPair->SetAllAppWindowsRestoring(false);
windowPair->SetAllSplitAppWindowsRestoring(false);
}
layoutPolicy_->SetSplitDividerWindowRects(backupDividerWindowRect_);
backupWindowIds_.clear();
+1 -6
View File
@@ -331,7 +331,7 @@ void WindowPair::UpdateIfSplitRelated(sptr<WindowNode>& node)
status_, node->GetWindowId(), node->GetWindowMode());
if (status_ == WindowPairStatus::STATUS_EMPTY) {
Insert(node);
if (!isAllAppWindowsRestoring_) {
if (!isAllSplitAppWindowsRestoring_) {
// find pairable window from trees or send broadcast
sptr<WindowNode> pairableNode = GetPairableWindow(node);
// insert pairable node
@@ -487,11 +487,6 @@ void WindowPair::HandleRemoveWindow(sptr<WindowNode>& node)
}
}
void WindowPair::SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring)
{
isAllAppWindowsRestoring_ = isAllAppWindowsRestoring;
}
void WindowPair::SetInitalDividerRect(const Rect& rect)
{
initalDividerRect_ = rect;
+1 -6
View File
@@ -395,12 +395,7 @@ WMError WindowRoot::ToggleShownStateForAllAppWindows()
WindowManagerService::GetInstance().HandleAddWindow(property);
return true;
};
WMError tmpRes = WMError::WM_OK;
if (isAllAppWindowsEmpty) {
tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, true);
} else {
tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, false);
}
WMError tmpRes = tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, isAllAppWindowsEmpty);
res = (res == WMError::WM_OK) ? tmpRes : res;
});
return res;