1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a bug in Windows plugins where the display bounds were not being updated when the scale factor was changed

This commit is contained in:
ed 2017-12-13 11:37:21 +00:00
parent 6fe0358dee
commit f11c43d038
2 changed files with 24 additions and 5 deletions

View file

@ -28,6 +28,9 @@ extern HWND juce_messageWindowHandle;
typedef bool (*CheckEventBlockedByModalComps) (const MSG&);
CheckEventBlockedByModalComps isEventBlockedByModalComps = nullptr;
typedef void (*SettingChangeCallbackFunc) (void);
SettingChangeCallbackFunc settingChangeCallback = nullptr;
//==============================================================================
namespace WindowsMessageHelpers
{
@ -101,6 +104,11 @@ namespace WindowsMessageHelpers
handleBroadcastMessage (reinterpret_cast<const COPYDATASTRUCT*> (lParam));
return 0;
}
else if (message == WM_SETTINGCHANGE)
{
if (settingChangeCallback != nullptr)
settingChangeCallback();
}
}
return DefWindowProc (h, message, wParam, lParam);

View file

@ -303,6 +303,9 @@ static void checkForPointerAPI()
&& getPointerPenInfo != nullptr);
}
typedef void (*SettingChangeCallbackFunc) (void);
extern SettingChangeCallbackFunc settingChangeCallback;
static Rectangle<int> rectangleFromRECT (const RECT& r) noexcept
{
return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom);
@ -1772,6 +1775,11 @@ private:
updateBorderSize();
checkForPointerAPI();
// This is needed so that our plugin window gets notified of WM_SETTINGCHANGE messages
// and can respond to display scale changes
if (! JUCEApplication::isStandaloneApp())
settingChangeCallback = forceDisplayUpdate;
// Calling this function here is (for some reason) necessary to make Windows
// correctly enable the menu items that we specify in the wm_initmenu message.
GetSystemMenu (hwnd, false);
@ -2918,19 +2926,23 @@ private:
void doSettingChange()
{
auto& desktop = Desktop::getInstance();
const_cast<Desktop::Displays&> (desktop.getDisplays()).refresh();
forceDisplayUpdate();
if (fullScreen && ! isMinimised())
{
auto& display = desktop.getDisplays().getDisplayContaining (component.getScreenBounds().getCentre());
auto& display = Desktop::getInstance().getDisplays()
.getDisplayContaining (component.getScreenBounds().getCentre());
setWindowPos (hwnd, display.userArea * display.scale,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSENDCHANGING);
}
}
static void forceDisplayUpdate()
{
const_cast<Desktop::Displays&> (Desktop::getInstance().getDisplays()).refresh();
}
void handleDPIChange() // happens when a window moves to a screen with a different DPI.
{
}
@ -3596,7 +3608,6 @@ JUCE_API ComponentPeer* createNonRepaintingEmbeddedWindowsPeer (Component& compo
JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
//==============================================================================
void ModifierKeys::updateCurrentModifiers() noexcept
{