Skip to content

Commit

Permalink
Code review for Mouse CoreWindow implementation (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Jan 23, 2025
1 parent 4aec63e commit 8392abe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Src/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,16 @@ void Mouse::SetWindow(HWND window)

#include <Windows.Devices.Input.h>

// This symbol is defined for Win32 desktop applications, but not for UWP
constexpr float USER_DEFAULT_SCREEN_DPI = 96.f;

class Mouse::Impl
{
public:
explicit Impl(Mouse* owner) noexcept(false) :
mState{},
mOwner(owner),
mDPI(96.f),
mDPI(USER_DEFAULT_SCREEN_DPI),
mMode(MODE_ABSOLUTE),
mAutoReset(true),
mLastX(0),
Expand Down Expand Up @@ -906,8 +909,8 @@ class Mouse::Impl

const float dpi = s_mouse->mDPI;

s_mouse->mState.x = static_cast<int>(pos.X * dpi / 96.f + 0.5f);
s_mouse->mState.y = static_cast<int>(pos.Y * dpi / 96.f + 0.5f);
s_mouse->mState.x = static_cast<int>(pos.X * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f);
s_mouse->mState.y = static_cast<int>(pos.Y * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f);
}

return S_OK;
Expand Down Expand Up @@ -970,8 +973,8 @@ class Mouse::Impl

float dpi = s_mouse->mDPI;

s_mouse->mState.x = static_cast<int>(pos.X * dpi / 96.f + 0.5f);
s_mouse->mState.y = static_cast<int>(pos.Y * dpi / 96.f + 0.5f);
s_mouse->mState.x = static_cast<int>(pos.X * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f);
s_mouse->mState.y = static_cast<int>(pos.Y * dpi / USER_DEFAULT_SCREEN_DPI + 0.5f);
}
}

Expand Down

0 comments on commit 8392abe

Please sign in to comment.