From f13be2bf825ea3ce48d2d1460469a476a4ccd0ea Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Tue, 7 Jun 2022 16:36:27 +0800 Subject: [PATCH] add startingwindow and remoteanimation to async queue Signed-off-by: chyyy0213 Change-Id: I0cf9ace1f8de29439641a8916d506776e16fcc74 Signed-off-by: chyyy0213 --- wm/src/window_adapter.cpp | 2 +- wmserver/include/window_manager_service.h | 3 ++- .../include/zidl/window_manager_interface.h | 3 ++- wmserver/include/zidl/window_manager_proxy.h | 3 ++- wmserver/src/window_manager_service.cpp | 27 ++++++++++++------- wmserver/src/zidl/window_manager_proxy.cpp | 7 ++++- wmserver/src/zidl/window_manager_stub.cpp | 3 ++- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 34947653..578ad9c8 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -255,7 +255,7 @@ WMError WindowAdapter::NotifyWindowTransition(sptr from, s { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); - return windowManagerServiceProxy_->NotifyWindowTransition(from, to); + return windowManagerServiceProxy_->NotifyWindowTransition(from, to, true); } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index d0448d09..ea1f8e29 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -69,7 +69,8 @@ public: uint32_t& windowId, sptr token) override; WMError AddWindow(sptr& property) override; WMError RemoveWindow(uint32_t windowId) override; - WMError NotifyWindowTransition(sptr& from, sptr& to) override; + WMError NotifyWindowTransition(sptr& from, sptr& to, + bool isFromClient = false) override; WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 4500eca1..72d04a6d 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -84,7 +84,8 @@ public: virtual WMError GetAccessibilityWindowInfo(sptr& windowInfo) = 0; virtual WMError SetWindowAnimationController(const sptr& controller) = 0; virtual WMError GetSystemConfig(SystemConfig& systemConfig) = 0; - virtual WMError NotifyWindowTransition(sptr& from, sptr& to) = 0; + virtual WMError NotifyWindowTransition(sptr& from, sptr& to, + bool isFromClient = false) = 0; virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones) = 0; }; } diff --git a/wmserver/include/zidl/window_manager_proxy.h b/wmserver/include/zidl/window_manager_proxy.h index 27e4ddc7..0f1b45e3 100644 --- a/wmserver/include/zidl/window_manager_proxy.h +++ b/wmserver/include/zidl/window_manager_proxy.h @@ -32,7 +32,8 @@ public: uint32_t& windowId, sptr token) override; WMError AddWindow(sptr& property) override; WMError RemoveWindow(uint32_t windowId) override; - WMError NotifyWindowTransition(sptr& from, sptr& to) override; + WMError NotifyWindowTransition(sptr& from, sptr& to, + bool isFromClient = false) override; WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 5187e6d4..fd92ad24 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -136,7 +136,7 @@ void WindowManagerServiceHandler::NotifyWindowTransition( { sptr fromInfo = new WindowTransitionInfo(from); sptr toInfo = new WindowTransitionInfo(to); - WindowManagerService::GetInstance().NotifyWindowTransition(fromInfo, toInfo); + WindowManagerService::GetInstance().NotifyWindowTransition(fromInfo, toInfo, false); } int32_t WindowManagerServiceHandler::GetFocusWindow(sptr& abilityToken) @@ -259,11 +259,20 @@ void WindowManagerService::OnStop() } WMError WindowManagerService::NotifyWindowTransition( - sptr& fromInfo, sptr& toInfo) + sptr& fromInfo, sptr& toInfo, bool isFromClient) { - return wmsTaskLooper_->ScheduleTask([this, &fromInfo, &toInfo]() { - return windowController_->NotifyWindowTransition(fromInfo, toInfo); - }).get(); + if (!isFromClient) { + WLOGFI("NotifyWindowTransition asynchronously."); + wmsTaskLooper_->PostTask([this, fromInfo, toInfo]() mutable { + return windowController_->NotifyWindowTransition(fromInfo, toInfo); + }); + return WMError::WM_OK; + } else { + WLOGFI("NotifyWindowTransition synchronously."); + return wmsTaskLooper_->ScheduleTask([this, &fromInfo, &toInfo]() { + return windowController_->NotifyWindowTransition(fromInfo, toInfo); + }).get(); + } } WMError WindowManagerService::GetFocusWindowInfo(sptr& abilityToken) @@ -280,9 +289,9 @@ void WindowManagerService::StartingWindow(sptr info, sptr< WLOGFI("startingWindow not open!"); return; } - return wmsTaskLooper_->ScheduleTask([this, &info, &pixelMap, isColdStart, bkgColor]() { + return wmsTaskLooper_->PostTask([this, info, pixelMap, isColdStart, bkgColor]() { return windowController_->StartingWindow(info, pixelMap, bkgColor, isColdStart); - }).wait(); + }); } void WindowManagerService::CancelStartingWindow(sptr abilityToken) @@ -292,9 +301,9 @@ void WindowManagerService::CancelStartingWindow(sptr abilityToken WLOGFI("startingWindow not open!"); return; } - return wmsTaskLooper_->ScheduleTask([this, &abilityToken]() { + return wmsTaskLooper_->PostTask([this, abilityToken]() { return windowController_->CancelStartingWindow(abilityToken); - }).wait(); + }); } WMError WindowManagerService::CreateWindow(sptr& window, sptr& property, diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index dff42403..bfb63fd7 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -570,7 +570,8 @@ WMError WindowManagerProxy::GetSystemConfig(SystemConfig& systemConfig) return static_cast(ret); } -WMError WindowManagerProxy::NotifyWindowTransition(sptr& from, sptr& to) +WMError WindowManagerProxy::NotifyWindowTransition(sptr& from, sptr& to, + bool isFromClient) { MessageParcel data; MessageParcel reply; @@ -591,6 +592,10 @@ WMError WindowManagerProxy::NotifyWindowTransition(sptr& f return WMError::WM_ERROR_IPC_FAILED; } + if (!data.WriteBool(isFromClient)) { + WLOGFE("Failed to write to isFromClient!"); + return WMError::WM_ERROR_IPC_FAILED; + } auto error = Remote()->SendRequest(static_cast(WindowManagerMessage::TRANS_ID_NOTIFY_WINDOW_TRANSITION), data, reply, option); if (error != ERR_NONE) { diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 2823f58c..1142b36f 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -190,7 +190,8 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M case WindowManagerMessage::TRANS_ID_NOTIFY_WINDOW_TRANSITION: { sptr from = data.ReadParcelable(); sptr to = data.ReadParcelable(); - WMError errCode = NotifyWindowTransition(from, to); + bool isFromClient = data.ReadBool(); + WMError errCode = NotifyWindowTransition(from, to, isFromClient); reply.WriteInt32(static_cast(errCode)); break; }