From f1a5f2ef1e95e1166908e58adf309367290a65b3 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 6 Jul 2020 16:50:00 +0100 Subject: [PATCH] Windows: Fixed drag and drop position for DPI-unaware windows --- modules/juce_gui_basics/native/juce_win32_Windowing.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 2b60c84713..aa6c1753ac 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1780,16 +1780,16 @@ public: private: Point getMousePos (POINTL mousePos) const { - Point screenPos; + auto screenPos = pointFromPOINT ({ mousePos.x, mousePos.y }).toFloat(); #if JUCE_WIN_PER_MONITOR_DPI_AWARE auto h = (HWND) peer.getNativeHandle(); if (isPerMonitorDPIAwareWindow (h)) - screenPos = convertPhysicalScreenPointToLogical (pointFromPOINT ({ mousePos.x, mousePos.y }), h).toFloat(); - else + screenPos = convertPhysicalScreenPointToLogical (screenPos.roundToInt(), h).toFloat(); + #else + screenPos /= static_cast (getGlobalDPI() / USER_DEFAULT_SCREEN_DPI); #endif - screenPos = pointFromPOINT ({ mousePos.x, mousePos.y }).toFloat() / static_cast (getGlobalDPI() / USER_DEFAULT_SCREEN_DPI); return peer.getComponent().getLocalPoint (nullptr, screenPos); }