From e75eec3db87cc7a2628f54bd1ac1c6a99ae7ea72 Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Sun, 23 Apr 2023 03:43:18 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!2430=20?= =?UTF-8?q?:=20mmi=5FmouseImage=5Ferr'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/pointer_drawing_manager.h | 4 +-- .../src/pointer_drawing_manager.cpp | 28 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/service/window_manager/include/pointer_drawing_manager.h b/service/window_manager/include/pointer_drawing_manager.h index 4789a68a0e..2a271980db 100644 --- a/service/window_manager/include/pointer_drawing_manager.h +++ b/service/window_manager/include/pointer_drawing_manager.h @@ -37,8 +37,8 @@ class PointerDrawingManager final : public IPointerDrawingManager, public IDeviceObserver, public std::enable_shared_from_this { public: - int32_t IMAGE_WIDTH = 64; - int32_t IMAGE_HEIGHT = 64; + static const int32_t IMAGE_WIDTH = 64; + static const int32_t IMAGE_HEIGHT = 64; public: PointerDrawingManager(); diff --git a/service/window_manager/src/pointer_drawing_manager.cpp b/service/window_manager/src/pointer_drawing_manager.cpp index c6a56ac301..290faebe52 100644 --- a/service/window_manager/src/pointer_drawing_manager.cpp +++ b/service/window_manager/src/pointer_drawing_manager.cpp @@ -32,9 +32,14 @@ namespace MMI { namespace { constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "PointerDrawingManager" }; const std::string IMAGE_POINTER_DEFAULT_PATH = "/system/etc/multimodalinput/mouse_icon/"; -constexpr int32_t BASELINE_DENSITY = 160; -constexpr int32_t DEVICE_INDEPENDENT_PIXELS = 40; -constexpr int32_t POINTER_WINDOW_INIT_SIZE = 64; +constexpr int32_t PAD_SCREEN_WIDTH = 2560; +constexpr int32_t PHONE_SCREEN_WIDTH = 2160; +constexpr int32_t SMALL_ICON_WIDTH = 40; +constexpr int32_t SMALL_ICON_HEIGHT = 40; +constexpr int32_t MIDDLE_ICON_WIDTH = 60; +constexpr int32_t MIDDLE_ICON_HEIGHT = 60; +constexpr int32_t LARGE_ICON_WIDTH = 80; +constexpr int32_t LARGE_ICON_HEIGHT = 80; } // namespace } // namespace MMI } // namespace OHOS @@ -316,10 +321,19 @@ void PointerDrawingManager::UpdateDisplayInfo(const DisplayInfo& displayInfo) CALL_DEBUG_ENTER; hasDisplay_ = true; displayInfo_ = displayInfo; - imageWidth_ = displayInfo.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY; - imageHeight_ = displayInfo.dpi * DEVICE_INDEPENDENT_PIXELS / BASELINE_DENSITY; - IMAGE_WIDTH = (imageWidth_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE; - IMAGE_WIDTH = (imageHeight_ / POINTER_WINDOW_INIT_SIZE + 1) * POINTER_WINDOW_INIT_SIZE; + + if ((displayInfo_.width >= PHONE_SCREEN_WIDTH) || (displayInfo_.height >= PHONE_SCREEN_WIDTH)) { + if ((displayInfo_.width == PAD_SCREEN_WIDTH) || (displayInfo_.height == PAD_SCREEN_WIDTH)) { + imageWidth_ = MIDDLE_ICON_WIDTH; + imageHeight_ = MIDDLE_ICON_HEIGHT; + } else { + imageWidth_ = LARGE_ICON_WIDTH; + imageHeight_ = LARGE_ICON_HEIGHT; + } + } else { + imageWidth_ = SMALL_ICON_WIDTH; + imageHeight_ = SMALL_ICON_HEIGHT; + } } void PointerDrawingManager::OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo) -- Gitee