From 74025826b473f4388ad54342d818c728329a51b7 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Tue, 17 Jul 2018 23:59:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=AB=98DPI=E4=B8=8B?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=B8=8D=E6=AD=A3=E5=B8=B8=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Base/Input.cpp | 7 ++++++- core/Base/Window.cpp | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/Base/Input.cpp b/core/Base/Input.cpp index f8b20b3e..435bad33 100644 --- a/core/Base/Input.cpp +++ b/core/Base/Input.cpp @@ -199,7 +199,12 @@ e2d::Point e2d::Input::getMousePos() POINT mousePos; GetCursorPos(&mousePos); ScreenToClient(Window::getInstance()->getHWnd(), &mousePos); - return Point((double)mousePos.x, (double)mousePos.y); + + float dpiScaleX = 0.f, dpiScaleY = 0.f; + Renderer::getFactory()->GetDesktopDpi(&dpiScaleX, &dpiScaleY); + + return Point(static_cast(mousePos.x * 96.f / dpiScaleX), + static_cast(mousePos.y * 96.f / dpiScaleX)); } double e2d::Input::getMouseDeltaX() diff --git a/core/Base/Window.cpp b/core/Base/Window.cpp index 1ff12099..56f61ac5 100644 --- a/core/Base/Window.cpp +++ b/core/Base/Window.cpp @@ -426,7 +426,9 @@ LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar if (wParam == SIZE_RESTORED) { - _instance->_size = Size(width, height); + float dpiScaleX = 0.f, dpiScaleY = 0.f; + Renderer::getFactory()->GetDesktopDpi(&dpiScaleX, &dpiScaleY); + _instance->_size = Size(width * 96.f / dpiScaleX, height * 96.f / dpiScaleY); } // 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染