From 513afc69edbba35fecc28b77ddf7ddec792080db Mon Sep 17 00:00:00 2001 From: koroltang Date: Sat, 15 Feb 2025 19:52:13 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=20=20=E6=96=B0=E5=A2=9E=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=B8=8A=E4=B8=8B=E6=A0=91=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E7=9B=91=E5=90=AC=E5=92=8C=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- interfaces/innerkits/wm/window.h | 14 +++++++++ .../include/zidl/session_stage_interface.h | 1 + .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../src/zidl/session_stage_proxy.cpp | 26 +++++++++++++++++ .../container/src/zidl/session_stage_stub.cpp | 14 +++++++++ window_scene/session/host/include/session.h | 5 ++++ window_scene/session/host/src/session.cpp | 9 ++++++ wm/include/window_scene_session_impl.h | 12 ++++++++ wm/include/window_session_impl.h | 5 ++++ wm/src/window_scene_session_impl.cpp | 29 +++++++++++++++++++ 12 files changed, 118 insertions(+) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index f79ee59394..2340af7e3e 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -144,6 +144,12 @@ public: virtual void AfterDestroyed() {} }; +class IWindowSceneListner : virtual public RefBase { +public: + virtual void AfterAttachToFrameNode() {} + virtual void AfterDetachFromFrameNode() {} +}; + /** * @class IWindowChangeListener * @@ -3176,6 +3182,14 @@ public: * @param want the want to update param. */ virtual void UpdateExtensionConfig(const std::shared_ptr& want) {} + + /** + * @brief Register window scene attach or detach framenode listener. + * + * @param listener IWindowSceneListner. + * @return WM_OK means register success, others means register failed. + */ + virtual WMError RegisterWindowSceneListener(const sptr& listener) { return WMError::WM_OK; } }; } } diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 2a450d4a5d..be595a125f 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -242,6 +242,7 @@ public: virtual WSError SetSupportEnterWaterfallMode(bool isSupportEnter) { return WSError::WS_DO_NOTHING; } virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0; virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0; + virtual WSError NotifyWindowSceneAttachStateChange(bool isAttach) { return WSErrors::WS_DO_NOTHING; } }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 261ca3faad..13daad4eb1 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -75,6 +75,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE, TRANS_ID_NOTIFY_CROSS_AXIS, TRANS_ID_NOTIFY_PIPSIZE_CHANGE, + TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 71662c3c46..e936862d9d 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -89,6 +89,7 @@ public: WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) override; WSError NotifyHighlightChange(bool isHighlight) override; void NotifyWindowCrossAxisChange(CrossAxisState state) override; + WSError NotifyWindowSceneAttachStateChange(bool isAttach) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index ac5f19c3ee..654a26c9f1 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -85,6 +85,7 @@ private: int HandleNotifyHighlightChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply); + int HandleNotifyWindowSceneAttachStateChange(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 90758fc8e4..f5ea3ac8da 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -1638,4 +1638,30 @@ void SessionStageProxy::NotifyWindowCrossAxisChange(CrossAxisState state) return; } } + +WSError SessionStageProxy::NotifyWindowSceneAttachStateChange(bool isAttach) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteUint32(isAttach)) { + TLOGE(WmsLogTag::WMS_SUB, "Write params failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_SUB, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index 5e549e0fce..d55e18c9f0 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -198,6 +198,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyWindowCrossAxisChange(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE): return HandleNotifyPipSizeChange(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE): + return HandleNotifyWindowSceneAttachStateChange(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -826,4 +828,16 @@ int SessionStageStub::HandleNotifyPipSizeChange(MessageParcel& data, MessageParc NotifyPipWindowSizeChange(width, height, scale); return ERR_NONE; } + +int SessionStageStub::HandleNotifyWindowSceneAttachStateChange(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_SUB, "in"); + bool isAttach = false; + if (!data.ReadBool(isAttach)) { + return ERR_INVALID_VALUE; + } + NotifyWindowSceneAttachStateChange(isAttach); + return ERR_NONE; +} + } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 8d90597441..2e2c924bd0 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -614,6 +614,11 @@ public: WindowLayoutInfo GetWindowLayoutInfoForWindowInfo() const; WindowMetaInfo GetWindowMetaInfoForWindowInfo() const; + /** + * Window Scene + */ + void NotifyWindowSceneAttachStateChange(bool isAttach); + protected: class SessionLifeCycleTask : public virtual RefBase { public: diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index a9c091ec53..ea90ac556a 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1576,6 +1576,7 @@ void Session::SetAttachState(bool isAttach, WindowMode windowMode) TLOGND(WmsLogTag::WMS_LIFE, "session is null"); return; } + session->NotifyWindowSceneAttachStateChange(isAttach); TLOGND(WmsLogTag::WMS_LIFE, "isAttach:%{public}d persistentId:%{public}d", isAttach, session->GetPersistentId()); if (!isAttach && session->detachCallback_ != nullptr) { @@ -1955,6 +1956,14 @@ void Session::NotifyScreenshot() sessionStage_->NotifyScreenshot(); } +void Session::NotifyWindowSceneAttachStateChange(bool isAttach) +{ + if (!sessionStage_) { + return; + } + sessionStage_->NotifyWindowSceneAttachStateChange(isAttach); +} + WSError Session::NotifyCloseExistPipWindow() { if (!sessionStage_) { diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 3d616a6aca..de992c9ba7 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -231,6 +231,11 @@ public: */ WMError NotifyRemoveStartingWindow() override; + /* + * Window Scene + */ + WMError RegisterWindowSceneListener(const sptr windowSceneListener_; + WSError NotifyWindowSceneAttachStateChange(bool isAttach) override; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index af9bd75df1..8365851c90 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -748,6 +748,11 @@ private: MouseEventFilterFunc mouseEventFilter_; std::mutex touchEventFilterMutex_; TouchEventFilterFunc touchEventFilter_; + + /* + * Window Scene + */ + WSError NotifyWindowSSceneChange(bool isAttach) override { return WSError::WS_OK; } }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index a562c8289b..9ca4b744ff 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -129,6 +129,7 @@ constexpr uint32_t FORCE_LIMIT_MIN_FLOATING_HEIGHT = 40; uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920; std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_; using WindowSessionImplMap = std::map>>; +std::mutex WindowSceneSessionImpl::windowSceneListenerMutex_; WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr& option) : WindowSessionImpl(option) { @@ -4549,6 +4550,34 @@ WMError WindowSceneSessionImpl::RegisterKeyboardPanelInfoChangeListener( return WMError::WM_OK; } +WMError WindowSceneSessionImpl::RegisterWindowSceneListener(const sptr& listener) +{ + std::lock_guard lockListener(windowSceneListenerMutex_); + if (listener == nullptr) { + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); + windowSceneListener_ = listener; + return WMError::WM_OK; + } + TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d listener already registered", GetPersistentId()); + return WMError::WM_ERROR_INVALID_OPERATION; +} + +WMError WindowSceneSessionImpl::NotifyWindowSceneAttachStateChange(bool isAttach) +{ + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); + if (!windowSceneListener_) { + TLOGW(WmsLogTag::WMS_SUB, "listener is null"); + return WMError::WM_ERROR_NULLPTR; + } + + if (isAttach) { + windowSceneListener_->AfterAttachToFrameNode(); + } else { + windowSceneListener_->AfterDetachFromFrameNode(); + } + return WMError::WM_OK; +} + WMError WindowSceneSessionImpl::UnregisterKeyboardPanelInfoChangeListener( const sptr& listener) { -- Gitee From 701543e9ced02b49126a420f9c49a58a444b9151 Mon Sep 17 00:00:00 2001 From: koroltang Date: Sat, 15 Feb 2025 19:52:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=92=8C=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- interfaces/innerkits/wm/window.h | 14 +++++++++++--- .../include/zidl/session_stage_interface.h | 2 +- .../zidl/session_stage_ipc_interface_code.h | 2 +- .../container/src/zidl/session_stage_proxy.cpp | 4 ++-- .../container/src/zidl/session_stage_stub.cpp | 4 ++-- wm/include/window_scene_session_impl.h | 7 ++++--- wm/src/window_scene_session_impl.cpp | 14 +++++++------- 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2340af7e3e..e1f9b8bf0c 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -144,7 +144,12 @@ public: virtual void AfterDestroyed() {} }; -class IWindowSceneListner : virtual public RefBase { +/** + * @class IWindowSceneAttachStateChangeListner + * + * @brief IWindowSceneAttachStateChangeListner is used to observe the window scene attach or detach state changed. + */ +class IWindowSceneAttachStateChangeListner : virtual public RefBase { public: virtual void AfterAttachToFrameNode() {} virtual void AfterDetachFromFrameNode() {} @@ -3186,10 +3191,13 @@ public: /** * @brief Register window scene attach or detach framenode listener. * - * @param listener IWindowSceneListner. + * @param listener IWindowSceneAttachStateChangeListner. * @return WM_OK means register success, others means register failed. */ - virtual WMError RegisterWindowSceneListener(const sptr& listener) { return WMError::WM_OK; } + virtual WMError RegisterWindowSceneAttachStateChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } }; } } diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index be595a125f..9ab1b26869 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -242,7 +242,7 @@ public: virtual WSError SetSupportEnterWaterfallMode(bool isSupportEnter) { return WSError::WS_DO_NOTHING; } virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0; virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0; - virtual WSError NotifyWindowSceneAttachStateChange(bool isAttach) { return WSErrors::WS_DO_NOTHING; } + virtual WSError NotifyWindowSceneAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; } }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 13daad4eb1..48d8e6f5e0 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -75,7 +75,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE, TRANS_ID_NOTIFY_CROSS_AXIS, TRANS_ID_NOTIFY_PIPSIZE_CHANGE, - TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE, + TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index f5ea3ac8da..df7ec1c960 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -1648,7 +1648,7 @@ WSError SessionStageProxy::NotifyWindowSceneAttachStateChange(bool isAttach) TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } - if (!data.WriteUint32(isAttach)) { + if (!data.WriteBool(isAttach)) { TLOGE(WmsLogTag::WMS_SUB, "Write params failed"); return WSError::WS_ERROR_IPC_FAILED; } @@ -1657,7 +1657,7 @@ WSError SessionStageProxy::NotifyWindowSceneAttachStateChange(bool isAttach) TLOGE(WmsLogTag::WMS_SUB, "remote is null"); return WSError::WS_ERROR_IPC_FAILED; } - if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE), + if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE), data, reply, option) != ERR_NONE) { TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index d55e18c9f0..52b9f84222 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -198,7 +198,7 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyWindowCrossAxisChange(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE): return HandleNotifyPipSizeChange(data, reply); - case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_CHANGE): + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE): return HandleNotifyWindowSceneAttachStateChange(data, reply); default: WLOGFE("Failed to find function handler!"); @@ -834,7 +834,7 @@ int SessionStageStub::HandleNotifyWindowSceneAttachStateChange(MessageParcel& da TLOGD(WmsLogTag::WMS_SUB, "in"); bool isAttach = false; if (!data.ReadBool(isAttach)) { - return ERR_INVALID_VALUE; + return ERR_INVALID_DATA; } NotifyWindowSceneAttachStateChange(isAttach); return ERR_NONE; diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index de992c9ba7..62fb3cf61b 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -234,7 +234,8 @@ public: /* * Window Scene */ - WMError RegisterWindowSceneListener(const sptr windowSceneListener_; + static std::mutex windowSceneAttachStateChangeListenerMutex_; + sptr windowSceneAttachStateChangeListener_; WSError NotifyWindowSceneAttachStateChange(bool isAttach) override; }; } // namespace Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 9ca4b744ff..de0cb8b340 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -129,7 +129,7 @@ constexpr uint32_t FORCE_LIMIT_MIN_FLOATING_HEIGHT = 40; uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920; std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_; using WindowSessionImplMap = std::map>>; -std::mutex WindowSceneSessionImpl::windowSceneListenerMutex_; +std::mutex WindowSceneSessionImpl::windowSceneAttachStateChangeListenerMutex_; WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr& option) : WindowSessionImpl(option) { @@ -4550,12 +4550,12 @@ WMError WindowSceneSessionImpl::RegisterKeyboardPanelInfoChangeListener( return WMError::WM_OK; } -WMError WindowSceneSessionImpl::RegisterWindowSceneListener(const sptr& listener) +WMError WindowSceneSessionImpl::RegisterWindowSceneAttachStateChangeListener(const sptr& listener) { - std::lock_guard lockListener(windowSceneListenerMutex_); + std::lock_guard lockListener(windowSceneAttachStateChangeListenerMutex_); if (listener == nullptr) { TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); - windowSceneListener_ = listener; + windowSceneAttachStateChangeListener_ = listener; return WMError::WM_OK; } TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d listener already registered", GetPersistentId()); @@ -4565,15 +4565,15 @@ WMError WindowSceneSessionImpl::RegisterWindowSceneListener(const sptrAfterAttachToFrameNode(); + windowSceneAttachStateChangeListener_->AfterAttachToFrameNode(); } else { - windowSceneListener_->AfterDetachFromFrameNode(); + windowSceneAttachStateChangeListener_->AfterDetachFromFrameNode(); } return WMError::WM_OK; } -- Gitee From 2e539c135af1e5665bc7996ef9a14a86f879337b Mon Sep 17 00:00:00 2001 From: koroltang Date: Mon, 17 Feb 2025 15:14:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- interfaces/innerkits/wm/window.h | 10 ++++----- .../include/zidl/session_stage_interface.h | 2 +- .../zidl/session_stage_ipc_interface_code.h | 2 +- .../include/zidl/session_stage_proxy.h | 2 +- .../include/zidl/session_stage_stub.h | 2 +- .../src/zidl/session_stage_proxy.cpp | 5 +++-- .../container/src/zidl/session_stage_stub.cpp | 8 +++---- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/session.cpp | 6 +++--- wm/include/window_scene_session_impl.h | 10 ++++----- wm/include/window_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 21 ++++++++++--------- 12 files changed, 37 insertions(+), 35 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index e1f9b8bf0c..5e758cfff1 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -145,11 +145,11 @@ public: }; /** - * @class IWindowSceneAttachStateChangeListner + * @class IWindowAttachStateChangeListner * - * @brief IWindowSceneAttachStateChangeListner is used to observe the window scene attach or detach state changed. + * @brief IWindowAttachStateChangeListner is used to observe the window attach or detach state changed. */ -class IWindowSceneAttachStateChangeListner : virtual public RefBase { +class IWindowAttachStateChangeListner : virtual public RefBase { public: virtual void AfterAttachToFrameNode() {} virtual void AfterDetachFromFrameNode() {} @@ -3191,10 +3191,10 @@ public: /** * @brief Register window scene attach or detach framenode listener. * - * @param listener IWindowSceneAttachStateChangeListner. + * @param listener IWindowAttachStateChangeListner. * @return WM_OK means register success, others means register failed. */ - virtual WMError RegisterWindowSceneAttachStateChangeListener(const sptr& listener) + virtual WMError RegisterWindowAttachStateChangeListener(const sptr& listener) { return WMError::WM_OK; } diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 9ab1b26869..b5308fdd7b 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -242,7 +242,7 @@ public: virtual WSError SetSupportEnterWaterfallMode(bool isSupportEnter) { return WSError::WS_DO_NOTHING; } virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0; virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0; - virtual WSError NotifyWindowSceneAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; } + virtual WSError NotifyWindowAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; } }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 48d8e6f5e0..3f1e7f6aca 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -75,7 +75,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE, TRANS_ID_NOTIFY_CROSS_AXIS, TRANS_ID_NOTIFY_PIPSIZE_CHANGE, - TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE, + TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index e936862d9d..5f20185a5a 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -89,7 +89,7 @@ public: WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) override; WSError NotifyHighlightChange(bool isHighlight) override; void NotifyWindowCrossAxisChange(CrossAxisState state) override; - WSError NotifyWindowSceneAttachStateChange(bool isAttach) override; + WSError NotifyWindowAttachStateChange(bool isAttach) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index 654a26c9f1..c6e53da460 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -85,7 +85,7 @@ private: int HandleNotifyHighlightChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply); int HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply); - int HandleNotifyWindowSceneAttachStateChange(MessageParcel& data, MessageParcel& reply); + int HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index df7ec1c960..f498e0df59 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -1639,7 +1639,7 @@ void SessionStageProxy::NotifyWindowCrossAxisChange(CrossAxisState state) } } -WSError SessionStageProxy::NotifyWindowSceneAttachStateChange(bool isAttach) +WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach) { MessageParcel data; MessageParcel reply; @@ -1657,7 +1657,8 @@ WSError SessionStageProxy::NotifyWindowSceneAttachStateChange(bool isAttach) TLOGE(WmsLogTag::WMS_SUB, "remote is null"); return WSError::WS_ERROR_IPC_FAILED; } - if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE), + if (remote->SendRequest( + static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE), data, reply, option) != ERR_NONE) { TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index 52b9f84222..881fd73409 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -198,8 +198,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyWindowCrossAxisChange(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE): return HandleNotifyPipSizeChange(data, reply); - case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_SCENE_ATTACH_STATE_CHANGE): - return HandleNotifyWindowSceneAttachStateChange(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE): + return HandleNotifyWindowAttachStateChange(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -829,14 +829,14 @@ int SessionStageStub::HandleNotifyPipSizeChange(MessageParcel& data, MessageParc return ERR_NONE; } -int SessionStageStub::HandleNotifyWindowSceneAttachStateChange(MessageParcel& data, MessageParcel& reply) +int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply) { TLOGD(WmsLogTag::WMS_SUB, "in"); bool isAttach = false; if (!data.ReadBool(isAttach)) { return ERR_INVALID_DATA; } - NotifyWindowSceneAttachStateChange(isAttach); + NotifyWindowAttachStateChange(isAttach); return ERR_NONE; } diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 2e2c924bd0..536156db55 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -617,7 +617,7 @@ public: /** * Window Scene */ - void NotifyWindowSceneAttachStateChange(bool isAttach); + void NotifyWindowAttachStateChange(bool isAttach); protected: class SessionLifeCycleTask : public virtual RefBase { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index ea90ac556a..8c0c11dd40 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1576,7 +1576,7 @@ void Session::SetAttachState(bool isAttach, WindowMode windowMode) TLOGND(WmsLogTag::WMS_LIFE, "session is null"); return; } - session->NotifyWindowSceneAttachStateChange(isAttach); + session->NotifyWindowAttachStateChange(isAttach); TLOGND(WmsLogTag::WMS_LIFE, "isAttach:%{public}d persistentId:%{public}d", isAttach, session->GetPersistentId()); if (!isAttach && session->detachCallback_ != nullptr) { @@ -1956,12 +1956,12 @@ void Session::NotifyScreenshot() sessionStage_->NotifyScreenshot(); } -void Session::NotifyWindowSceneAttachStateChange(bool isAttach) +void Session::NotifyWindowAttachStateChange(bool isAttach) { if (!sessionStage_) { return; } - sessionStage_->NotifyWindowSceneAttachStateChange(isAttach); + sessionStage_->NotifyWindowAttachStateChange(isAttach); } WSError Session::NotifyCloseExistPipWindow() diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 62fb3cf61b..76abca6328 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -234,8 +234,8 @@ public: /* * Window Scene */ - WMError RegisterWindowSceneAttachStateChangeListener( - const sptr& listener) override; protected: WMError CreateAndConnectSpecificSession(); @@ -396,9 +396,9 @@ private: /* * Window Scene */ - static std::mutex windowSceneAttachStateChangeListenerMutex_; - sptr windowSceneAttachStateChangeListener_; - WSError NotifyWindowSceneAttachStateChange(bool isAttach) override; + static std::mutex windowAttachStateChangeListenerMutex_; + sptr windowAttachStateChangeListener_; + WSError NotifyWindowAttachStateChange(bool isAttach) override; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 8365851c90..e6d7308818 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -752,7 +752,7 @@ private: /* * Window Scene */ - WSError NotifyWindowSSceneChange(bool isAttach) override { return WSError::WS_OK; } + WSError NotifyWindowAttachStateChange(bool isAttach) override { return WSError::WS_OK; } }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index de0cb8b340..6f3c5cbe8c 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -129,7 +129,7 @@ constexpr uint32_t FORCE_LIMIT_MIN_FLOATING_HEIGHT = 40; uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920; std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_; using WindowSessionImplMap = std::map>>; -std::mutex WindowSceneSessionImpl::windowSceneAttachStateChangeListenerMutex_; +std::mutex WindowSceneSessionImpl::windowAttachStateChangeListenerMutex_; WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr& option) : WindowSessionImpl(option) { @@ -4550,32 +4550,33 @@ WMError WindowSceneSessionImpl::RegisterKeyboardPanelInfoChangeListener( return WMError::WM_OK; } -WMError WindowSceneSessionImpl::RegisterWindowSceneAttachStateChangeListener(const sptr& listener) +WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( + const sptr& listener) { - std::lock_guard lockListener(windowSceneAttachStateChangeListenerMutex_); + std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); if (listener == nullptr) { TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); - windowSceneAttachStateChangeListener_ = listener; + windowAttachStateChangeListener_ = listener; return WMError::WM_OK; } TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d listener already registered", GetPersistentId()); return WMError::WM_ERROR_INVALID_OPERATION; } -WMError WindowSceneSessionImpl::NotifyWindowSceneAttachStateChange(bool isAttach) +WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) { TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); - if (!windowSceneAttachStateChangeListener_) { + if (!windowAttachStateChangeListener_) { TLOGW(WmsLogTag::WMS_SUB, "listener is null"); - return WMError::WM_ERROR_NULLPTR; + return WSError::WS_ERROR_NULLPTR; } if (isAttach) { - windowSceneAttachStateChangeListener_->AfterAttachToFrameNode(); + windowAttachStateChangeListener_->AfterAttachToFrameNode(); } else { - windowSceneAttachStateChangeListener_->AfterDetachFromFrameNode(); + windowAttachStateChangeListener_->AfterDetachFromFrameNode(); } - return WMError::WM_OK; + return WSError::WS_OK; } WMError WindowSceneSessionImpl::UnregisterKeyboardPanelInfoChangeListener( -- Gitee From 00b1032139a99776c9e92f87a246fa0158230829 Mon Sep 17 00:00:00 2001 From: koroltang Date: Mon, 17 Feb 2025 21:41:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- interfaces/innerkits/wm/window.h | 4 ++-- window_scene/session/host/include/session.h | 5 ----- window_scene/session/host/src/session.cpp | 12 +++--------- wm/src/window_scene_session_impl.cpp | 16 ++++++++-------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 5e758cfff1..aa6a858e99 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -151,8 +151,8 @@ public: */ class IWindowAttachStateChangeListner : virtual public RefBase { public: - virtual void AfterAttachToFrameNode() {} - virtual void AfterDetachFromFrameNode() {} + virtual void AfterAttached() {} + virtual void AfterDetached() {} }; /** diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 536156db55..8d90597441 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -614,11 +614,6 @@ public: WindowLayoutInfo GetWindowLayoutInfoForWindowInfo() const; WindowMetaInfo GetWindowMetaInfoForWindowInfo() const; - /** - * Window Scene - */ - void NotifyWindowAttachStateChange(bool isAttach); - protected: class SessionLifeCycleTask : public virtual RefBase { public: diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 8c0c11dd40..ba9813b0ff 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1576,7 +1576,9 @@ void Session::SetAttachState(bool isAttach, WindowMode windowMode) TLOGND(WmsLogTag::WMS_LIFE, "session is null"); return; } - session->NotifyWindowAttachStateChange(isAttach); + if (session->sessionStage_) { + session->sessionStage_->NotifyWindowAttachStateChange(isAttach); + } TLOGND(WmsLogTag::WMS_LIFE, "isAttach:%{public}d persistentId:%{public}d", isAttach, session->GetPersistentId()); if (!isAttach && session->detachCallback_ != nullptr) { @@ -1956,14 +1958,6 @@ void Session::NotifyScreenshot() sessionStage_->NotifyScreenshot(); } -void Session::NotifyWindowAttachStateChange(bool isAttach) -{ - if (!sessionStage_) { - return; - } - sessionStage_->NotifyWindowAttachStateChange(isAttach); -} - WSError Session::NotifyCloseExistPipWindow() { if (!sessionStage_) { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 6f3c5cbe8c..598b6518d4 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4555,26 +4555,26 @@ WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( { std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); if (listener == nullptr) { - TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); - windowAttachStateChangeListener_ = listener; - return WMError::WM_OK; + TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d, listener is null", GetPersistentId()); + return WMError::WM_ERROR_NULLPTR; } - TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d listener already registered", GetPersistentId()); - return WMError::WM_ERROR_INVALID_OPERATION; + windowAttachStateChangeListener_ = listener; + TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener registered", GetPersistentId()); + return WMError::WM_OK; } WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) { - TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); + TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); if (!windowAttachStateChangeListener_) { TLOGW(WmsLogTag::WMS_SUB, "listener is null"); return WSError::WS_ERROR_NULLPTR; } if (isAttach) { - windowAttachStateChangeListener_->AfterAttachToFrameNode(); + windowAttachStateChangeListener_->AfterAttached(); } else { - windowAttachStateChangeListener_->AfterDetachFromFrameNode(); + windowAttachStateChangeListener_->AfterDetached(); } return WSError::WS_OK; } -- Gitee From ea8f7b847a5290a57d941b1c13b697d3da2c9f9a Mon Sep 17 00:00:00 2001 From: koroltang Date: Wed, 19 Feb 2025 09:29:42 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A3=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- interfaces/innerkits/wm/window.h | 10 ++++++++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index aa6a858e99..1003076e02 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -3198,6 +3198,16 @@ public: { return WMError::WM_OK; } + + /** + * @brief Unregister window scene attach or detach framenode listener. + * + * @return WM_OK means unregister success + */ + virtual WMError UnregisterWindowAttachStateChangeListener() + { + return WMError::WM_OK; + } }; } } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 76abca6328..90265d146a 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -236,6 +236,7 @@ public: */ WMError RegisterWindowAttachStateChangeListener( const sptr& listener) override; + WMError UnregisterWindowAttachStateChangeListener() override; protected: WMError CreateAndConnectSpecificSession(); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 598b6518d4..045d78e3bf 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4563,6 +4563,14 @@ WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( return WMError::WM_OK; } +WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() +{ + std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); + windowAttachStateChangeListener_ = nullptr; + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); + return WMError::WM_OK; +} + WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) { TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); -- Gitee