diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 16a6b36097043d9b1bac3b60f562c063867f314b..345b1090234bc9908529c12b9145a0198b982862 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -450,7 +450,6 @@ private: * Window Property */ void InitSystemSessionDragEnable(); - bool IsSystemDensityChanged(const sptr& displayInfo); bool IsDefaultDensityEnabled(); float GetMainWindowCustomDensity(); float customDensity_ = UNDEFINED_DENSITY; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6f578ce4f9a967fc52e116baa234e2c7ec7a200e..ddbf30830a42381fa8cf3225ef25fa1ed86f269a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -1095,6 +1095,11 @@ private: HookWindowInfo hookWindowInfo_; std::atomic_bool notifySizeChangeFlag_ = false; + /* + * Window Property + */ + bool IsSystemDensityChanged(const sptr& displayInfo); + /* * Window Decor */ diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 64154ed9f74ddd699dd01e47d572a254715663d5..8578003e8c2828f2c7a3613d2a4be8edf48116ec 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -6140,10 +6140,6 @@ void WindowSceneSessionImpl::NotifyDisplayInfoChange(const sptr& in TLOGE(WmsLogTag::DMS, "get display info %{public}" PRIu64 " failed.", displayId); return; } - if (IsSystemDensityChanged(displayInfo)) { - lastSystemDensity_ = displayInfo->GetVirtualPixelRatio(); - NotifySystemDensityChange(displayInfo->GetVirtualPixelRatio()); - } float density = GetVirtualPixelRatio(displayInfo); DisplayOrientation orientation = displayInfo->GetDisplayOrientation(); @@ -6563,17 +6559,6 @@ WMError WindowSceneSessionImpl::OnContainerModalEvent(const std::string& eventNa return WMError::WM_DO_NOTHING; } -bool WindowSceneSessionImpl::IsSystemDensityChanged(const sptr& displayInfo) -{ - if (MathHelper::NearZero(lastSystemDensity_ - displayInfo->GetVirtualPixelRatio())) { - TLOGD(WmsLogTag::WMS_ATTRIBUTE, "System density not change"); - return false; - } - TLOGI(WmsLogTag::WMS_ATTRIBUTE, "windowId: %{public}d, lastDensity: %{public}f, currDensity: %{public}f", - GetPersistentId(), lastSystemDensity_, displayInfo->GetVirtualPixelRatio()); - return true; -} - bool WindowSceneSessionImpl::IsDefaultDensityEnabled() { if (WindowHelper::IsMainWindow(GetType())) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index f40c22ad7528eb7ee0581211e78782b5be7ab893..c9018a091d6e0466f175f2783ff2ee699bffd87d 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1775,6 +1775,10 @@ void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeR UpdateCurrentWindowOrientation(displayInfo->GetDisplayOrientation()); int32_t orientation = static_cast(displayInfo->GetDisplayOrientation()); virtualPixelRatio_ = density; + if (IsSystemDensityChanged(displayInfo)) { + lastSystemDensity_ = displayInfo->GetVirtualPixelRatio(); + NotifySystemDensityChange(displayInfo->GetVirtualPixelRatio()); + } auto config = FillViewportConfig(rect, density, orientation, transformHint, GetDisplayId()); if (reason == WindowSizeChangeReason::DRAG_END && keyFramePolicy_.stopping_) { TLOGI(WmsLogTag::WMS_LAYOUT, "key frame stop"); @@ -1811,6 +1815,17 @@ void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeR } } +bool WindowSessionImpl::IsSystemDensityChanged(const sptr& displayInfo) +{ + if (MathHelper::NearZero(lastSystemDensity_ - displayInfo->GetVirtualPixelRatio())) { + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "System density not change"); + return false; + } + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "windowId: %{public}d, lastDensity: %{public}f, currDensity: %{public}f", + GetPersistentId(), lastSystemDensity_, displayInfo->GetVirtualPixelRatio()); + return true; +} + int32_t WindowSessionImpl::GetFloatingWindowParentId() { auto context = GetContext();