mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 08:53:06 +08:00
Ensure the window origin is visible after DPI change
Keep the window origin on its display to avoid moving it out of visible area, which is unexpected and inconvenient.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "wx/graphics.h"
|
||||
#endif // wxUSE_GRAPHICS_CONTEXT
|
||||
|
||||
#include "wx/display.h"
|
||||
#include "wx/dynlib.h"
|
||||
#include "wx/msw/missing.h"
|
||||
#include "wx/msw/private/darkmode.h"
|
||||
@@ -338,6 +339,14 @@ bool wxNonOwnedWindow::HandleDPIChange(const wxSize& newDPI, const wxRect& newRe
|
||||
// which it might have been just moved to this one, as doing this
|
||||
// would result in an infinite stream of WM_DPICHANGED messages.
|
||||
actualNewRect.Inflate(diff / 2);
|
||||
|
||||
// However still ensure that the window origin is visible on its
|
||||
// display, we don't move to move it out of visible space.
|
||||
const wxRect screenRect = wxDisplay(this).GetClientArea();
|
||||
if ( actualNewRect.x < screenRect.x )
|
||||
actualNewRect.x = screenRect.x;
|
||||
if ( actualNewRect.y < screenRect.y )
|
||||
actualNewRect.y = screenRect.y;
|
||||
}
|
||||
|
||||
SetSize(actualNewRect);
|
||||
|
||||
Reference in New Issue
Block a user