Browse Source

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

tags/2021-05-28
ed 7 years ago
parent
commit
f11c43d038
2 changed files with 24 additions and 5 deletions
  1. +8
    -0
      modules/juce_events/native/juce_win32_Messaging.cpp
  2. +16
    -5
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp

+ 8
- 0
modules/juce_events/native/juce_win32_Messaging.cpp View File

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


+ 16
- 5
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -303,6 +303,9 @@ static void checkForPointerAPI()
&& getPointerPenInfo != nullptr); && getPointerPenInfo != nullptr);
} }
typedef void (*SettingChangeCallbackFunc) (void);
extern SettingChangeCallbackFunc settingChangeCallback;
static Rectangle<int> rectangleFromRECT (const RECT& r) noexcept static Rectangle<int> rectangleFromRECT (const RECT& r) noexcept
{ {
return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom); return Rectangle<int>::leftTopRightBottom ((int) r.left, (int) r.top, (int) r.right, (int) r.bottom);
@@ -1772,6 +1775,11 @@ private:
updateBorderSize(); updateBorderSize();
checkForPointerAPI(); 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 // 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. // correctly enable the menu items that we specify in the wm_initmenu message.
GetSystemMenu (hwnd, false); GetSystemMenu (hwnd, false);
@@ -2918,19 +2926,23 @@ private:
void doSettingChange() void doSettingChange()
{ {
auto& desktop = Desktop::getInstance();
const_cast<Desktop::Displays&> (desktop.getDisplays()).refresh();
forceDisplayUpdate();
if (fullScreen && ! isMinimised()) 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, setWindowPos (hwnd, display.userArea * display.scale,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSENDCHANGING); 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. 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) JUCE_IMPLEMENT_SINGLETON (HWNDComponentPeer::WindowClassHolder)
//============================================================================== //==============================================================================
void ModifierKeys::updateCurrentModifiers() noexcept void ModifierKeys::updateCurrentModifiers() noexcept
{ {


Loading…
Cancel
Save