diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index ecb8faa4..a04d8792 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -439,24 +439,24 @@ bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability) napi_value global; auto env = reinterpret_cast(&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(&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; } diff --git a/wmserver/include/minimize_app.h b/wmserver/include/minimize_app.h index 5fb27ab6..dda33e12 100644 --- a/wmserver/include/minimize_app.h +++ b/wmserver/include/minimize_app.h @@ -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& node); private: static inline bool IsFromUser(MinimizeReason reason) { @@ -52,6 +53,7 @@ private: static std::map>> needMinimizeAppNodes_; static bool isMinimizedByOtherWindow_; + static std::recursive_mutex mutex_; }; } // Rosen } // OHOS diff --git a/wmserver/include/remote_animation.h b/wmserver/include/remote_animation.h index 35e3196f..c63c39fc 100644 --- a/wmserver/include/remote_animation.h +++ b/wmserver/include/remote_animation.h @@ -46,11 +46,11 @@ public: sptr dstInfo, const sptr& srcNode, const sptr& dstNode); static WMError SetWindowAnimationController(const sptr& controller); static WMError NotifyAnimationTransition(sptr srcInfo, sptr dstInfo, - const sptr& srcNode, const sptr& dstNode, bool needMinimizeSrcNode); + const sptr& srcNode, const sptr& dstNode); static WMError NotifyAnimationMinimize(sptr srcInfo, const sptr& srcNode); static WMError NotifyAnimationClose(sptr srcInfo, const sptr& srcNode); static void OnRemoteDie(const sptr& remoteObject); - + static bool CheckAnimationController(); private: static sptr CreateWindowAnimationTarget(sptr info, const sptr& windowNode); diff --git a/wmserver/include/starting_window.h b/wmserver/include/starting_window.h index 886f6d7e..6cb9c904 100644 --- a/wmserver/include/starting_window.h +++ b/wmserver/include/starting_window.h @@ -36,10 +36,11 @@ public: static void DrawStartingWindow(sptr& node, sptr pixelMap, uint32_t bkgColor, bool isColdStart); static void UpdateRSTree(sptr& node); - + static void ReleaseStartWinSurfaceNode(sptr& node); private: static SurfaceDraw surfaceDraw_; static WMError CreateLeashAndStartingSurfaceNode(sptr& node); + static std::recursive_mutex mutex_; }; } // Rosen } // OHOS diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index cbfc8864..7295c623 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -57,7 +57,6 @@ public: WMError SetWindowAnimationController(const sptr& controller); WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config); - void SetMinimizedByOtherWindow(bool isMinimizedByOtherWindow); void StartingWindow(sptr info, sptr pixelMap, uint32_t bkgColor, bool isColdStart); void CancelStartingWindow(sptr abilityToken); @@ -75,7 +74,6 @@ private: WMError SetWindowMode(uint32_t windowId, WindowMode dstMode); void ReSizeSystemBarPropertySizeIfNeed(sptr node); void HandleTurnScreenOn(const sptr& node); - bool IsWindowNeedMinimizedByOther(const sptr& target, const sptr& other); void ProcessSystemBarChange(const sptr& displayInfo); sptr windowRoot_; @@ -89,7 +87,6 @@ private: std::unordered_map>> systemBarRect_; std::unordered_map> curDisplayInfo_; constexpr static float SYSTEM_BAR_HEIGHT_RATIO = 0.08; - bool isMinimizedByOtherWindow_ = true; bool isScreenLocked_ { false }; }; } // Rosen diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 90f10110..6399c53f 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -36,7 +36,7 @@ class WindowNodeContainer : public RefBase { public: WindowNodeContainer(const sptr& displayInfo); ~WindowNodeContainer(); - WMError ShowInTransition(sptr& node); + WMError ShowStartingWindow(sptr& node); WMError AddWindowNode(sptr& node, sptr& parentNode); WMError RemoveWindowNode(sptr& node); WMError UpdateWindowNode(sptr& node, WindowUpdateReason reason); diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index a03e17f3..7fac9084 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -80,7 +80,7 @@ public: WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones, const ModeChangeHotZonesConfig& config); std::vector GetAllDisplayIds() const; - + std::map> GetWindowNodeMap(); private: void OnRemoteDied(const sptr& remoteObject); WMError DestroyWindowInner(sptr& node); diff --git a/wmserver/src/minimize_app.cpp b/wmserver/src/minimize_app.cpp index b66fb98e..57ad4c5c 100644 --- a/wmserver/src/minimize_app.cpp +++ b/wmserver/src/minimize_app.cpp @@ -26,15 +26,18 @@ namespace { std::map>> MinimizeApp::needMinimizeAppNodes_; bool MinimizeApp::isMinimizedByOtherWindow_ = true; +std::recursive_mutex MinimizeApp::mutex_; void MinimizeApp::AddNeedMinimizeApp(const sptr& node, MinimizeReason reason) { + std::lock_guard 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 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 lock(mutex_); + if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) { + needMinimizeAppNodes_.at(reason).clear(); + } +} + +bool MinimizeApp::IsNodeNeedMinimize(const sptr& 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 lock(mutex_); if (needMinimizeAppNodes_.find(reason) != needMinimizeAppNodes_.end()) { bool isFromUser = IsFromUser(reason); if (!isMinimizedByOtherWindow_ && !isFromUser) { diff --git a/wmserver/src/remote_animation.cpp b/wmserver/src/remote_animation.cpp index 50968170..66488b8f 100644 --- a/wmserver/src/remote_animation.cpp +++ b/wmserver/src/remote_animation.cpp @@ -18,7 +18,7 @@ #include #include #include - +#include "minimize_app.h" #include "window_helper.h" #include "window_manager_hilog.h" @@ -51,6 +51,15 @@ WMError RemoteAnimation::SetWindowAnimationController(const sptr srcInfo, const sptr& srcNode, sptr dstInfo, const sptr& dstNode) { @@ -64,11 +73,7 @@ bool RemoteAnimation::CheckTransition(sptr srcInfo, const return false; } - if (windowAnimationController_ == nullptr) { - WLOGFI("RSWindowAnimation: windowAnimationController_ null!"); - return false; - } - return true; + return CheckAnimationController(); } void RemoteAnimation::OnRemoteDie(const sptr& remoteObject) @@ -104,7 +109,7 @@ TransitionEvent RemoteAnimation::GetTransitionEvent(sptr s WMError RemoteAnimation::NotifyAnimationTransition(sptr srcInfo, sptr dstInfo, const sptr& srcNode, - const sptr& dstNode, bool needMinimizeSrcNode) + const sptr& 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 sr } WLOGFI("RSWindowAnimation: nofity animation transition with dst currId:%{public}u!", dstNode->GetWindowId()); sptr 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 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); diff --git a/wmserver/src/starting_window.cpp b/wmserver/src/starting_window.cpp index 1ed62487..9e27374b 100644 --- a/wmserver/src/starting_window.cpp +++ b/wmserver/src/starting_window.cpp @@ -17,17 +17,19 @@ #include #include #include +#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 StartingWindow::CreateWindowNode(sptr info, uint32_t winId) { @@ -114,6 +116,11 @@ void StartingWindow::HandleClientWindowCreate(sptr& node, sptr 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& node, sptr& node) +{ + std::lock_guard 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& 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(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(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 diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index b1fe2c55..9a35201e 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -38,20 +38,6 @@ uint32_t WindowController::GenWindowId() return ++windowId_; } -bool WindowController::IsWindowNeedMinimizedByOther(const sptr& target, const sptr& 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 info, sptr pixelMap, uint32_t bkgColor, bool isColdStart) { @@ -72,6 +58,9 @@ void WindowController::StartingWindow(sptr info, sptrSaveWindow(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 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& 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& 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& 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& 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& node) if (animationFlag == static_cast(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 \ No newline at end of file diff --git a/wmserver/src/window_dumper.cpp b/wmserver/src/window_dumper.cpp index 18bad685..9c032584 100644 --- a/wmserver/src/window_dumper.cpp +++ b/wmserver/src/window_dumper.cpp @@ -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; } diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 7a582ff3..072fe475 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -49,7 +49,6 @@ void WindowLayoutPolicy::Reorder() void WindowLayoutPolicy::LimitWindowToBottomRightCorner(const sptr& 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& 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& node, for (auto& childNode : node->children_) { UpdateRectInDisplayGroup(childNode, srcDisplayRect, dstDisplayRect); } -======= - WLOGFI("UpdateDisplayGroupLimitRect_"); -} - -void WindowLayoutPolicy::UpdateNodeAbsoluteCordinate(const sptr& 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& 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); } diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 9ba90dbc..44490565 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -194,7 +194,6 @@ void WindowManagerService::ConfigureWindowManagerService() } if (enableConfig.count("minimizeByOther") != 0) { - windowController_->SetMinimizedByOtherWindow(enableConfig.at("minimizeByOther")); MinimizeApp::SetMinimizedByOtherConfig(enableConfig.at("minimizeByOther")); } diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 4c216bc4..5279a70f 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -116,13 +116,12 @@ WMError WindowNodeContainer::AddWindowNodeOnWindowTree(sptr& node, c return WMError::WM_OK; } -WMError WindowNodeContainer::ShowInTransition(sptr& node) +WMError WindowNodeContainer::ShowStartingWindow(sptr& 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& 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& 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& node, std::vect // clear vector cache completely, swap with empty vector auto emptyVector = std::vector>(); node->children_.swap(emptyVector); + WLOGFI("DestroyWindowNode windowId: %{public}u end", node->GetWindowId()); return WMError::WM_OK; } @@ -393,22 +391,16 @@ bool WindowNodeContainer::UpdateRSTree(sptr& 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& 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; diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index c065a868..b37f1827 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -30,6 +30,11 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowRoot"}; } +std::map> WindowRoot::GetWindowNodeMap() +{ + return windowNodeMap_; +} + ScreenId WindowRoot::GetScreenGroupId(DisplayId displayId, bool& isRecordedDisplay) { for (auto iter : displayIdMap_) { @@ -149,7 +154,7 @@ sptr WindowRoot::FindWindowNodeWithToken(const sptr& 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& 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);