修复高DPI下工作不正常的BUG

This commit is contained in:
Nomango 2018-07-17 23:59:21 +08:00
parent 6bb7d35497
commit 74025826b4
2 changed files with 9 additions and 2 deletions

View File

@ -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<double>(mousePos.x * 96.f / dpiScaleX),
static_cast<double>(mousePos.y * 96.f / dpiScaleX));
}
double e2d::Input::getMouseDeltaX()

View File

@ -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 消息,这个方法将调整渲染