diff --git a/window_manager/wm/include/window_impl.h b/window_manager/wm/include/window_impl.h index 6f1f55f9242cb1d39199f6d258c6f725073c009f..a1dc98126ce1235f03f8d8318802e08fabb4d0cd 100644 --- a/window_manager/wm/include/window_impl.h +++ b/window_manager/wm/include/window_impl.h @@ -579,6 +579,7 @@ private: {DragType::DRAG_LEFT_TOP_CORNER, MMI::MOUSE_ICON::NORTH_WEST_SOUTH_EAST}, {DragType::DRAG_RIGHT_TOP_CORNER, MMI::MOUSE_ICON::NORTH_EAST_SOUTH_WEST} }; + float virtualPixelRatio_ = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/window_manager/wm/src/window_impl.cpp b/window_manager/wm/src/window_impl.cpp index ead42939efb71b181bbd30e41aaaa01b7551b460..30e134f822330b3d752945dc9ef7c681e7dbea09 100755 --- a/window_manager/wm/src/window_impl.cpp +++ b/window_manager/wm/src/window_impl.cpp @@ -2463,15 +2463,22 @@ void WindowImpl::HandlePointerStyle(const std::shared_ptr& po } auto action = pointerEvent->GetPointerAction(); if (WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) { - auto display = SingletonContainer::IsDestroyed() ? nullptr : - SingletonContainer::Get().GetDisplayById(moveDragProperty_->targetDisplayId_); - if (display == nullptr || display->GetDisplayInfo() == nullptr) { - WLOGFE("get display failed displayId:%{public}" PRIu64", window id:%{public}u", - property_->GetDisplayId(), property_->GetWindowId()); - return; + /* To optimize performance, we only get virtualPixelRatio once. + * TODO: If there is a change in virtualPixelRatio, the DMS will report the virtualPixelRatio change event, + * at this time, it is necessary to get the virtualPixelRatio again + */ + if (virtualPixelRatio_ == 0) { + auto display = SingletonContainer::IsDestroyed() ? nullptr : + SingletonContainer::Get().GetDisplayById(moveDragProperty_->targetDisplayId_); + if (display == nullptr || display->GetDisplayInfo() == nullptr) { + WLOGFE("get display failed displayId:%{public}" PRIu64", window id:%{public}u", + property_->GetDisplayId(), property_->GetWindowId()); + return; + } + virtualPixelRatio_ = display->GetVirtualPixelRatio(); } - float vpr = display->GetVirtualPixelRatio(); - CalculateStartRectExceptHotZone(vpr); + CalculateStartRectExceptHotZone(virtualPixelRatio_); + if (IsPointInDragHotZone(pointerItem.GetDisplayX(), pointerItem.GetDisplayY())) { uint32_t tempStyleID = mouseStyleID_; // calculate pointer style