From cfee7cfc9388c69b881c96f1f01abf13dc35ec72 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 28 Nov 2024 20:43:04 +0000 Subject: [PATCH] Windows: Fix bug where IME displayed at incorrect location on scaled displays --- modules/juce_gui_basics/native/juce_Windowing_windows.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index cafc6a727b..bf8d63c3fa 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -4586,9 +4586,10 @@ private: { if (auto* targetComp = dynamic_cast (target)) { - auto area = peer.getComponent().getLocalArea (targetComp, target->getCaretRectangle()); + const auto screenPos = targetComp->localPointToGlobal (target->getCaretRectangle().getBottomLeft()); + const auto relativePos = peer.globalToLocal (screenPos) * peer.getPlatformScaleFactor(); - CANDIDATEFORM pos = { 0, CFS_CANDIDATEPOS, { area.getX(), area.getBottom() }, { 0, 0, 0, 0 } }; + CANDIDATEFORM pos { 0, CFS_CANDIDATEPOS, D2DUtilities::toPOINT (relativePos), { 0, 0, 0, 0 } }; ImmSetCandidateWindow (hImc, &pos); } }