From ba58d2a611fc8e9a19056c1c99eb905cc226a605 Mon Sep 17 00:00:00 2001 From: jiangwenyu1 Date: Tue, 5 Sep 2023 16:15:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AA=97=E5=8F=A3=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E5=87=BA=E7=8E=B0=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_manager/wm/include/window_impl.h | 1 + window_manager/wm/src/window_impl.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/window_manager/wm/include/window_impl.h b/window_manager/wm/include/window_impl.h index 6f1f55f..a1dc981 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 ead4293..30e134f 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 -- Gitee