BR: minimizing/restoring a window does increase its size

Spotted with 8.0.4, not present in 8.0.1.
Windows 11

When a plugin editor window is set to have a native title bar and a constrained aspect ratio the window does increase in size every time it is minimized and restored again.

Here is a simple way to reproduce the issue:
In a new basic plugin project, simply add these two lines to the NewProjectAudioProcessorEditor constructor

    juce::TopLevelWindow::getTopLevelWindow(0)->setUsingNativeTitleBar(true);
    getConstrainer()->setFixedAspectRatio(4./3);
1 Like

I confirm this for Windows 10 as well.

Thanks for reporting. It looks like this was caused by Windows returning incorrect window/border sizes for windows in a minimized state, which then caused problems when adding this border back to the component’s bounds.

The problem should be fixed here:

3 Likes

That fixes it for me, thank you!

1 Like

Hi @Fuo many thanks to report this issue
Hi @reuk many thanks for this fix.

BTW Their is still a pitfall in it the following special case:

When a windows does not have a native titlebar and came from minimized state to maximized state directly, the issue appears again:

This is due to the fact that HWNDComponentPeer::peerWindowProc() WM_NCCALCSIZE implementation is trigger when this special event occured.
MonitorFromWindow fail in the specific case hwnd is still minimized and about to be restored in fullscreen.

To fix this I just remove the local monitor variable and its computation and let relly GetMonitorInfo to the valid currentMonitor member of HWNDComponentPeer

juce_Windowing_windows.cpp line 3920 before:

                // If we're not using a native titlebar, and the window is maximised, then the
                // proposed window may be a bit bigger than the available space. Remove the padding
                // so that the client area exactly fills the available space.
                if (isFullScreen())
                {
                    const auto monitor = MonitorFromWindow (hwnd, MONITOR_DEFAULTTONULL);

                    if (monitor == nullptr)
                        return 0;

                    MONITORINFOEX info{};
                    info.cbSize = sizeof (info);
                    GetMonitorInfo (monitor, &info);

juce_Windowing_windows.cpp line 3920 after:

                // If we're not using a native titlebar, and the window is maximised, then the
                // proposed window may be a bit bigger than the available space. Remove the padding
                // so that the client area exactly fills the available space.
                if (isFullScreen())
                {
                    if (currentMonitor == nullptr)
                        return 0;

                    MONITORINFOEX info{};
                    info.cbSize = sizeof(info);
                    GetMonitorInfo (currentMonitor, &info); 

Hoping this will helps.
All the best!