aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r--win32/PlatWin.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 02f31cc5e..ff47c28ab 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -168,7 +168,7 @@ float GetDeviceScaleFactorWhenGdiScalingActive(HWND hWnd) noexcept {
const HMONITOR hMonitor = MonitorFromWindowHandleScaling(hRootWnd);
DEVICE_SCALE_FACTOR deviceScaleFactor;
if (S_OK == fnGetScaleFactorForMonitor(hMonitor, &deviceScaleFactor))
- return static_cast<int>(deviceScaleFactor) / 100.f;
+ return static_cast<float>(static_cast<int>(deviceScaleFactor)) / 100.f;
}
}
return 1.f;
@@ -404,6 +404,8 @@ class CursorHelper {
DWORD *pixels = nullptr;
const int width;
const int height;
+ const float scale;
+ static constexpr float baseSize = 32.0f;
static constexpr float arrow[][2] = {
{ 32.0f - 12.73606f,32.0f - 19.04075f },
@@ -418,7 +420,7 @@ class CursorHelper {
public:
~CursorHelper() = default;
- CursorHelper(int width_, int height_) noexcept : width{width_}, height{height_} {
+ CursorHelper(int width_, int height_) noexcept : width{width_}, height{height_}, scale{ static_cast<float>(width) / baseSize } {
// https://learn.microsoft.com/en-us/windows/win32/menurc/using-cursors#creating-a-cursor
bm.Create({}, width, height, &pixels);
}
@@ -470,7 +472,6 @@ public:
// Draw something on the bitmap section.
constexpr size_t nPoints = std::size(arrow);
D2D1_POINT_2F points[nPoints]{};
- const FLOAT scale = width/32.0f;
for (size_t i = 0; i < nPoints; i++) {
points[i].x = arrow[i][0] * scale;
points[i].y = arrow[i][1] * scale;
@@ -519,7 +520,6 @@ public:
// Draw something on the DIB section.
constexpr size_t nPoints = std::size(arrow);
POINT points[nPoints]{};
- const float scale = width/32.0f;
for (size_t i = 0; i < nPoints; i++) {
points[i].x = std::lround(arrow[i][0] * scale);
points[i].y = std::lround(arrow[i][1] * scale);