Browse Source

Windows: Set SWP_NOMOVE/SWP_NOSIZE flags when updating window position in HWNDComponent and use getSmallestIntegerContainer() when calculating scaled bounds

tags/2021-05-28
ed 4 years ago
parent
commit
08e6d2f9ee
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp

+ 8
- 4
modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp View File

@@ -46,16 +46,20 @@ public:
DestroyWindow (hwnd); DestroyWindow (hwnd);
} }
void componentMovedOrResized (bool, bool) override
void componentMovedOrResized (bool wasMoved, bool wasResized) override
{ {
if (auto* peer = owner.getTopLevelComponent()->getPeer()) if (auto* peer = owner.getTopLevelComponent()->getPeer())
{ {
auto area = (peer->getAreaCoveredBy (owner).toFloat() * peer->getPlatformScaleFactor()).toNearestInt();
auto area = (peer->getAreaCoveredBy (owner).toFloat() * peer->getPlatformScaleFactor()).getSmallestIntegerContainer();
setThreadDPIAwarenessForWindow (hwnd); setThreadDPIAwarenessForWindow (hwnd);
SetWindowPos (hwnd, nullptr, area.getX(), area.getY(), area.getWidth(), area.getHeight(),
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER);
UINT flagsToSend = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER;
if (! wasMoved) flagsToSend |= SWP_NOMOVE;
if (! wasResized) flagsToSend |= SWP_NOSIZE;
SetWindowPos (hwnd, nullptr, area.getX(), area.getY(), area.getWidth(), area.getHeight(), flagsToSend);
} }
} }


Loading…
Cancel
Save