!1167 增加resetSize参数复数校验&remoteAnimation back逻辑修复&&最大化recover reason复位

Merge pull request !1167 from chenhaiying/m2
This commit is contained in:
openharmony_ci
2022-07-14 11:28:31 +00:00
committed by Gitee
10 changed files with 55 additions and 34 deletions
-1
View File
@@ -147,7 +147,6 @@ enum class WindowSizeChangeReason : uint32_t {
RESIZE,
MOVE,
HIDE,
TRANSFORM,
};
enum class WindowLayoutMode : uint32_t {
@@ -603,17 +603,20 @@ NativeValue* JsWindow::OnResize(NativeEngine& engine, NativeCallbackInfo& info)
WLOGFE("[NAPI]Argc is invalid: %{public}zu", info.argc);
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
uint32_t width = 0;
int32_t width = 0;
if (errCode == WMError::WM_OK && !ConvertFromJsValue(engine, info.argv[0], width)) {
WLOGFE("[NAPI]Failed to convert parameter to width");
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
uint32_t height = 0;
int32_t height = 0;
if (errCode == WMError::WM_OK && !ConvertFromJsValue(engine, info.argv[1], height)) {
WLOGFE("[NAPI]Failed to convert parameter to height");
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
if (width <= 0 || height <= 0) {
WLOGFE("[NAPI]width or height should greater than 0!");
errCode = WMError::WM_ERROR_INVALID_PARAM;
}
wptr<Window> weakToken(windowToken_);
AsyncTask::CompleteCallback complete =
[weakToken, errCode, width, height](NativeEngine& engine, AsyncTask& task, int32_t status) {
@@ -623,7 +626,7 @@ NativeValue* JsWindow::OnResize(NativeEngine& engine, NativeCallbackInfo& info)
WLOGFE("[NAPI]window is nullptr or get invalid param");
return;
}
WMError ret = weakWindow->Resize(width, height);
WMError ret = weakWindow->Resize(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
if (ret == WMError::WM_OK) {
task.Resolve(engine, engine.CreateUndefined());
} else {
+6 -4
View File
@@ -22,6 +22,7 @@
#include "wm_common.h"
#include "window_node.h"
#include "window_root.h"
#include "window_transition_info.h"
namespace OHOS {
@@ -46,13 +47,14 @@ 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);
static WMError NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode);
const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, sptr<WindowRoot>& windowRoot);
static WMError NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode,
sptr<WindowRoot>& windowRoot);
static WMError NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode,
TransitionEvent event);
TransitionEvent event, sptr<WindowRoot>& windowRoot);
static void OnRemoteDie(const sptr<IRemoteObject>& remoteObject);
static bool CheckAnimationController();
static WMError NotifyAnimationByHome();
static WMError NotifyAnimationByHome(sptr<WindowRoot>& windowRoot);
static WMError NotifyAnimationScreenUnlock(std::function<void(void)> callback);
private:
static sptr<RSWindowAnimationTarget> CreateWindowAnimationTarget(sptr<WindowTransitionInfo> info,
+1 -1
View File
@@ -119,7 +119,7 @@ private:
sptr<WindowNode> FindWindowNodeById(uint32_t id) const;
void UpdateFocusStatus(uint32_t id, bool focused) const;
void UpdateActiveStatus(uint32_t id, bool isActive) const;
void RemoveNodeFromRSTree(sptr<WindowNode>& node);
void NotifyIfAvoidAreaChanged(const sptr<WindowNode>& node, const AvoidControlType avoidType) const;
void NotifyIfSystemBarTintChanged(DisplayId displayId) const;
void NotifyIfSystemBarRegionChanged(DisplayId displayId) const;
+11 -5
View File
@@ -110,7 +110,7 @@ TransitionEvent RemoteAnimation::GetTransitionEvent(sptr<WindowTransitionInfo> s
WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> srcInfo,
sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode,
const sptr<WindowNode>& dstNode)
const sptr<WindowNode>& dstNode, sptr<WindowRoot>& windowRoot)
{
if (!dstNode || !dstNode->startingWindowShown_) {
WLOGFE("RSWindowAnimation: no startingWindow for dst window id:%{public}u!", dstNode->GetWindowId());
@@ -143,6 +143,7 @@ WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> sr
auto srcTarget = CreateWindowAnimationTarget(srcInfo, srcNode);
// to avoid normal animation
srcNode->isPlayAnimationHide_ = true;
windowRoot->RemoveWindowNode(srcNode->GetWindowId());
WLOGFI("RSWindowAnimation: app transition from id:%{public}u to id:%{public}u!",
srcNode->GetWindowId(), dstNode->GetWindowId());
windowAnimationController_->OnAppTransition(srcTarget, dstTarget, finishedCallback);
@@ -168,7 +169,8 @@ WMError RemoteAnimation::NotifyAnimationTransition(sptr<WindowTransitionInfo> sr
return WMError::WM_OK;
}
WMError RemoteAnimation::NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode)
WMError RemoteAnimation::NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode,
sptr<WindowRoot>& windowRoot)
{
sptr<RSWindowAnimationTarget> srcTarget = CreateWindowAnimationTarget(srcInfo, srcNode);
if (srcTarget == nullptr) {
@@ -176,6 +178,7 @@ WMError RemoteAnimation::NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcI
}
WLOGFI("RSWindowAnimation: notify animation minimize Id:%{public}u!", srcNode->GetWindowId());
srcNode->isPlayAnimationHide_ = true;
windowRoot->RemoveWindowNode(srcNode->GetWindowId());
wptr<WindowNode> weak = srcNode;
auto minimizeFunc = [weak]() {
auto weakNode = weak.promote();
@@ -198,7 +201,7 @@ WMError RemoteAnimation::NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcI
}
WMError RemoteAnimation::NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode,
TransitionEvent event)
TransitionEvent event, sptr<WindowRoot>& windowRoot)
{
sptr<RSWindowAnimationTarget> srcTarget = CreateWindowAnimationTarget(srcInfo, srcNode);
if (srcTarget == nullptr) {
@@ -206,6 +209,7 @@ WMError RemoteAnimation::NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo
}
WLOGFI("RSWindowAnimation: notify animation close id:%{public}u!", srcNode->GetWindowId());
srcNode->isPlayAnimationHide_ = true;
windowRoot->RemoveWindowNode(srcNode->GetWindowId());
wptr<WindowNode> weak = srcNode;
auto closeFunc = [weak, event]() {
auto weakNode = weak.promote();
@@ -217,7 +221,8 @@ WMError RemoteAnimation::NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo
} else if (event == TransitionEvent::BACK) {
WLOGFI("terminate windowId: %{public}u, name:%{public}s",
weakNode->GetWindowId(), weakNode->GetWindowName().c_str());
AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(weakNode->abilityToken_, -1);
AAFwk::Want resultWant;
AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(weakNode->abilityToken_, -1, &resultWant);
}
FinishAsyncTraceArgs(HITRACE_TAG_WINDOW_MANAGER, static_cast<int32_t>(TraceTaskId::REMOTE_ANIMATION),
"wms:async:ShowRemoteAnimation");
@@ -233,7 +238,7 @@ WMError RemoteAnimation::NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo
return WMError::WM_OK;
}
WMError RemoteAnimation::NotifyAnimationByHome()
WMError RemoteAnimation::NotifyAnimationByHome(sptr<WindowRoot>& windowRoot)
{
if (!CheckAnimationController()) {
return WMError::WM_ERROR_NO_REMOTE_ANIMATION;
@@ -249,6 +254,7 @@ WMError RemoteAnimation::NotifyAnimationByHome()
continue;
}
srcNode->isPlayAnimationHide_ = true;
windowRoot->RemoveWindowNode(srcNode->GetWindowId());
animationTargets.emplace_back(srcTarget);
}
auto func = []() {
+5 -6
View File
@@ -138,14 +138,14 @@ WMError WindowController::NotifyWindowTransition(sptr<WindowTransitionInfo>& src
if (dstNode->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
windowRoot_->MinimizeStructuredAppWindowsExceptSelf(dstNode); // avoid split/float mode minimize
}
return RemoteAnimation::NotifyAnimationTransition(srcInfo, dstInfo, srcNode, dstNode);
return RemoteAnimation::NotifyAnimationTransition(srcInfo, dstInfo, srcNode, dstNode, windowRoot_);
}
case TransitionEvent::MINIMIZE:
return RemoteAnimation::NotifyAnimationMinimize(srcInfo, srcNode);
return RemoteAnimation::NotifyAnimationMinimize(srcInfo, srcNode, windowRoot_);
case TransitionEvent::CLOSE:
return RemoteAnimation::NotifyAnimationClose(srcInfo, srcNode, TransitionEvent::CLOSE);
return RemoteAnimation::NotifyAnimationClose(srcInfo, srcNode, TransitionEvent::CLOSE, windowRoot_);
case TransitionEvent::BACK:
return RemoteAnimation::NotifyAnimationClose(srcInfo, srcNode, TransitionEvent::BACK);
return RemoteAnimation::NotifyAnimationClose(srcInfo, srcNode, TransitionEvent::BACK, windowRoot_);
default:
return WMError::WM_ERROR_NO_REMOTE_ANIMATION;
}
@@ -726,7 +726,7 @@ WMError WindowController::ProcessPointUp(uint32_t windowId)
void WindowController::MinimizeAllAppWindows(DisplayId displayId)
{
windowRoot_->MinimizeAllAppWindows(displayId);
if (RemoteAnimation::NotifyAnimationByHome() != WMError::WM_OK) {
if (RemoteAnimation::NotifyAnimationByHome(windowRoot_) != WMError::WM_OK) {
MinimizeApp::ExecuteMinimizeAll();
}
}
@@ -905,7 +905,6 @@ WMError WindowController::UpdateProperty(sptr<WindowProperty>& property, Propert
}
case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: {
node->SetTransform(property->GetTransform());
node->SetWindowSizeChangeReason(WindowSizeChangeReason::TRANSFORM);
ret = UpdateTransform(windowId);
break;
}
+2 -3
View File
@@ -346,8 +346,7 @@ void WindowLayoutPolicy::UpdateClientRectAndResetReason(const sptr<WindowNode>&
"%{public}u", node->GetWindowId(), winRect.posX_, winRect.posY_, winRect.width_, winRect.height_, reason);
node->GetWindowToken()->UpdateWindowRect(winRect, node->GetDecoStatus(), reason);
}
if ((reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END) &&
(node->GetWindowType() != WindowType::WINDOW_TYPE_DOCK_SLICE)) {
if ((reason != WindowSizeChangeReason::MOVE) && (node->GetWindowType() != WindowType::WINDOW_TYPE_DOCK_SLICE)) {
node->ResetWindowSizeChangeReason();
}
}
@@ -947,7 +946,7 @@ bool WindowLayoutPolicy::IsFullScreenRecentWindowExist(const std::vector<sptr<Wi
void WindowLayoutPolicy::UpdateSurfaceBounds(const sptr<WindowNode>& node, const Rect& winRect, const Rect& preRect)
{
if (node->GetWindowType() == WindowType::WINDOW_TYPE_APP_COMPONENT ||
node->GetWindowSizeChangeReason() == WindowSizeChangeReason::TRANSFORM) {
node->GetWindowProperty()->GetAnimationFlag() == static_cast<uint32_t>(WindowAnimation::CUSTOM)) {
WLOGFI("not need to update bounds");
return;
}
@@ -314,12 +314,9 @@ void WindowLayoutPolicyCascade::UpdateLayoutRect(const sptr<WindowNode>& node)
ApplyWindowRectConstraints(node, winRect);
node->SetWindowRect(winRect);
CalcAndSetNodeHotZone(winRect, node);
UpdateClientRectAndResetReason(node, lastWinRect, winRect);
// update node bounds
// update node bounds before reset reason
UpdateSurfaceBounds(node, winRect, lastWinRect);
UpdateClientRectAndResetReason(node, lastWinRect, winRect);
}
void WindowLayoutPolicyCascade::UpdateSurfaceBounds(
+2 -2
View File
@@ -213,7 +213,6 @@ void WindowLayoutPolicyTile::LayoutForegroundNodeQueue(DisplayId displayId)
node->GetWindowToken()->UpdateWindowRect(
winRect, node->GetDecoStatus(), node->GetWindowSizeChangeReason());
}
UpdateSurfaceBounds(node, winRect, lastRect);
for (auto& childNode : node->children_) {
LayoutWindowNode(childNode);
@@ -377,8 +376,9 @@ void WindowLayoutPolicyTile::UpdateLayoutRect(const sptr<WindowNode>& node)
node->SetWindowRect(winRect);
CalcAndSetNodeHotZone(winRect, node);
UpdateClientRectAndResetReason(node, lastRect, winRect);
// update Node Bounds before reset Reason
UpdateSurfaceBounds(node, winRect, lastRect);
UpdateClientRectAndResetReason(node, lastRect, winRect);
}
} // Rosen
} // OHOS
+19 -3
View File
@@ -24,6 +24,7 @@
#include "common_event_manager.h"
#include "dm_common.h"
#include "remote_animation.h"
#include "starting_window.h"
#include "window_helper.h"
#include "window_inner_manager.h"
@@ -259,6 +260,21 @@ void WindowNodeContainer::RemoveWindowNodeFromWindowTree(sptr<WindowNode>& node)
node->parent_ = nullptr;
}
void WindowNodeContainer::RemoveNodeFromRSTree(sptr<WindowNode>& node)
{
if (!node->isPlayAnimationHide_) {
bool isAnimationPlayed = false;
if (RemoteAnimation::CheckAnimationController() && WindowHelper::IsMainWindow(node->GetWindowType())) {
isAnimationPlayed = true;
}
for (auto& displayId : node->GetShowingDisplays()) {
UpdateRSTree(node, displayId, false, isAnimationPlayed);
}
} else {
node->isPlayAnimationHide_ = false;
}
}
WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
{
if (node == nullptr) {
@@ -274,9 +290,9 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr<WindowNode>& node)
node->requestedVisibility_ = false;
node->currentVisibility_ = false;
// Remove node from RSTree
for (auto& displayId : node->GetShowingDisplays()) {
UpdateRSTree(node, displayId, false, node->isPlayAnimationHide_);
}
// When RemoteAnimation exists, Remove node from RSTree after animation
RemoveNodeFromRSTree(node);
auto emptyVec = std::vector<DisplayId>();
node->showingDisplays_.swap(emptyVec);