From a3d93c7822cfb83eb994d66bc4dd93d98edf0b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Fri, 15 Nov 2024 00:07:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=B7=AE=E5=BC=82?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- .../session/host/include/scene_session.h | 23 +++-- window_scene/session/host/include/session.h | 35 ++++--- .../session/host/src/scene_session.cpp | 91 +++++++++++-------- .../session/host/src/zidl/session_proxy.cpp | 10 +- .../session/host/src/zidl/session_stub.cpp | 8 +- .../include/scene_session_manager.h | 13 ++- .../src/scene_session_manager.cpp | 7 +- .../test/unittest/scene_session_test5.cpp | 13 +-- .../test/unittest/session_stub_test.cpp | 4 +- wm/include/window_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 3 +- wm/src/window_session_impl.cpp | 6 +- 12 files changed, 115 insertions(+), 100 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 2efd52478c..24b8acf4ee 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -362,8 +362,6 @@ public: bool GetShowWhenLockedFlagValue() const; bool IsFloatingWindowAppType() const; bool IsNeedDefaultAnimation() const; - bool IsDirtyWindow(); - bool IsDirtyDragWindow(); void SetSystemTouchable(bool touchable) override; bool IsVisibleForAccessibility() const; void SetStartingWindowExitAnimationFlag(bool enable); @@ -528,13 +526,14 @@ public: */ WSError SetSplitButtonVisible(bool isVisible); - void SetRequestNextVsyncFunc(const RequestVsyncFunc& func); - void OnNextVsyncDragReceived(); - /** * Window Layout */ + bool IsDirtyWindow(); + bool IsDirtyDragWindow(); void ResetSizeChangeReasonIfDirty(); + void SetRequestNextVsyncFunc(const RequestVsyncFunc&& func); + void OnNextVsyncReceivedWhenDrag(); void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback); bool SetFrameGravity(Gravity gravity); @@ -687,9 +686,6 @@ private: bool isSupportDragInPcCompatibleMode, bool isGlobal, bool needFlush = true); void HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reason, bool isSupportDragInPcCompatibleMode, bool isGlobal, bool needFlush); - void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); - bool FixRectByAspectRatio(WSRect& rect); - bool SaveAspectRatio(float ratio); void NotifyPropertyWhenConnect(); WSError RaiseAppMainWindowToTop() override; void UpdateWinRectForSystemBar(WSRect& rect); @@ -698,8 +694,6 @@ private: bool IsFullScreenMovable(); bool IsMovable(); void HandleCastScreenConnection(SessionInfo& info, sptr session); - void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason); - void UpdateRectForDrag(WSRect& rect); WMError HandleUpdatePropertyByAction(const sptr& property, WSPropertyChangeAction action); WMError HandleActionUpdateTurnScreenOn(const sptr& property, @@ -795,6 +789,15 @@ private: std::map extWindowFlagsMap_; std::vector extensionTokenInfos_; + /** + * Window Layout + */ + void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); + bool FixRectByAspectRatio(WSRect& rect); + bool SaveAspectRatio(float ratio); + void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason); + WSError UpdateRectForDrag(const WSRect& rect); + /** * Window Decor */ diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 728b1a78aa..6dc5d0cf2c 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -23,14 +23,14 @@ #include #include "interfaces/include/ws_common.h" +#include "occupied_area_change_info.h" +#include "pattern_detach_callback_interface.h" #include "session/container/include/zidl/session_stage_interface.h" #include "session/host/include/zidl/session_stub.h" #include "session/host/include/scene_persistence.h" -#include "wm_common.h" -#include "occupied_area_change_info.h" -#include "window_visibility_info.h" -#include "pattern_detach_callback_interface.h" #include "vsync_station.h" +#include "window_visibility_info.h" +#include "wm_common.h" namespace OHOS::MMI { class PointerEvent; @@ -88,7 +88,7 @@ using NotifyFrameLayoutFinishFunc = std::function; using VisibilityChangedDetectFunc = std::function; using AcquireRotateAnimationConfigFunc = std::function; -using RequestVsyncFunc = std::function& callback)>; +using RequestVsyncFunc = std::function& callback)>; class ILifecycleListener { public: @@ -244,8 +244,6 @@ public: std::string GetWindowName() const; WSRect GetLastLayoutRect() const; WSRect GetLayoutRect() const; - void SetClientRect(const WSRect& rect); - WSRect GetClientRect() const; virtual WSError SetActive(bool active); virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); @@ -513,8 +511,6 @@ public: void SetUIStateDirty(bool dirty); void SetMainSessionUIStateDirty(bool dirty); bool GetUIStateDirty() const; - void ResetDirtyFlags(); - void ResetDragDirtyFlags(); static bool IsScbCoreEnabled(); static void SetScbCoreEnabled(bool enabled); bool IsVisible() const; @@ -542,6 +538,10 @@ public: /** * Window Layout */ + void SetClientRect(const WSRect& rect); + WSRect GetClientRect() const; + void ResetDirtyFlags(); + void ResetDragDirtyFlags(); void SetClientDragEnable(bool dragEnable); std::optional GetClientDragEnable() const; @@ -611,11 +611,6 @@ protected: std::list> lifeCycleTaskQueue_; bool isActive_ = false; bool isSystemActive_ = false; - WSRect winRect_; - WSRect clientRect_; // rect saved when prelayout or notify client to update rect - WSRect lastLayoutRect_; // rect saved when go background - WSRect layoutRect_; // rect of root view - WSRect globalRect_; // globalRect include translate mutable std::mutex globalRectMutex_; WSRectF bounds_; Rotation rotation_; @@ -623,9 +618,7 @@ protected: float offsetY_ = 0.0f; std::atomic_bool isExitSplitOnBackground_ = false; bool isVisible_ = false; - SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; - NotifySessionRectChangeFunc sessionRectChangeFunc_; NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_; NotifySessionStateChangeFunc sessionStateChangeFunc_; NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_; @@ -668,8 +661,6 @@ protected: */ AcquireRotateAnimationConfigFunc acquireRotateAnimationConfigFunc_; - RequestVsyncFunc requestNextVsyncFunc_; - SystemSessionConfig systemConfig_; bool needSnapshot_ = false; float snapshotScale_ = 0.5; @@ -678,6 +669,14 @@ protected: /** * Window Layout */ + RequestVsyncFunc requestNextVsyncFunc_; + WSRect winRect_; + WSRect clientRect_; // rect saved when prelayout or notify client to update rect + WSRect lastLayoutRect_; // rect saved when go background + WSRect layoutRect_; // rect of root view + WSRect globalRect_; // globalRect include translate + SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; + NotifySessionRectChangeFunc sessionRectChangeFunc_; float clientScaleX_ = 1.0f; float clientScaleY_ = 1.0f; float clientPivotX_ = 0.0f; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 21faaf02c5..fdca5b12b0 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -338,13 +338,13 @@ WSError SceneSession::Foreground( return ForegroundTask(property); } -void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc& func) +void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc&& func) { if (func == nullptr) { TLOGI(WmsLogTag::DEFAULT, "func is nullptr"); return; } - requestNextVsyncFunc_ = func; + requestNextVsyncFunc_ = std::move(func); } WSError SceneSession::ForegroundTask(const sptr& property) @@ -1006,39 +1006,44 @@ WSError SceneSession::SetAspectRatio(float ratio) WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::string& updateReason, const std::shared_ptr& rsTransaction) { - auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason]() { + const char* const funcName = __func__; + auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName]() { auto session = weakThis.promote(); if (!session) { - WLOGFE("session is null"); - return WSError::WS_ERROR_DESTROYED_OBJECT; + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); + return; + } + if (session->reason_ == SizeChangeReason::DRAG) { + TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip drag reason update id:%{public}d rect:%{public}s", + funcName, session->GetPersistentId(), rect.ToString().c_str()); + return; } if (session->winRect_ == rect && session->reason_ != SizeChangeReason::DRAG_END && (session->GetWindowType() != WindowType::WINDOW_TYPE_KEYBOARD_PANEL && session->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)) { if (!session->sessionStage_) { - TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s", - session->GetPersistentId(), rect.ToString().c_str()); - return WSError::WS_OK; + TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip same rect update id:%{public}d rect:%{public}s", + funcName, session->GetPersistentId(), rect.ToString().c_str()); + return; } else if (session->GetClientRect() == rect) { - TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s " - "clientRect:%{public}s", session->GetPersistentId(), rect.ToString().c_str(), + TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: skip same rect update id:%{public}d rect:%{public}s " + "clientRect:%{public}s", funcName, session->GetPersistentId(), rect.ToString().c_str(), session->GetClientRect().ToString().c_str()); - return WSError::WS_OK; + return; } } if (rect.IsInvalid()) { - TLOGE(WmsLogTag::WMS_LAYOUT, "id:%{public}d rect:%{public}s is invalid", - session->GetPersistentId(), rect.ToString().c_str()); - return WSError::WS_ERROR_INVALID_PARAM; + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d rect:%{public}s is invalid", + funcName, session->GetPersistentId(), rect.ToString().c_str()); + return; } - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, - "SceneSession::UpdateRect%d [%d, %d, %u, %u]", + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::UpdateRect%d [%d, %d, %u, %u]", session->GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_); // position change no need to notify client, since frame layout finish will notify if (NearEqual(rect.width_, session->winRect_.width_) && NearEqual(rect.height_, session->winRect_.height_) && (session->reason_ != SizeChangeReason::MOVE || !session->rectChangeListenerRegistered_)) { - TLOGI(WmsLogTag::WMS_LAYOUT, "position change no need notify client id:%{public}d, rect:%{public}s, " - "preRect: %{public}s", + TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: position change no need notify client id:%{public}d, " + "rect:%{public}s, preRect: %{public}s", funcName, session->GetPersistentId(), rect.ToString().c_str(), session->winRect_.ToString().c_str()); session->winRect_ = rect; } else { @@ -1046,13 +1051,12 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, session->NotifyClientToUpdateRect(updateReason, rsTransaction); } session->dirtyFlags_ |= static_cast(SessionUIDirtyFlag::RECT); - TLOGI(WmsLogTag::WMS_LAYOUT, "UpdateRect id:%{public}d, reason:%{public}d %{public}s, rect:%{public}s, " - "clientRect:%{public}s", session->GetPersistentId(), session->reason_, updateReason.c_str(), + TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d, reason:%{public}d %{public}s, " + "rect:%{public}s, clientRect:%{public}s", + funcName, session->GetPersistentId(), session->reason_, updateReason.c_str(), rect.ToString().c_str(), session->GetClientRect().ToString().c_str()); - - return WSError::WS_OK; }; - PostTask(task, "UpdateRect" + GetRectInfo(rect)); + PostTask(task, funcName + GetRectInfo(rect)); return WSError::WS_OK; } @@ -1454,22 +1458,21 @@ WSError SceneSession::UpdateClientRect(const WSRect& rect) auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); - return WSError::WS_ERROR_DESTROYED_OBJECT; + return; } if (rect.IsInvalid()) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d rect:%{public}s is invalid", funcName, session->GetPersistentId(), rect.ToString().c_str()); - return WSError::WS_ERROR_INVALID_PARAM; + return; } if (rect == session->GetClientRect()) { TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s: id:%{public}d skip same rect", funcName, session->GetPersistentId()); - return WSError::WS_DO_NOTHING; + return; } session->SetClientRect(rect); - return WSError::WS_OK; }; - PostTask(task, "UpdateClientRect" + GetRectInfo(rect)); + PostTask(task, funcName + GetRectInfo(rect)); return WSError::WS_OK; } @@ -2660,21 +2663,25 @@ void SceneSession::HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, if (reason != SizeChangeReason::MOVE) { UpdateRectForDrag(rect); std::shared_ptr nextVsyncDragCallback = std::make_shared(); - nextVsyncDragCallback ->onCallback = [weakThis = wptr(this), funcName = __func__](int64_t, int64_t) { + nextVsyncDragCallback->onCallback = [weakThis = wptr(this), funcName = __func__](int64_t, int64_t) { auto session = weakThis.promote(); if (!session) { - TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s, session is null", funcName); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); return; } - session->OnNextVsyncDragReceived(); + session->OnNextVsyncReceivedWhenDrag(); }; - requestNextVsyncFunc_(nextVsyncDragCallback); + if (requestNextVsyncFunc_) { + requestNextVsyncFunc_(nextVsyncDragCallback); + } else { + TLOGE(WmsLogTag::WMS_LAYOUT, "Func is null, could not request vsync"); + } } } -void SceneSession::OnNextVsyncDragReceived() +void SceneSession::OnNextVsyncReceivedWhenDrag() { - PostTask([weakThis = wptr(this)]() { + PostTask([weakThis = wptr(this)] { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); @@ -2839,10 +2846,20 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) } } -void SceneSession::UpdateRectForDrag(WSRect& rect) +WSError SceneSession::UpdateRectForDrag(const WSRect& rect) { - winRect_ = rect; - dirtyFlags_ |= static_cast(SessionUIDirtyFlag::DRAG_RECT); + const char* const funcName = __func__; + auto task = [weakThis = wptr(this), rect, funcName] { + auto sceneSession = weakThis.promote(); + if (!sceneSession) { + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + sceneSession->winRect_ = rect; + sceneSession->dirtyFlags_ |= static_cast(SessionUIDirtyFlag::DRAG_RECT); + return WSError::WS_OK; + }; + return PostSyncTask(task, funcName); } void SceneSession::UpdateWinRectForSystemBar(WSRect& rect) diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 988fc57996..bcfa2b6a4d 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -847,7 +847,7 @@ WMError SessionProxy::GetGlobalScaledRect(Rect& globalScaledRect) /** @note @window.layout */ WSError SessionProxy::UpdateClientRect(const WSRect& rect) { - TLOGI(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}u, %{public}u]", + TLOGD(WmsLogTag::WMS_LAYOUT, "rect:[%{public}d, %{public}d, %{public}d, %{public}d]", rect.posX_, rect.posY_, rect.width_, rect.height_); MessageParcel data; MessageParcel reply; @@ -856,10 +856,10 @@ WSError SessionProxy::UpdateClientRect(const WSRect& rect) TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } - if (!((data.WriteInt32(static_cast(rect.posX_))) && - (data.WriteInt32(static_cast(rect.posY_))) && - (data.WriteUint32(static_cast(rect.width_))) && - (data.WriteUint32(static_cast(rect.height_))))) { + if (!data.WriteInt32(rect.posX_) || + !data.WriteInt32(rect.posY_) || + !data.WriteInt32(rect.width_) || + !data.WriteInt32(rect.height_)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Write rect failed"); return WSError::WS_ERROR_IPC_FAILED; } diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 63315d18d9..cd44ec51ea 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -735,15 +735,15 @@ int SessionStub::HandleUpdateClientRect(MessageParcel& data, MessageParcel& repl TLOGD(WmsLogTag::WMS_LAYOUT, "In"); int32_t posX = 0; int32_t posY = 0; - uint32_t width = 0; - uint32_t height = 0; - if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadUint32(width) || !data.ReadUint32(height)) { + int32_t width = 0; + int32_t height = 0; + if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadInt32(width) || !data.ReadInt32(height)) { TLOGE(WmsLogTag::WMS_LAYOUT, "read rect failed"); return ERR_INVALID_DATA; } WSRect rect = { posX, posY, width, height }; WSError errCode = UpdateClientRect(rect); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f8f55d58e1..d0bad78735 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -515,8 +515,6 @@ public: WMError GetDisplayIdByWindowId(const std::vector& windowIds, std::unordered_map& windowDisplayIdMap) override; - std::shared_ptr vsyncCallback_ = nullptr; - /* * Specific Window */ @@ -557,9 +555,6 @@ private: void ConfigSnapshotScale(); void ConfigFreeMultiWindow(); void LoadFreeMultiWindowConfig(bool enable); - void RegisterRequestVsyncFunc(const sptr& sceneSession); - std::shared_ptr vsyncStation_ = nullptr; - void InitVsyncStation(); std::tuple> CreateCurve(const WindowSceneConfig::ConfigItem& curveConfig); void LoadKeyboardAnimation(const WindowSceneConfig::ConfigItem& item, KeyboardSceneAnimationConfig& config); @@ -1000,6 +995,14 @@ private: void RemoveProcessWatermarkPid(int32_t pid); /** + * Window Layout + */ + std::shared_ptr vsyncCallback_ = nullptr; + std::shared_ptr vsyncStation_ = nullptr; + void InitVsyncStation(); + void RegisterRequestVsyncFunc(const sptr& sceneSession); + + /* * Window Snapshot */ std::unordered_set snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 29c3ab884d..60ae4e9d01 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4351,11 +4351,10 @@ void SceneSessionManager::RegisterRequestVsyncFunc(const sptr& sce TLOGE(WmsLogTag::DEFAULT, "session is nullptr"); return; } - RequestVsyncFunc requestVsyncFunc = [this](std::shared_ptr callback) { + sceneSession->SetRequestNextVsyncFunc([this](const std::shared_ptr& callback) { vsyncStation_->RequestVsync(callback); - }; - sceneSession->SetRequestNextVsyncFunc(requestVsyncFunc); -}; + }); +} void SceneSessionManager::RegisterAcquireRotateAnimationConfigFunc(const sptr& sceneSession) { diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 45aece8ee8..31e8cb883b 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -813,9 +813,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2) info.bundleName_ = "OnMoveDragCallback"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); - EXPECT_NE(session, nullptr); - RequestVsyncFunc requestVsyncFunc = [](std::shared_ptr& callback){}; - session->SetRequestNextVsyncFunc(requestVsyncFunc); + session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback){}); EXPECT_NE(nullptr, session->requestNextVsyncFunc_); session->moveDragController_ = nullptr; SizeChangeReason reason = { SizeChangeReason::DRAG }; @@ -1663,18 +1661,15 @@ HWTEST_F(SceneSessionTest5, SetRequestNextVsyncFunc01, Function | SmallTest | Le info.abilityName_ = "test1"; info.bundleName_ = "test1"; sptr session = sptr::MakeSptr(info, nullptr); - EXPECT_NE(session, nullptr); - RequestVsyncFunc requestVsyncFunc; - session->SetRequestNextVsyncFunc(requestVsyncFunc); + session->SetRequestNextVsyncFunc(nullptr); ASSERT_EQ(nullptr, session->requestNextVsyncFunc_); - RequestVsyncFunc requestVsyncFunc1 = [](std::shared_ptr& callback) { + session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback) { SessionInfo info1; info1.abilityName_ = "test2"; info1.bundleName_ = "test2"; - }; - session->SetRequestNextVsyncFunc(requestVsyncFunc1); + }); ASSERT_NE(nullptr, session->requestNextVsyncFunc_); } diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 7702a78f58..fce754322b 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -859,8 +859,8 @@ HWTEST_F(SessionStubTest, HandleUpdateClientRect01, Function | SmallTest | Level data.WriteInt32(100); data.WriteInt32(100); - data.WriteUint32(800); - data.WriteUint32(800); + data.WriteInt32(800); + data.WriteInt32(800); res = session_->HandleUpdateClientRect(data, reply); ASSERT_EQ(ERR_NONE, res); } diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 501df57319..b89a5e5abf 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -388,7 +388,6 @@ protected: bool useUniqueDensity_ { false }; float virtualPixelRatio_ { 1.0f }; bool escKeyEventTriggered_ = false; - std::atomic_bool isDragTaskUpdateDone_ = true; // Check whether the UIExtensionAbility process is started static bool isUIExtensionAbilityProcess_; virtual WMError SetKeyEventFilter(KeyEventFilterFunc filter) override; @@ -421,6 +420,7 @@ protected: /** * Window Layout */ + std::atomic_bool isDragTaskUpdateDone_ = true; void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; void UpdateVirtualPixelRatio(const sptr& display); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index f2cece0174..c0b32217e1 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1065,8 +1065,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptrGetWindowName().c_str(), GetPersistentId(), type, requestRect.ToString().c_str()); if (requestRect.width_ != 0 && requestRect.height_ != 0) { UpdateViewportConfig(requestRect, WindowSizeChangeReason::RESIZE, nullptr, info); - auto hostSession = GetHostSession(); - if (hostSession) { + if (auto hostSession = GetHostSession()) { WSRect wsRect = { requestRect.posX_, requestRect.posY_, requestRect.width_, requestRect.height_ }; property_->SetWindowRect(requestRect); hostSession->UpdateClientRect(wsRect); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 5302cbb8b1..643ad1f82b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -811,7 +811,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } if (wmReason == WindowSizeChangeReason::DRAG) { window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction); - window->isDragTaskUpdateDone_ = true; + window->isDragTaskUpdateDone_.store(true); } else { window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); } @@ -820,9 +820,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } }; if (wmReason == WindowSizeChangeReason::DRAG) { - if (isDragTaskUpdateDone_) { + if (isDragTaskUpdateDone_.load()) { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); - isDragTaskUpdateDone_ = false; + isDragTaskUpdateDone_.store(false); } } else { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); From a58a1767fd5015361cf6290af2670cc2c6c8dd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Thu, 21 Nov 2024 12:02:17 +0800 Subject: [PATCH 2/4] fix comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- .../wms/window_layout_integration_test.cpp | 14 ++++---- .../session/host/include/scene_session.h | 6 ++-- window_scene/session/host/include/session.h | 6 ++-- .../session/host/src/scene_session.cpp | 26 +++++++------- .../test/unittest/scene_session_test.cpp | 8 ++--- .../test/unittest/scene_session_test2.cpp | 4 +-- .../test/unittest/scene_session_test5.cpp | 36 +++++++++---------- wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 6 ++-- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/test/systemtest/wms/window_layout_integration_test.cpp b/test/systemtest/wms/window_layout_integration_test.cpp index ef9c91eff0..1bd59443cd 100644 --- a/test/systemtest/wms/window_layout_integration_test.cpp +++ b/test/systemtest/wms/window_layout_integration_test.cpp @@ -727,15 +727,15 @@ HWTEST_F(WindowLayoutTest, ResizeDataRoute, Function | MediumTest | Level3) } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: test FixRectByAspectRatio + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: test AdjustRectByAspectRatio * @tc.type: FUNC */ -HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0) +HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, Function | MediumTest | Level0) { - TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio begin ###"); + TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio begin ###"); sptr option = sptr::MakeSptr(); - option->SetWindowName("FixRectByAspectRatio"); + option->SetWindowName("AdjustRectByAspectRatio"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sptr windowSceneSessionImpl = sptr::MakeSptr(option); @@ -775,12 +775,12 @@ HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0) WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false); EXPECT_EQ(WSError::WS_OK, wsRet2); usleep(WAIT_SERVERAL_FRAMES); - WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "FixRectByAspectRatio", nullptr); + WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "AdjustRectByAspectRatio", nullptr); EXPECT_EQ(WSError::WS_OK, wsRet3); usleep(WAIT_SERVERAL_FRAMES); WSError wsRet4 = session->SetAspectRatio(ratio); EXPECT_EQ(WSError::WS_OK, wsRet4); - TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio end ###"); + TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###"); } } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 24b8acf4ee..8c216f350d 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -532,7 +532,7 @@ public: bool IsDirtyWindow(); bool IsDirtyDragWindow(); void ResetSizeChangeReasonIfDirty(); - void SetRequestNextVsyncFunc(const RequestVsyncFunc&& func); + void SetRequestNextVsyncFunc(RequestVsyncFunc&& func); void OnNextVsyncReceivedWhenDrag(); void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback); bool SetFrameGravity(Gravity gravity); @@ -792,8 +792,8 @@ private: /** * Window Layout */ - void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); - bool FixRectByAspectRatio(WSRect& rect); + void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect); + bool AdjustRectByAspectRatio(WSRect& rect); bool SaveAspectRatio(float ratio); void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason); WSError UpdateRectForDrag(const WSRect& rect); diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 6dc5d0cf2c..523e0d7ee6 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -671,10 +671,10 @@ protected: */ RequestVsyncFunc requestNextVsyncFunc_; WSRect winRect_; - WSRect clientRect_; // rect saved when prelayout or notify client to update rect + WSRect clientRect_; // rect saved when prelayout or notify client to update rect WSRect lastLayoutRect_; // rect saved when go background - WSRect layoutRect_; // rect of root view - WSRect globalRect_; // globalRect include translate + WSRect layoutRect_; // rect of root view + WSRect globalRect_; // globalRect include translate SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; NotifySessionRectChangeFunc sessionRectChangeFunc_; float clientScaleX_ = 1.0f; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index fdca5b12b0..df318a2360 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -338,7 +338,7 @@ WSError SceneSession::Foreground( return ForegroundTask(property); } -void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc&& func) +void SceneSession::SetRequestNextVsyncFunc(RequestVsyncFunc&& func) { if (func == nullptr) { TLOGI(WmsLogTag::DEFAULT, "func is nullptr"); @@ -964,7 +964,7 @@ static WSError CheckAspectRatioValid(const sptr& session, float ra /** @note @window.layout */ WSError SceneSession::SetAspectRatio(float ratio) { - auto task = [weakThis = wptr(this), ratio]() { + auto task = [weakThis = wptr(this), ratio] { auto session = weakThis.promote(); if (!session) { TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); @@ -989,13 +989,13 @@ WSError SceneSession::SetAspectRatio(float ratio) session->moveDragController_->SetAspectRatio(ratio); } session->SaveAspectRatio(session->aspectRatio_); - WSRect fixedRect = session->winRect_; - TLOGI(WmsLogTag::WMS_LAYOUT, "Before fixing, the id:%{public}d, the current rect: %{public}s, " - "ratio: %{public}f", session->GetPersistentId(), fixedRect.ToString().c_str(), ratio); - if (session->FixRectByAspectRatio(fixedRect)) { - TLOGI(WmsLogTag::WMS_LAYOUT, "After fixing, the id:%{public}d, the fixed rect: %{public}s", - session->GetPersistentId(), fixedRect.ToString().c_str()); - session->NotifySessionRectChange(fixedRect, SizeChangeReason::RESIZE); + WSRect adjustedRect = session->winRect_; + TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect: %{public}s, " + "ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio); + if (session->AdjustRectByAspectRatio(adjustedRect)) { + TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect: %{public}s", + session->GetPersistentId(), adjustedRect.ToString().c_str()); + session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE); } return WSError::WS_OK; }; @@ -1007,7 +1007,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::string& updateReason, const std::shared_ptr& rsTransaction) { const char* const funcName = __func__; - auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName]() { + auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName] { auto session = weakThis.promote(); if (!session) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); @@ -2466,7 +2466,7 @@ bool SceneSession::SaveAspectRatio(float ratio) return false; } -void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr) +void SceneSession::AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect) { if (isDecor) { rect.width_ = SessionUtils::ToLayoutWidth(rect.width_, vpr); @@ -2494,7 +2494,7 @@ void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float rati rect.width_ = SessionUtils::ToWinWidth(rect.width_, vpr); } } -bool SceneSession::FixRectByAspectRatio(WSRect& rect) +bool SceneSession::AdjustRectByAspectRatio(WSRect& rect) { const int tolerancePx = 2; // 2: tolerance delta pixel value, unit: px WSRect originalRect = rect; @@ -2536,7 +2536,7 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect) rect.height_ = rect.width_ / aspectRatio_; } } - FixRectByLimits(property->GetWindowLimits(), rect, aspectRatio_, IsDecorEnable(), vpr); + AdjustRectByLimits(property->GetWindowLimits(), aspectRatio_, IsDecorEnable(), vpr, rect); if (std::abs(static_cast(originalRect.width_) - static_cast(rect.width_)) <= tolerancePx && std::abs(static_cast(originalRect.height_) - static_cast(rect.height_)) <= tolerancePx) { rect = originalRect; diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 2cb826a5f7..4a068fc008 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -886,11 +886,11 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: FixRectByAspectRatio + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: AdjustRectByAspectRatio * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest, AdjustRectByAspectRatio, Function | SmallTest | Level2) { SessionInfo info; info.abilityName_ = "Background01"; @@ -904,7 +904,7 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); WSRect originalRect_ = { 0, 0, 0, 0 }; - ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_)); + ASSERT_EQ(false, sceneSession->AdjustRectByAspectRatio(originalRect_)); } /** diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 9e3570f82f..52c52673da 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1648,7 +1648,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level float ratio = 0.0; bool isDecor = true; float vpr = 0.0; - sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr); + sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect); sceneSession->SetPipActionEvent("pointerEvent", 0); auto property = sptr::MakeSptr(); @@ -1660,7 +1660,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level sceneSession->sessionStage_ = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_PIP); property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - sceneSession->FixRectByLimits(limits, rect, ratio, false, vpr); + sceneSession->AdjustRectByLimits(limits, ratio, false, vpr, rect); ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0)); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 31e8cb883b..489cbacd63 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -742,42 +742,42 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2) } /** - * @tc.name: FixRectByAspectRatio - * @tc.desc: FixRectByAspectRatio function01 + * @tc.name: AdjustRectByAspectRatio + * @tc.desc: AdjustRectByAspectRatio function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, FixRectByAspectRatio, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "FixRectByAspectRatio"; - info.bundleName_ = "FixRectByAspectRatio"; + info.abilityName_ = "AdjustRectByAspectRatio"; + info.bundleName_ = "AdjustRectByAspectRatio"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); sptr property = sptr::MakeSptr(); session->SetSessionProperty(nullptr); WSRect rect; - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); session->SetSessionProperty(property); property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetWindowType(WindowType::APP_MAIN_WINDOW_END); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect)); } /** - * @tc.name: FixRectByAspectRatio01 - * @tc.desc: FixRectByAspectRatio function01 + * @tc.name: AdjustRectByAspectRatio01 + * @tc.desc: AdjustRectByAspectRatio function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "FixRectByAspectRatio01"; - info.bundleName_ = "FixRectByAspectRatio01"; + info.abilityName_ = "AdjustRectByAspectRatio01"; + info.bundleName_ = "AdjustRectByAspectRatio01"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); @@ -791,14 +791,14 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level systemConfig.isSystemDecorEnable_ = true; systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); - EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect)); systemConfig.isSystemDecorEnable_ = false; - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); systemConfig.isSystemDecorEnable_ = true; session->SetSessionProperty(nullptr); - EXPECT_EQ(false, session->FixRectByAspectRatio(rect)); + EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect)); } /** @@ -813,7 +813,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2) info.bundleName_ = "OnMoveDragCallback"; info.isSystem_ = false; sptr session = sptr::MakeSptr(info, nullptr); - session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback){}); + session->SetRequestNextVsyncFunc([](const std::shared_ptr& callback) {}); EXPECT_NE(nullptr, session->requestNextVsyncFunc_); session->moveDragController_ = nullptr; SizeChangeReason reason = { SizeChangeReason::DRAG }; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index b89a5e5abf..78e6c49b2a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -420,7 +420,7 @@ protected: /** * Window Layout */ - std::atomic_bool isDragTaskUpdateDone_ = true; + std::atomic_bool isDragTaskPostDone_ = true; void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; void UpdateVirtualPixelRatio(const sptr& display); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 643ad1f82b..e3ab0a378e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -811,7 +811,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } if (wmReason == WindowSizeChangeReason::DRAG) { window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction); - window->isDragTaskUpdateDone_.store(true); + window->isDragTaskPostDone_.store(true); } else { window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); } @@ -820,9 +820,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& } }; if (wmReason == WindowSizeChangeReason::DRAG) { - if (isDragTaskUpdateDone_.load()) { + bool isDragTaskPostDone = true; + if (isDragTaskPostDone_.compare_exchange_strong(isDragTaskPostDone, false)) { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); - isDragTaskUpdateDone_.store(false); } } else { handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason"); From 705332d4cbc0736c0bb1735d014627a9f04fc023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Thu, 21 Nov 2024 16:50:47 +0800 Subject: [PATCH 3/4] fix comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- window_scene/session/host/src/scene_session.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index df318a2360..a325cba17f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -990,10 +990,10 @@ WSError SceneSession::SetAspectRatio(float ratio) } session->SaveAspectRatio(session->aspectRatio_); WSRect adjustedRect = session->winRect_; - TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect: %{public}s, " + TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect:%{public}s, " "ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio); if (session->AdjustRectByAspectRatio(adjustedRect)) { - TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect: %{public}s", + TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect:%{public}s", session->GetPersistentId(), adjustedRect.ToString().c_str()); session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE); } @@ -1037,13 +1037,13 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, funcName, session->GetPersistentId(), rect.ToString().c_str()); return; } - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::UpdateRect%d [%d, %d, %u, %u]", + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::UpdateRect %d [%d, %d, %u, %u]", session->GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_); // position change no need to notify client, since frame layout finish will notify if (NearEqual(rect.width_, session->winRect_.width_) && NearEqual(rect.height_, session->winRect_.height_) && (session->reason_ != SizeChangeReason::MOVE || !session->rectChangeListenerRegistered_)) { TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s: position change no need notify client id:%{public}d, " - "rect:%{public}s, preRect: %{public}s", funcName, + "rect:%{public}s, preRect:%{public}s", funcName, session->GetPersistentId(), rect.ToString().c_str(), session->winRect_.ToString().c_str()); session->winRect_ = rect; } else { @@ -2849,7 +2849,7 @@ void SceneSession::HandleMoveDragSurfaceNode(SizeChangeReason reason) WSError SceneSession::UpdateRectForDrag(const WSRect& rect) { const char* const funcName = __func__; - auto task = [weakThis = wptr(this), rect, funcName] { + return PostSyncTask([weakThis = wptr(this), rect, funcName] { auto sceneSession = weakThis.promote(); if (!sceneSession) { TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName); @@ -2858,8 +2858,7 @@ WSError SceneSession::UpdateRectForDrag(const WSRect& rect) sceneSession->winRect_ = rect; sceneSession->dirtyFlags_ |= static_cast(SessionUIDirtyFlag::DRAG_RECT); return WSError::WS_OK; - }; - return PostSyncTask(task, funcName); + }, funcName); } void SceneSession::UpdateWinRectForSystemBar(WSRect& rect) From 7a56818662b15cede0ddd33f4124be0f53517032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=92=B0=E8=83=9C?= Date: Thu, 21 Nov 2024 18:06:52 +0800 Subject: [PATCH 4/4] fix comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 白钰胜 --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index a325cba17f..bd4406d604 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -991,7 +991,7 @@ WSError SceneSession::SetAspectRatio(float ratio) session->SaveAspectRatio(session->aspectRatio_); WSRect adjustedRect = session->winRect_; TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect:%{public}s, " - "ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio); + "ratio:%{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio); if (session->AdjustRectByAspectRatio(adjustedRect)) { TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect:%{public}s", session->GetPersistentId(), adjustedRect.ToString().c_str());