mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-08-27 23:09:59 -04:00
@@ -72,6 +72,7 @@ ohos_shared_library("libwms") {
|
||||
"src/drag_controller.cpp",
|
||||
"src/freeze_controller.cpp",
|
||||
"src/input_window_monitor.cpp",
|
||||
"src/minimize_app.cpp",
|
||||
"src/remote_animation.cpp",
|
||||
"src/starting_window.cpp",
|
||||
"src/window_controller.cpp",
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_MINIMIZE_APP_H
|
||||
#define OHOS_ROSEN_MINIMIZE_APP_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <refbase.h>
|
||||
#include "wm_common.h"
|
||||
#include "window_node.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
enum class MinimizeReason : uint32_t {
|
||||
MINIMIZE_BUTTOM,
|
||||
MINIMIZE_ALL,
|
||||
LAYOUT_TILE,
|
||||
MAX_APP_COUNT,
|
||||
OTHER_WINDOW,
|
||||
};
|
||||
|
||||
class MinimizeApp : public RefBase {
|
||||
public:
|
||||
MinimizeApp() = delete;
|
||||
~MinimizeApp() = default;
|
||||
|
||||
static void AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason);
|
||||
static void ExecuteMinimizeAll();
|
||||
static void ExecuteMinimizeTargetReason(MinimizeReason reason);
|
||||
static void SetMinimizedByOtherConfig(bool isMinimizedByOther);
|
||||
|
||||
private:
|
||||
static inline bool IsFromUser(MinimizeReason reason)
|
||||
{
|
||||
return (reason == MinimizeReason::MINIMIZE_ALL || reason == MinimizeReason::MINIMIZE_BUTTOM ||
|
||||
reason == MinimizeReason::MAX_APP_COUNT || reason == MinimizeReason::LAYOUT_TILE);
|
||||
}
|
||||
|
||||
static std::map<MinimizeReason, std::vector<sptr<WindowNode>>> needMinimizeAppNodes_;
|
||||
static bool isMinimizedByOtherWindow_;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
#endif // OHOS_ROSEN_MINIMIZE_APP_H
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <ui/rs_display_node.h>
|
||||
#include "avoid_area_controller.h"
|
||||
#include "display_info.h"
|
||||
#include "minimize_app.h"
|
||||
#include "window_layout_policy.h"
|
||||
#include "window_manager.h"
|
||||
#include "window_node.h"
|
||||
@@ -75,7 +76,7 @@ public:
|
||||
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
|
||||
void NotifySystemBarTints(std::vector<DisplayId> displayIdVec);
|
||||
void NotifySystemBarDismiss(sptr<WindowNode>& node);
|
||||
WMError MinimizeAppNodeExceptOptions(bool fromUser, const std::vector<uint32_t> &exceptionalIds = {},
|
||||
WMError MinimizeAppNodeExceptOptions(MinimizeReason reason, const std::vector<uint32_t> &exceptionalIds = {},
|
||||
const std::vector<WindowMode> &exceptionalModes = {});
|
||||
WMError SetWindowMode(sptr<WindowNode>& node, WindowMode dstMode);
|
||||
WMError SwitchLayoutPolicy(WindowLayoutMode mode, DisplayId displayId, bool reorder = false);
|
||||
@@ -120,7 +121,6 @@ private:
|
||||
bool IsTopWindow(uint32_t windowId, sptr<WindowNode>& rootNode) const;
|
||||
sptr<WindowNode> FindDividerNode() const;
|
||||
void RaiseWindowToTop(uint32_t windowId, std::vector<sptr<WindowNode>>& windowNodes);
|
||||
void MinimizeWindowFromAbility(const sptr<WindowNode>& node, bool fromUser);
|
||||
void ResetLayoutPolicy();
|
||||
bool IsAboveSystemBarNode(sptr<WindowNode> node) const;
|
||||
bool IsFullImmersiveNode(sptr<WindowNode> node) const;
|
||||
@@ -173,7 +173,6 @@ private:
|
||||
std::map<DisplayId, sptr<DisplayInfo>> displayInfosMap_;
|
||||
|
||||
WindowNodeMaps windowNodeMaps_;
|
||||
bool isMinimizedByOther_ = true;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -76,7 +76,6 @@ public:
|
||||
void UpdateFocusableProperty(uint32_t windowId);
|
||||
WMError GetAccessibilityWindowInfo(sptr<AccessibilityWindowInfo>& windowInfo);
|
||||
void SetMaxAppWindowNumber(int windowNum);
|
||||
void SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow);
|
||||
WMError GetModeChangeHotZones(DisplayId displayId,
|
||||
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config);
|
||||
void NotifyVirtualPixelRatioChange(sptr<DisplayInfo> displayInfo);
|
||||
@@ -105,7 +104,6 @@ private:
|
||||
std::map<ScreenId, std::vector<DisplayId>> displayIdMap_;
|
||||
|
||||
bool needCheckFocusWindow = false;
|
||||
bool isMinimizedByOtherWindow_ = true;
|
||||
|
||||
std::map<WindowManagerAgentType, std::vector<sptr<IWindowManagerAgent>>> windowManagerAgents_;
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "minimize_app.h"
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "MinimizeApp"};
|
||||
}
|
||||
|
||||
std::map<MinimizeReason, std::vector<sptr<WindowNode>>> MinimizeApp::needMinimizeAppNodes_;
|
||||
bool MinimizeApp::isMinimizedByOtherWindow_ = true;
|
||||
|
||||
void MinimizeApp::AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason)
|
||||
{
|
||||
WLOGFI("[Minimize] Add Window %{public}u to minimize list, reason %{public}u", node->GetWindowId(), reason);
|
||||
needMinimizeAppNodes_[reason].emplace_back(node);
|
||||
}
|
||||
|
||||
void MinimizeApp::ExecuteMinimizeAll()
|
||||
{
|
||||
for (auto& appNodes: needMinimizeAppNodes_) {
|
||||
bool isFromUser = IsFromUser(appNodes.first);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto& node : appNodes.second) {
|
||||
if (node->abilityToken_ != nullptr) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u", node->GetWindowId(), appNodes.first);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, isFromUser);
|
||||
}
|
||||
}
|
||||
appNodes.second.clear();
|
||||
}
|
||||
needMinimizeAppNodes_.clear();
|
||||
}
|
||||
|
||||
void MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason reason)
|
||||
{
|
||||
if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) {
|
||||
bool isFromUser = IsFromUser(reason);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
return;
|
||||
}
|
||||
for (auto& node : needMinimizeAppNodes_.at(reason)) {
|
||||
if (node->abilityToken_ != nullptr) {
|
||||
WLOGFI("[Minimize] Minimize Window %{public}u, reason %{public}u", node->GetWindowId(), reason);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, isFromUser);
|
||||
}
|
||||
}
|
||||
needMinimizeAppNodes_.at(reason).clear();
|
||||
}
|
||||
}
|
||||
|
||||
void MinimizeApp::SetMinimizedByOtherConfig(bool isMinimizedByOther)
|
||||
{
|
||||
isMinimizedByOtherWindow_ = isMinimizedByOther;
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <parameters.h>
|
||||
#include <power_mgr_client.h>
|
||||
#include <transaction/rs_transaction.h>
|
||||
|
||||
#include "minimize_app.h"
|
||||
#include "remote_animation.h"
|
||||
#include "starting_window.h"
|
||||
#include "window_manager_hilog.h"
|
||||
@@ -212,6 +214,7 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
|
||||
}
|
||||
}
|
||||
StopBootAnimationIfNeed(node->GetWindowType());
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -350,6 +353,7 @@ WMError WindowController::SetWindowMode(uint32_t windowId, WindowMode dstMode)
|
||||
return ret;
|
||||
}
|
||||
FlushWindowInfo(windowId);
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -612,6 +616,7 @@ WMError WindowController::ProcessPointUp(uint32_t windowId)
|
||||
void WindowController::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
windowRoot_->MinimizeAllAppWindows(displayId);
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
}
|
||||
|
||||
void WindowController::ToggleShownStateForAllAppWindows()
|
||||
@@ -682,6 +687,7 @@ WMError WindowController::SetWindowLayoutMode(WindowLayoutMode mode)
|
||||
}
|
||||
FlushWindowInfoWithDisplayId(displayId);
|
||||
}
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -774,7 +780,6 @@ WMError WindowController::GetModeChangeHotZones(DisplayId displayId,
|
||||
void WindowController::SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow)
|
||||
{
|
||||
isMinimizedByOtherWindow_ = isMinimizedByOtherWindow;
|
||||
windowRoot_->SetMinimizedByOtherWindow(isMinimizedByOtherWindow);
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Rosen
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "window_layout_policy_tile.h"
|
||||
#include <ability_manager_client.h>
|
||||
#include "minimize_app.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
@@ -208,10 +209,7 @@ void WindowLayoutPolicyTile::ForegroundNodeQueuePushBack(const sptr<WindowNode>&
|
||||
auto removeNode = foregroundNodes.front();
|
||||
foregroundNodes.pop_front();
|
||||
WLOGFI("pop win in queue head for add new win, windowId: %{public}d", removeNode->GetWindowId());
|
||||
if (removeNode->abilityToken_ != nullptr) {
|
||||
WLOGFI("minimize win %{public}u in tile", removeNode->GetWindowId());
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(removeNode->abilityToken_);
|
||||
}
|
||||
MinimizeApp::AddNeedMinimizeApp(removeNode, MinimizeReason::LAYOUT_TILE);
|
||||
}
|
||||
foregroundNodes.push_back(node);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "display_manager_service_inner.h"
|
||||
#include "drag_controller.h"
|
||||
#include "remote_animation.h"
|
||||
#include "minimize_app.h"
|
||||
#include "singleton_container.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
@@ -194,6 +195,7 @@ void WindowManagerService::ConfigureWindowManagerService()
|
||||
|
||||
if (enableConfig.count("minimizeByOther") != 0) {
|
||||
windowController_->SetMinimizedByOtherWindow(enableConfig.at("minimizeByOther"));
|
||||
MinimizeApp::SetMinimizedByOtherConfig(enableConfig.at("minimizeByOther"));
|
||||
}
|
||||
|
||||
if (enableConfig.count("stretchable") != 0) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include "window_node_container.h"
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
@@ -1227,7 +1226,7 @@ sptr<WindowNode> WindowNodeContainer::GetNextActiveWindow(uint32_t windowId) con
|
||||
|
||||
void WindowNodeContainer::MinimizeAllAppWindows(DisplayId displayId)
|
||||
{
|
||||
WMError ret = MinimizeAppNodeExceptOptions(true);
|
||||
WMError ret = MinimizeAppNodeExceptOptions(MinimizeReason::MINIMIZE_ALL);
|
||||
SwitchLayoutPolicy(WindowLayoutMode::CASCADE, displayId);
|
||||
if (ret != WMError::WM_OK) {
|
||||
WLOGFE("Minimize all app window failed");
|
||||
@@ -1239,15 +1238,13 @@ void WindowNodeContainer::MinimizeOldestAppWindow()
|
||||
{
|
||||
for (auto& appNode : appWindowNode_->children_) {
|
||||
if (appNode->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
WLOGFI("minimize window, windowId:%{public}u", appNode->GetWindowId());
|
||||
MinimizeWindowFromAbility(appNode, true);
|
||||
MinimizeApp::AddNeedMinimizeApp(appNode, MinimizeReason::MAX_APP_COUNT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (auto& appNode : aboveAppWindowNode_->children_) {
|
||||
if (appNode->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
WLOGFI("minimize window, windowId:%{public}u", appNode->GetWindowId());
|
||||
MinimizeWindowFromAbility(appNode, true);
|
||||
MinimizeApp::AddNeedMinimizeApp(appNode, MinimizeReason::MAX_APP_COUNT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1299,21 +1296,8 @@ bool WindowNodeContainer::IsAppWindowsEmpty() const
|
||||
return appWindowNode_->children_.empty();
|
||||
}
|
||||
|
||||
void WindowNodeContainer::MinimizeWindowFromAbility(const sptr<WindowNode>& node, bool fromUser)
|
||||
{
|
||||
if (node->abilityToken_ == nullptr) {
|
||||
WLOGFW("Target abilityToken is nullptr, windowId:%{public}u", node->GetWindowId());
|
||||
return;
|
||||
}
|
||||
WLOGFI("minimize window fromUser:%{public}d, isMinimizedByOther:%{public}d", fromUser, isMinimizedByOther_);
|
||||
if (!fromUser && !isMinimizedByOther_) {
|
||||
return;
|
||||
}
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(node->abilityToken_, fromUser);
|
||||
}
|
||||
|
||||
WMError WindowNodeContainer::MinimizeAppNodeExceptOptions(bool fromUser, const std::vector<uint32_t> &exceptionalIds,
|
||||
const std::vector<WindowMode> &exceptionalModes)
|
||||
WMError WindowNodeContainer::MinimizeAppNodeExceptOptions(MinimizeReason reason,
|
||||
const std::vector<uint32_t> &exceptionalIds, const std::vector<WindowMode> &exceptionalModes)
|
||||
{
|
||||
if (appWindowNode_->children_.empty()) {
|
||||
return WMError::WM_OK;
|
||||
@@ -1326,9 +1310,7 @@ WMError WindowNodeContainer::MinimizeAppNodeExceptOptions(bool fromUser, const s
|
||||
appNode->GetWindowType() != WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
continue;
|
||||
}
|
||||
// minimize window
|
||||
WLOGFI("minimize window, windowId:%{public}u", appNode->GetWindowId());
|
||||
MinimizeWindowFromAbility(appNode, fromUser);
|
||||
MinimizeApp::AddNeedMinimizeApp(appNode, reason);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
@@ -1337,7 +1319,7 @@ WMError WindowNodeContainer::MinimizeStructuredAppWindowsExceptSelf(const sptr<W
|
||||
{
|
||||
std::vector<uint32_t> exceptionalIds = { node->GetWindowId() };
|
||||
std::vector<WindowMode> exceptionalModes = { WindowMode::WINDOW_MODE_FLOATING, WindowMode::WINDOW_MODE_PIP };
|
||||
return MinimizeAppNodeExceptOptions(false, exceptionalIds, exceptionalModes);
|
||||
return MinimizeAppNodeExceptOptions(MinimizeReason::OTHER_WINDOW, exceptionalIds, exceptionalModes);
|
||||
}
|
||||
|
||||
void WindowNodeContainer::ResetLayoutPolicy()
|
||||
@@ -1658,10 +1640,6 @@ WMError WindowNodeContainer::SetWindowMode(sptr<WindowNode>& node, WindowMode ds
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::SetMinimizedByOther(bool isMinimizedByOther)
|
||||
{
|
||||
isMinimizedByOther_ = isMinimizedByOther;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones,
|
||||
const ModeChangeHotZonesConfig& config)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include "common_event_manager.h"
|
||||
#include "minimize_app.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "window_helper.h"
|
||||
#include "wm_trace.h"
|
||||
@@ -387,7 +388,7 @@ void WindowPair::Insert(sptr<WindowNode>& node)
|
||||
}
|
||||
// minimize invalid paired window
|
||||
if (pairedNode != nullptr && pairedNode->abilityToken_ != nullptr) {
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(pairedNode->abilityToken_, false);
|
||||
MinimizeApp::AddNeedMinimizeApp(pairedNode, MinimizeReason::OTHER_WINDOW);
|
||||
}
|
||||
UpdateWindowPairStatus();
|
||||
}
|
||||
|
||||
@@ -71,11 +71,10 @@ sptr<WindowNodeContainer> WindowRoot::CreateWindowNodeContainer(DisplayId displa
|
||||
}
|
||||
|
||||
ScreenId screenGroupId = DisplayManagerServiceInner::GetInstance().GetScreenGroupIdByDisplayId(displayId);
|
||||
WLOGFI("create new container for display, width: %{public}d, height: %{public}d, isMinimized:%{public}d, "
|
||||
WLOGFI("create new container for display, width: %{public}d, height: %{public}d, "
|
||||
"screenGroupId:%{public}" PRIu64", displayId:%{public}" PRIu64"", displayInfo->GetWidth(),
|
||||
displayInfo->GetHeight(), isMinimizedByOtherWindow_, screenGroupId, displayId);
|
||||
displayInfo->GetHeight(), screenGroupId, displayId);
|
||||
sptr<WindowNodeContainer> container = new WindowNodeContainer(displayInfo);
|
||||
container->SetMinimizedByOther(isMinimizedByOtherWindow_);
|
||||
windowNodeContainerMap_.insert(std::make_pair(screenGroupId, container));
|
||||
std::vector<DisplayId> displayVec = { displayId };
|
||||
displayIdMap_.insert(std::make_pair(screenGroupId, displayVec));
|
||||
@@ -998,12 +997,6 @@ void WindowRoot::SetMaxAppWindowNumber(int windowNum)
|
||||
maxAppWindowNumber_ = windowNum;
|
||||
}
|
||||
|
||||
void WindowRoot::SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow)
|
||||
{
|
||||
WLOGFI("isMinimizedByOtherWindow:%{public}d", isMinimizedByOtherWindow);
|
||||
isMinimizedByOtherWindow_ = isMinimizedByOtherWindow;
|
||||
}
|
||||
|
||||
WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId,
|
||||
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user