mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-08-27 23:09:59 -04:00
add normal animation for starting window
Signed-off-by: chyyy0213 <chenhaiying3@huawei.com> Change-Id: I07551305c9fbf0b1ae3869ffa190681e2b6e8db0 Signed-off-by: chyyy0213 <chenhaiying3@huawei.com>
This commit is contained in:
@@ -439,24 +439,24 @@ bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability)
|
||||
napi_value global;
|
||||
auto env = reinterpret_cast<napi_env>(&engine);
|
||||
if (napi_get_global(env, &global) != napi_ok) {
|
||||
WLOGFE("[NAPI]Get global failed");
|
||||
WLOGFI("[NAPI]Get global failed");
|
||||
return false;
|
||||
}
|
||||
napi_value jsAbility;
|
||||
napi_status status = napi_get_named_property(env, global, "ability", &jsAbility);
|
||||
if (status != napi_ok || jsAbility == nullptr) {
|
||||
WLOGFE("[NAPI]Get ability property failed");
|
||||
WLOGFI("[NAPI]Get ability property failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (napi_get_value_external(env, jsAbility, reinterpret_cast<void **>(&ability)) != napi_ok) {
|
||||
WLOGFE("[NAPI]Get ability external failed");
|
||||
WLOGFI("[NAPI]Get ability external failed");
|
||||
return false;
|
||||
}
|
||||
if (ability == nullptr) {
|
||||
return false;
|
||||
} else {
|
||||
WLOGI("[NAPI]Get ability");
|
||||
WLOGFI("[NAPI]Get ability");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
static void ExecuteMinimizeAll();
|
||||
static void ExecuteMinimizeTargetReason(MinimizeReason reason);
|
||||
static void SetMinimizedByOtherConfig(bool isMinimizedByOther);
|
||||
|
||||
static void ClearNodesWithReason(MinimizeReason reason);
|
||||
static bool IsNodeNeedMinimize(const sptr<WindowNode>& node);
|
||||
private:
|
||||
static inline bool IsFromUser(MinimizeReason reason)
|
||||
{
|
||||
@@ -52,6 +53,7 @@ private:
|
||||
|
||||
static std::map<MinimizeReason, std::vector<sptr<WindowNode>>> needMinimizeAppNodes_;
|
||||
static bool isMinimizedByOtherWindow_;
|
||||
static std::recursive_mutex mutex_;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
||||
@@ -46,11 +46,11 @@ public:
|
||||
sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode);
|
||||
static WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller);
|
||||
static WMError NotifyAnimationTransition(sptr<WindowTransitionInfo> srcInfo, sptr<WindowTransitionInfo> dstInfo,
|
||||
const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, bool needMinimizeSrcNode);
|
||||
const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode);
|
||||
static WMError NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode);
|
||||
static WMError NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode);
|
||||
static void OnRemoteDie(const sptr<IRemoteObject>& remoteObject);
|
||||
|
||||
static bool CheckAnimationController();
|
||||
private:
|
||||
static sptr<RSWindowAnimationTarget> CreateWindowAnimationTarget(sptr<WindowTransitionInfo> info,
|
||||
const sptr<WindowNode>& windowNode);
|
||||
|
||||
@@ -36,10 +36,11 @@ public:
|
||||
static void DrawStartingWindow(sptr<WindowNode>& node, sptr<Media::PixelMap> pixelMap, uint32_t bkgColor,
|
||||
bool isColdStart);
|
||||
static void UpdateRSTree(sptr<WindowNode>& node);
|
||||
|
||||
static void ReleaseStartWinSurfaceNode(sptr<WindowNode>& node);
|
||||
private:
|
||||
static SurfaceDraw surfaceDraw_;
|
||||
static WMError CreateLeashAndStartingSurfaceNode(sptr<WindowNode>& node);
|
||||
static std::recursive_mutex mutex_;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
||||
@@ -57,7 +57,6 @@ public:
|
||||
WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller);
|
||||
WMError GetModeChangeHotZones(DisplayId displayId,
|
||||
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config);
|
||||
void SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow);
|
||||
void StartingWindow(sptr<WindowTransitionInfo> info, sptr<Media::PixelMap> pixelMap,
|
||||
uint32_t bkgColor, bool isColdStart);
|
||||
void CancelStartingWindow(sptr<IRemoteObject> abilityToken);
|
||||
@@ -75,7 +74,6 @@ private:
|
||||
WMError SetWindowMode(uint32_t windowId, WindowMode dstMode);
|
||||
void ReSizeSystemBarPropertySizeIfNeed(sptr<WindowNode> node);
|
||||
void HandleTurnScreenOn(const sptr<WindowNode>& node);
|
||||
bool IsWindowNeedMinimizedByOther(const sptr<WindowNode>& target, const sptr<WindowNode>& other);
|
||||
void ProcessSystemBarChange(const sptr<DisplayInfo>& displayInfo);
|
||||
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
@@ -89,7 +87,6 @@ private:
|
||||
std::unordered_map<WindowType, std::map<uint32_t, std::map<uint32_t, Rect>>> systemBarRect_;
|
||||
std::unordered_map<DisplayId, sptr<DisplayInfo>> curDisplayInfo_;
|
||||
constexpr static float SYSTEM_BAR_HEIGHT_RATIO = 0.08;
|
||||
bool isMinimizedByOtherWindow_ = true;
|
||||
bool isScreenLocked_ { false };
|
||||
};
|
||||
} // Rosen
|
||||
|
||||
@@ -36,7 +36,7 @@ class WindowNodeContainer : public RefBase {
|
||||
public:
|
||||
WindowNodeContainer(const sptr<DisplayInfo>& displayInfo);
|
||||
~WindowNodeContainer();
|
||||
WMError ShowInTransition(sptr<WindowNode>& node);
|
||||
WMError ShowStartingWindow(sptr<WindowNode>& node);
|
||||
WMError AddWindowNode(sptr<WindowNode>& node, sptr<WindowNode>& parentNode);
|
||||
WMError RemoveWindowNode(sptr<WindowNode>& node);
|
||||
WMError UpdateWindowNode(sptr<WindowNode>& node, WindowUpdateReason reason);
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
WMError GetModeChangeHotZones(DisplayId displayId,
|
||||
ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config);
|
||||
std::vector<DisplayId> GetAllDisplayIds() const;
|
||||
|
||||
std::map<uint32_t, sptr<WindowNode>> GetWindowNodeMap();
|
||||
private:
|
||||
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
|
||||
WMError DestroyWindowInner(sptr<WindowNode>& node);
|
||||
|
||||
@@ -26,15 +26,18 @@ namespace {
|
||||
|
||||
std::map<MinimizeReason, std::vector<sptr<WindowNode>>> MinimizeApp::needMinimizeAppNodes_;
|
||||
bool MinimizeApp::isMinimizedByOtherWindow_ = true;
|
||||
std::recursive_mutex MinimizeApp::mutex_;
|
||||
|
||||
void MinimizeApp::AddNeedMinimizeApp(const sptr<WindowNode>& node, MinimizeReason reason)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
WLOGFI("[Minimize] Add Window %{public}u to minimize list, reason %{public}u", node->GetWindowId(), reason);
|
||||
needMinimizeAppNodes_[reason].emplace_back(node);
|
||||
}
|
||||
|
||||
void MinimizeApp::ExecuteMinimizeAll()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto& appNodes: needMinimizeAppNodes_) {
|
||||
bool isFromUser = IsFromUser(appNodes.first);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
@@ -52,8 +55,32 @@ void MinimizeApp::ExecuteMinimizeAll()
|
||||
needMinimizeAppNodes_.clear();
|
||||
}
|
||||
|
||||
void MinimizeApp::ClearNodesWithReason(MinimizeReason reason)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) {
|
||||
needMinimizeAppNodes_.at(reason).clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool MinimizeApp::IsNodeNeedMinimize(const sptr<WindowNode>& node)
|
||||
{
|
||||
if (node == nullptr) {
|
||||
WLOGFE("[Minimize] node is nullptr");
|
||||
return false;
|
||||
}
|
||||
for (auto iter : needMinimizeAppNodes_) {
|
||||
auto nodes = iter.second;
|
||||
if (std::find(nodes.begin(), nodes.end(), node) != nodes.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason reason)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) {
|
||||
bool isFromUser = IsFromUser(reason);
|
||||
if (!isMinimizedByOtherWindow_ && !isFromUser) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <ability_manager_client.h>
|
||||
#include <common/rs_rect.h>
|
||||
#include <rs_window_animation_finished_callback.h>
|
||||
|
||||
#include "minimize_app.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
@@ -51,6 +51,15 @@ WMError RemoteAnimation::SetWindowAnimationController(const sptr<RSIWindowAnimat
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool RemoteAnimation::CheckAnimationController()
|
||||
{
|
||||
if (windowAnimationController_ == nullptr) {
|
||||
WLOGFI("RSWindowAnimation: windowAnimationController_ null!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoteAnimation::CheckTransition(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode,
|
||||
sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& dstNode)
|
||||
{
|
||||
@@ -64,11 +73,7 @@ bool RemoteAnimation::CheckTransition(sptr<WindowTransitionInfo> srcInfo, const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (windowAnimationController_ == nullptr) {
|
||||
WLOGFI("RSWindowAnimation: windowAnimationController_ null!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return CheckAnimationController();
|
||||
}
|
||||
|
||||
void RemoteAnimation::OnRemoteDie(const sptr<IRemoteObject>& remoteObject)
|
||||
@@ -104,7 +109,7 @@ TransitionEvent RemoteAnimation::GetTransitionEvent(sptr<WindowTransitionInfo> s
|
||||
|
||||
WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> srcInfo,
|
||||
sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode,
|
||||
const sptr<WindowNode>& dstNode, bool needMinimizeSrcNode)
|
||||
const sptr<WindowNode>& dstNode)
|
||||
{
|
||||
if (!dstNode || !dstNode->startingWindowShown_) {
|
||||
WLOGFE("RSWindowAnimation: no startingWindow for dst window id:%{public}u!", dstNode->GetWindowId());
|
||||
@@ -112,13 +117,9 @@ WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> sr
|
||||
}
|
||||
WLOGFI("RSWindowAnimation: nofity animation transition with dst currId:%{public}u!", dstNode->GetWindowId());
|
||||
sptr<RSWindowAnimationFinishedCallback> finishedCallback = new(std::nothrow) RSWindowAnimationFinishedCallback(
|
||||
[srcNode, dstNode, needMinimizeSrcNode]() {
|
||||
WLOGFI("RSWindowAnimation: on finish transition!");
|
||||
if (needMinimizeSrcNode && srcNode != nullptr && srcNode->abilityToken_ != nullptr) {
|
||||
WLOGFI("RSWindowAnimation minimize windowId: %{public}u, name:%{public}s",
|
||||
srcNode->GetWindowId(), srcNode->GetWindowName().c_str());
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(srcNode->abilityToken_, false);
|
||||
}
|
||||
[]() {
|
||||
WLOGFI("RSWindowAnimation: on finish transition with minimizeAll!");
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
}
|
||||
);
|
||||
if (finishedCallback == nullptr) {
|
||||
@@ -133,11 +134,12 @@ WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> sr
|
||||
return WMError::WM_ERROR_NO_MEM;
|
||||
}
|
||||
dstNode->isPlayAnimationShow_ = true;
|
||||
bool needMinimizeSrcNode = MinimizeApp::IsNodeNeedMinimize(srcNode);
|
||||
// from app to app
|
||||
if (needMinimizeSrcNode && srcNode != nullptr) {
|
||||
auto srcTarget = CreateWindowAnimationTarget(srcInfo, srcNode);
|
||||
// to avoid normal animation
|
||||
srcNode->isPlayAnimationHide_ = true;
|
||||
|
||||
WLOGFI("RSWindowAnimation: app transition from id:%{public}u to id:%{public}u!",
|
||||
srcNode->GetWindowId(), dstNode->GetWindowId());
|
||||
windowAnimationController_->OnAppTransition(srcTarget, dstTarget, finishedCallback);
|
||||
|
||||
@@ -17,17 +17,19 @@
|
||||
#include <ability_manager_client.h>
|
||||
#include <display_manager_service_inner.h>
|
||||
#include <transaction/rs_transaction.h>
|
||||
#include "remote_animation.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "StartingWindow"};
|
||||
const char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_animation";
|
||||
}
|
||||
|
||||
SurfaceDraw StartingWindow::surfaceDraw_;
|
||||
static bool g_hasInit = false;
|
||||
std::recursive_mutex StartingWindow::mutex_;
|
||||
|
||||
sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId)
|
||||
{
|
||||
@@ -114,6 +116,11 @@ void StartingWindow::HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWind
|
||||
|
||||
// Register FirstFrame Callback to rs, replace startwin
|
||||
auto firstFrameCompleteCallback = [node]() {
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (node->leashWinSurfaceNode_ == nullptr) {
|
||||
WLOGFE("leashWinSurfaceNode_ is nullptr");
|
||||
return;
|
||||
}
|
||||
WLOGFI("StartingWindow::Replace surfaceNode, id: %{public}u", node->GetWindowId());
|
||||
node->leashWinSurfaceNode_->RemoveChild(node->startingWinSurfaceNode_);
|
||||
node->leashWinSurfaceNode_->AddChild(node->surfaceNode_, -1);
|
||||
@@ -125,26 +132,53 @@ void StartingWindow::HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWind
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
|
||||
void StartingWindow::ReleaseStartWinSurfaceNode(sptr<WindowNode>& node)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!node->leashWinSurfaceNode_) {
|
||||
return;
|
||||
}
|
||||
node->leashWinSurfaceNode_->RemoveChild(node->startingWinSurfaceNode_);
|
||||
node->leashWinSurfaceNode_->RemoveChild(node->surfaceNode_);
|
||||
node->leashWinSurfaceNode_ = nullptr;
|
||||
node->startingWinSurfaceNode_ = nullptr;
|
||||
WLOGFI("Release startwindow surfaceNode end id:%{public}u", node->GetWindowId());
|
||||
}
|
||||
|
||||
void StartingWindow::UpdateRSTree(sptr<WindowNode>& node)
|
||||
{
|
||||
auto& dms = DisplayManagerServiceInner::GetInstance();
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
if (!node->surfaceNode_) { // cold start
|
||||
if (!WindowHelper::IsMainWindow(node->GetWindowType())) {
|
||||
WLOGFE("window id:%{public}d type: %{public}u is not Main Window!",
|
||||
node->GetWindowId(), static_cast<uint32_t>(node->GetWindowType()));
|
||||
}
|
||||
dms.UpdateRSTree(displayId, node->leashWinSurfaceNode_, true);
|
||||
node->leashWinSurfaceNode_->AddChild(node->startingWinSurfaceNode_, -1);
|
||||
} else { // hot start
|
||||
const auto& displayIdVec = node->GetShowingDisplays();
|
||||
for (auto& shownDisplayId : displayIdVec) {
|
||||
if (node->leashWinSurfaceNode_) { // to app
|
||||
dms.UpdateRSTree(shownDisplayId, node->leashWinSurfaceNode_, true);
|
||||
} else { // to launcher
|
||||
dms.UpdateRSTree(shownDisplayId, node->surfaceNode_, true);
|
||||
auto updateRSTreeFunc = [&]() {
|
||||
auto& dms = DisplayManagerServiceInner::GetInstance();
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
if (!node->surfaceNode_) { // cold start
|
||||
if (!WindowHelper::IsMainWindow(node->GetWindowType())) {
|
||||
WLOGFE("window id:%{public}d type: %{public}u is not Main Window!",
|
||||
node->GetWindowId(), static_cast<uint32_t>(node->GetWindowType()));
|
||||
}
|
||||
dms.UpdateRSTree(displayId, node->leashWinSurfaceNode_, true);
|
||||
node->leashWinSurfaceNode_->AddChild(node->startingWinSurfaceNode_, -1);
|
||||
} else { // hot start
|
||||
const auto& displayIdVec = node->GetShowingDisplays();
|
||||
for (auto& shownDisplayId : displayIdVec) {
|
||||
if (node->leashWinSurfaceNode_) { // to app
|
||||
dms.UpdateRSTree(shownDisplayId, node->leashWinSurfaceNode_, true);
|
||||
} else { // to launcher
|
||||
dms.UpdateRSTree(shownDisplayId, node->surfaceNode_, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
static const bool IsWindowAnimationEnabled = access(DISABLE_WINDOW_ANIMATION_PATH, F_OK) == 0 ? false : true;
|
||||
if (IsWindowAnimationEnabled && !RemoteAnimation::CheckAnimationController()) {
|
||||
// default transition duration: 350ms
|
||||
static const RSAnimationTimingProtocol timingProtocol(350);
|
||||
// default transition curve: EASE OUT
|
||||
static const Rosen::RSAnimationTimingCurve curve = Rosen::RSAnimationTimingCurve::EASE_OUT;
|
||||
// add window with transition animation
|
||||
RSNode::Animate(timingProtocol, curve, updateRSTreeFunc);
|
||||
} else {
|
||||
// add or remove window without animation
|
||||
updateRSTreeFunc();
|
||||
}
|
||||
}
|
||||
} // Rosen
|
||||
|
||||
@@ -38,20 +38,6 @@ uint32_t WindowController::GenWindowId()
|
||||
return ++windowId_;
|
||||
}
|
||||
|
||||
bool WindowController::IsWindowNeedMinimizedByOther(const sptr<WindowNode>& target, const sptr<WindowNode>& other)
|
||||
{
|
||||
if (target == nullptr || other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (!isMinimizedByOtherWindow_ || (target->GetWindowId() == other->GetWindowId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (other->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) &&
|
||||
(WindowHelper::IsAppWindow(other->GetWindowType())) && (target->GetWindowMode() ==
|
||||
WindowMode::WINDOW_MODE_FULLSCREEN) && (WindowHelper::IsMainWindow(target->GetWindowType()));
|
||||
}
|
||||
|
||||
void WindowController::StartingWindow(sptr<WindowTransitionInfo> info, sptr<Media::PixelMap> pixelMap,
|
||||
uint32_t bkgColor, bool isColdStart)
|
||||
{
|
||||
@@ -72,6 +58,9 @@ void WindowController::StartingWindow(sptr<WindowTransitionInfo> info, sptr<Medi
|
||||
if (windowRoot_->SaveWindow(node) != WMError::WM_OK) {
|
||||
return;
|
||||
}
|
||||
if (!RemoteAnimation::CheckAnimationController()) {
|
||||
UpdateWindowAnimation(node);
|
||||
}
|
||||
} else {
|
||||
if (isColdStart) {
|
||||
WLOGFE("windowNode exists but is cold start!");
|
||||
@@ -94,6 +83,7 @@ void WindowController::CancelStartingWindow(sptr<IRemoteObject> abilityToken)
|
||||
WLOGFI("cannot find windowNode!");
|
||||
return;
|
||||
}
|
||||
WM_SCOPED_TRACE("wms:CancelStartingWindow(%u)", node->GetWindowId());
|
||||
DestroyWindow(node->GetWindowId(), true);
|
||||
}
|
||||
|
||||
@@ -110,10 +100,13 @@ WMError WindowController::NotifyWindowTransition(sptr<WindowTransitionInfo>& src
|
||||
return WMError::WM_ERROR_NO_REMOTE_ANIMATION;
|
||||
}
|
||||
auto transitionEvent = RemoteAnimation::GetTransitionEvent(srcInfo, dstInfo, srcNode, dstNode);
|
||||
auto needMinimizeSrcNode = IsWindowNeedMinimizedByOther(srcNode, dstNode);
|
||||
switch (transitionEvent) {
|
||||
case TransitionEvent::APP_TRANSITION:
|
||||
return RemoteAnimation::NotifyAnimationTransition(srcInfo, dstInfo, srcNode, dstNode, needMinimizeSrcNode);
|
||||
case TransitionEvent::APP_TRANSITION: {
|
||||
if (dstNode->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
windowRoot_->MinimizeStructuredAppWindowsExceptSelf(dstNode); // avoid split/float mode minimize
|
||||
}
|
||||
return RemoteAnimation::NotifyAnimationTransition(srcInfo, dstInfo, srcNode, dstNode);
|
||||
}
|
||||
case TransitionEvent::MINIMIZE:
|
||||
return RemoteAnimation::NotifyAnimationMinimize(srcInfo, srcNode);
|
||||
case TransitionEvent::CLOSE:
|
||||
@@ -185,10 +178,22 @@ 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);
|
||||
if (res != WMError::WM_OK) {
|
||||
MinimizeApp::ClearNodesWithReason(MinimizeReason::OTHER_WINDOW);
|
||||
return res;
|
||||
}
|
||||
windowRoot_->FocusFaultDetection();
|
||||
@@ -201,16 +206,6 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
|
||||
ReSizeSystemBarPropertySizeIfNeed(node);
|
||||
}
|
||||
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
|
||||
WindowHelper::IsAppWindow(node->GetWindowType()) && !node->isPlayAnimationHide_) {
|
||||
WM_SCOPED_TRACE_BEGIN("controller:MinimizeStructuredAppWindowsExceptSelf");
|
||||
res = windowRoot_->MinimizeStructuredAppWindowsExceptSelf(node);
|
||||
WM_SCOPED_TRACE_END();
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("Minimize other structured window failed");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
StopBootAnimationIfNeed(node->GetWindowType());
|
||||
MinimizeApp::ExecuteMinimizeAll();
|
||||
return WMError::WM_OK;
|
||||
@@ -650,7 +645,7 @@ void WindowController::FlushWindowInfoWithDisplayId(DisplayId displayId)
|
||||
|
||||
void WindowController::UpdateWindowAnimation(const sptr<WindowNode>& node)
|
||||
{
|
||||
if (node == nullptr || node->surfaceNode_ == nullptr) {
|
||||
if (node == nullptr || (node->leashWinSurfaceNode_ == nullptr && node->surfaceNode_ == nullptr)) {
|
||||
WLOGFE("windowNode or surfaceNode is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -661,9 +656,19 @@ void WindowController::UpdateWindowAnimation(const sptr<WindowNode>& node)
|
||||
if (animationFlag == static_cast<uint32_t>(WindowAnimation::DEFAULT)) {
|
||||
// set default transition effect for window: scale from 1.0 to 0.7, fade from 1.0 to 0.0
|
||||
static const auto effect = RSTransitionEffect::Create()->Scale(Vector3f(0.7f, 0.7f, 0.0f))->Opacity(0.0f);
|
||||
node->surfaceNode_->SetTransitionEffect(effect);
|
||||
if (node->leashWinSurfaceNode_) {
|
||||
node->leashWinSurfaceNode_->SetTransitionEffect(effect);
|
||||
}
|
||||
if (node->surfaceNode_) {
|
||||
node->surfaceNode_->SetTransitionEffect(effect);
|
||||
}
|
||||
} else {
|
||||
node->surfaceNode_->SetTransitionEffect(nullptr);
|
||||
if (node->leashWinSurfaceNode_) {
|
||||
node->leashWinSurfaceNode_->SetTransitionEffect(nullptr);
|
||||
}
|
||||
if (node->surfaceNode_) {
|
||||
node->surfaceNode_->SetTransitionEffect(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,10 +772,5 @@ WMError WindowController::GetModeChangeHotZones(DisplayId displayId,
|
||||
{
|
||||
return windowRoot_->GetModeChangeHotZones(displayId, hotZones, config);
|
||||
}
|
||||
|
||||
void WindowController::SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow)
|
||||
{
|
||||
isMinimizedByOtherWindow_ = isMinimizedByOtherWindow;
|
||||
}
|
||||
} // namespace OHOS
|
||||
} // namespace Rosen
|
||||
@@ -112,6 +112,7 @@ WMError WindowDumper::DumpDisplayWindowInfo(DisplayId displayId, std::string& du
|
||||
<< std::endl;
|
||||
}
|
||||
oss << "Focus window: " << windowNodeContainer->GetFocusWindow() << std::endl;
|
||||
oss << "total window num: " << windowRoot_->GetWindowNodeMap().size() << std::endl;
|
||||
dumpInfo.append(oss.str());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ void WindowLayoutPolicy::Reorder()
|
||||
|
||||
void WindowLayoutPolicy::LimitWindowToBottomRightCorner(const sptr<WindowNode>& node)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
Rect windowRect = node->GetRequestRect();
|
||||
Rect displayRect = displayRectMap_[node->GetDisplayId()];
|
||||
windowRect.posX_ = std::max(windowRect.posX_, displayRect.posX_);
|
||||
@@ -76,14 +75,10 @@ void WindowLayoutPolicy::LimitWindowToBottomRightCorner(const sptr<WindowNode>&
|
||||
for (auto& childNode : node->children_) {
|
||||
LimitWindowToBottomRightCorner(childNode);
|
||||
}
|
||||
=======
|
||||
WLOGFI("LimitWindowToBottomRightCorner");
|
||||
>>>>>>> support drag cross display
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateDisplayGroupRect()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
Rect newDisplayGroupRect = { 0, 0, 0, 0 };
|
||||
// current mutiDisplay is only support left-right combination, maxNum is two
|
||||
for (auto& elem : displayRectMap_) {
|
||||
@@ -97,14 +92,10 @@ void WindowLayoutPolicy::UpdateDisplayGroupRect()
|
||||
displayGroupRect_ = newDisplayGroupRect;
|
||||
WLOGFI("displayGroupRect_: [ %{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
displayGroupRect_.posX_, displayGroupRect_.posY_, displayGroupRect_.width_, displayGroupRect_.height_);
|
||||
=======
|
||||
WLOGFI("UpdateDisplayGroupRect");
|
||||
>>>>>>> support drag cross display
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateDisplayGroupLimitRect_()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
auto firstDisplayLimitRect = limitRectMap_.begin()->second;
|
||||
Rect newDisplayGroupLimitRect = { firstDisplayLimitRect.posX_, firstDisplayLimitRect.posY_, 0, 0 };
|
||||
for (auto& elem : limitRectMap_) {
|
||||
@@ -144,16 +135,6 @@ void WindowLayoutPolicy::UpdateRectInDisplayGroup(const sptr<WindowNode>& node,
|
||||
for (auto& childNode : node->children_) {
|
||||
UpdateRectInDisplayGroup(childNode, srcDisplayRect, dstDisplayRect);
|
||||
}
|
||||
=======
|
||||
WLOGFI("UpdateDisplayGroupLimitRect_");
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateNodeAbsoluteCordinate(const sptr<WindowNode>& node,
|
||||
const Rect& srcDisplayRect,
|
||||
const Rect& dstDisplayRect)
|
||||
{
|
||||
WLOGFI("UpdateNodeAbsoluteCordinate");
|
||||
>>>>>>> support drag cross display
|
||||
}
|
||||
|
||||
bool WindowLayoutPolicy::IsMultiDisplay()
|
||||
@@ -169,7 +150,6 @@ void WindowLayoutPolicy::UpdateMultiDisplayFlag()
|
||||
} else {
|
||||
isMultiDisplay_ = false;
|
||||
WLOGFI("current mode is not muti-display");
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,18 +178,6 @@ void WindowLayoutPolicy::UpdateRectInDisplayGroupForAllNodes(DisplayId displayId
|
||||
}
|
||||
}
|
||||
|
||||
=======
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateNodesAbsoluteCordinatesInAllDisplay(DisplayId displayId,
|
||||
const Rect& srcDisplayRect,
|
||||
const Rect& dstDisplayRect)
|
||||
{
|
||||
WLOGFI("UpdateNodesAbsoluteCordinatesInAllDisplay");
|
||||
}
|
||||
|
||||
>>>>>>> support drag cross display
|
||||
void WindowLayoutPolicy::PostProcessWhenDisplayChange()
|
||||
{
|
||||
UpdateMultiDisplayFlag();
|
||||
@@ -227,11 +195,7 @@ void WindowLayoutPolicy::ProcessDisplayCreate(DisplayId displayId, const std::ma
|
||||
for (auto& elem : displayRectMap) {
|
||||
auto iter = displayRectMap_.find(elem.first);
|
||||
if (iter != displayRectMap_.end()) {
|
||||
<<<<<<< HEAD
|
||||
UpdateRectInDisplayGroupForAllNodes(elem.first, iter->second, elem.second);
|
||||
=======
|
||||
UpdateNodesAbsoluteCordinatesInAllDisplay(elem.first, iter->second, elem.second);
|
||||
>>>>>>> support drag cross display
|
||||
iter->second = elem.second;
|
||||
} else {
|
||||
if (elem.first != displayId) {
|
||||
@@ -251,11 +215,7 @@ void WindowLayoutPolicy::ProcessDisplayDestroy(DisplayId displayId, const std::m
|
||||
for (auto oriIter = displayRectMap_.begin(); oriIter != displayRectMap_.end();) {
|
||||
auto newIter = displayRectMap.find(oriIter->first);
|
||||
if (newIter != displayRectMap.end()) {
|
||||
<<<<<<< HEAD
|
||||
UpdateRectInDisplayGroupForAllNodes(oriIter->first, oriIter->second, newIter->second);
|
||||
=======
|
||||
UpdateNodesAbsoluteCordinatesInAllDisplay(oriIter->first, oriIter->second, newIter->second);
|
||||
>>>>>>> support drag cross display
|
||||
oriIter->second = newIter->second;
|
||||
++oriIter;
|
||||
} else {
|
||||
@@ -265,7 +225,6 @@ void WindowLayoutPolicy::ProcessDisplayDestroy(DisplayId displayId, const std::m
|
||||
}
|
||||
displayRectMap_.erase(oriIter++);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
PostProcessWhenDisplayChange();
|
||||
@@ -284,26 +243,6 @@ void WindowLayoutPolicy::ProcessDisplaySizeChangeOrRotation(DisplayId displayId,
|
||||
}
|
||||
|
||||
PostProcessWhenDisplayChange();
|
||||
=======
|
||||
}
|
||||
|
||||
PostProcessWhenDisplayChange();
|
||||
WLOGFI("Process display destroy, displayId: %{public}" PRIu64"", displayId);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::ProcessDisplaySizeChangeOrRotation(DisplayId displayId,
|
||||
const std::map<DisplayId, Rect>& displayRectMap)
|
||||
{
|
||||
for (auto& elem : displayRectMap) {
|
||||
auto iter = displayRectMap_.find(elem.first);
|
||||
if (iter != displayRectMap_.end()) {
|
||||
UpdateNodesAbsoluteCordinatesInAllDisplay(elem.first, iter->second, elem.second);
|
||||
iter->second = elem.second;
|
||||
}
|
||||
}
|
||||
|
||||
PostProcessWhenDisplayChange();
|
||||
>>>>>>> support drag cross display
|
||||
WLOGFI("Process display change, displayId: %{public}" PRIu64"", displayId);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,6 @@ void WindowManagerService::ConfigureWindowManagerService()
|
||||
}
|
||||
|
||||
if (enableConfig.count("minimizeByOther") != 0) {
|
||||
windowController_->SetMinimizedByOtherWindow(enableConfig.at("minimizeByOther"));
|
||||
MinimizeApp::SetMinimizedByOtherConfig(enableConfig.at("minimizeByOther"));
|
||||
}
|
||||
|
||||
|
||||
@@ -116,13 +116,12 @@ WMError WindowNodeContainer::AddWindowNodeOnWindowTree(sptr<WindowNode>& node, c
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowNodeContainer::ShowInTransition(sptr<WindowNode>& node)
|
||||
WMError WindowNodeContainer::ShowStartingWindow(sptr<WindowNode>& node)
|
||||
{
|
||||
if (node->currentVisibility_) {
|
||||
WLOGFE("current window is visible, windowId: %{public}u", node->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
WM_SCOPED_TRACE_BEGIN("WindowNodeContainer::ShowInTransition");
|
||||
WMError res = AddWindowNodeOnWindowTree(node, nullptr);
|
||||
if (res != WMError::WM_OK) {
|
||||
return res;
|
||||
@@ -143,8 +142,7 @@ WMError WindowNodeContainer::ShowInTransition(sptr<WindowNode>& node)
|
||||
AssignZOrder();
|
||||
|
||||
layoutPolicy_->AddWindowNode(node);
|
||||
WM_SCOPED_TRACE_END();
|
||||
WLOGFI("ShowInTransition windowId: %{public}u end", node->GetWindowId());
|
||||
WLOGFI("ShowStartingWindow windowId: %{public}u end", node->GetWindowId());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -319,8 +317,7 @@ WMError WindowNodeContainer::DestroyWindowNode(sptr<WindowNode>& node, std::vect
|
||||
WLOGFE("RemoveWindowNode failed");
|
||||
return ret;
|
||||
}
|
||||
node->leashWinSurfaceNode_ = nullptr;
|
||||
node->startingWinSurfaceNode_ = nullptr;
|
||||
StartingWindow::ReleaseStartWinSurfaceNode(node);
|
||||
node->surfaceNode_ = nullptr;
|
||||
windowIds.push_back(node->GetWindowId());
|
||||
|
||||
@@ -336,6 +333,7 @@ WMError WindowNodeContainer::DestroyWindowNode(sptr<WindowNode>& node, std::vect
|
||||
// clear vector cache completely, swap with empty vector
|
||||
auto emptyVector = std::vector<sptr<WindowNode>>();
|
||||
node->children_.swap(emptyVector);
|
||||
WLOGFI("DestroyWindowNode windowId: %{public}u end", node->GetWindowId());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
@@ -393,22 +391,16 @@ bool WindowNodeContainer::UpdateRSTree(sptr<WindowNode>& node, DisplayId display
|
||||
WLOGFI("UpdateRSTree windowId: %{public}d, displayId: %{public}" PRIu64", isAdd: %{public}d",
|
||||
node->GetWindowId(), displayId, isAdd);
|
||||
if (isAdd) {
|
||||
if (node->leashWinSurfaceNode_) {
|
||||
dms.UpdateRSTree(displayId, node->leashWinSurfaceNode_, true);
|
||||
} else {
|
||||
dms.UpdateRSTree(displayId, node->surfaceNode_, true);
|
||||
}
|
||||
auto& surfaceNode = node->leashWinSurfaceNode_ != nullptr ? node->leashWinSurfaceNode_ : node->surfaceNode_;
|
||||
dms.UpdateRSTree(displayId, surfaceNode, true);
|
||||
for (auto& child : node->children_) {
|
||||
if (child->currentVisibility_) {
|
||||
dms.UpdateRSTree(displayId, child->surfaceNode_, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (node->leashWinSurfaceNode_) {
|
||||
dms.UpdateRSTree(displayId, node->leashWinSurfaceNode_, false);
|
||||
} else {
|
||||
dms.UpdateRSTree(displayId, node->surfaceNode_, false);
|
||||
}
|
||||
auto& surfaceNode = node->leashWinSurfaceNode_ != nullptr ? node->leashWinSurfaceNode_ : node->surfaceNode_;
|
||||
dms.UpdateRSTree(displayId, surfaceNode, false);
|
||||
for (auto& child : node->children_) {
|
||||
dms.UpdateRSTree(displayId, child->surfaceNode_, false);
|
||||
}
|
||||
@@ -416,14 +408,16 @@ bool WindowNodeContainer::UpdateRSTree(sptr<WindowNode>& node, DisplayId display
|
||||
};
|
||||
|
||||
if (IsWindowAnimationEnabled && !animationPlayed) {
|
||||
WLOGFI("add or remove window with animation");
|
||||
// default transition duration: 350ms
|
||||
static const RSAnimationTimingProtocol timingProtocol(350);
|
||||
// default transition curve: EASE OUT
|
||||
static const Rosen::RSAnimationTimingCurve curve = Rosen::RSAnimationTimingCurve::EASE_OUT;
|
||||
// add or remove window with transition animation
|
||||
// add window with transition animation
|
||||
RSNode::Animate(timingProtocol, curve, updateRSTreeFunc);
|
||||
} else {
|
||||
// add or remove window without animation
|
||||
WLOGFI("add or remove window without animation");
|
||||
updateRSTreeFunc();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -30,6 +30,11 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowRoot"};
|
||||
}
|
||||
|
||||
std::map<uint32_t, sptr<WindowNode>> WindowRoot::GetWindowNodeMap()
|
||||
{
|
||||
return windowNodeMap_;
|
||||
}
|
||||
|
||||
ScreenId WindowRoot::GetScreenGroupId(DisplayId displayId, bool& isRecordedDisplay)
|
||||
{
|
||||
for (auto iter : displayIdMap_) {
|
||||
@@ -149,7 +154,7 @@ sptr<WindowNode> WindowRoot::FindWindowNodeWithToken(const sptr<IRemoteObject>&
|
||||
return false;
|
||||
});
|
||||
if (iter == windowNodeMap_.end()) {
|
||||
WLOGFE("cannot find windowNode");
|
||||
WLOGFI("cannot find windowNode");
|
||||
return nullptr;
|
||||
}
|
||||
return iter->second;
|
||||
@@ -305,7 +310,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, boo
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (fromStartingWin) {
|
||||
return container->ShowInTransition(node);
|
||||
return container->ShowStartingWindow(node);
|
||||
}
|
||||
// limit number of main window
|
||||
int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
|
||||
Reference in New Issue
Block a user