Windows QPA: Update screen on child window DPI change
Windows does not send WM_DPICHANGED to child windows, which means that the normal DPI change handling code does not run for QWindows which are embedded in a foreign, non-Qt, window. Add code which handles WM_DPICHANGED_AFTERPARENT. This event is sent to all child windows, but not the top-level window. Call checkForScreenChanged() here, similar to what the WM_DPICHANGED code does. This commit does not add code to resize the child window, since it is uncertain if this is the responsibility of the window which receives WM_DPICHANGED, or of each child window. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Task-number: QTBUG-103383 Change-Id: Icf85dd0afa806609dbbe0ffc36efbc5127962c39 Reviewed-by: <stefan.wastl@native-instruments.de> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 077eddb3e1aaba1517d67e7c83574c16e971dc67) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
393eb4fa97
commit
02c9117836
@ -106,6 +106,7 @@ enum WindowsEventType // Simplify event types
|
||||
ExitSizeMoveEvent = WindowEventFlag + 23,
|
||||
PointerActivateWindowEvent = WindowEventFlag + 24,
|
||||
DpiScaledSizeEvent = WindowEventFlag + 25,
|
||||
DpiChangedAfterParentEvent = WindowEventFlag + 27,
|
||||
MouseEvent = MouseEventFlag + 1,
|
||||
MouseWheelEvent = MouseEventFlag + 2,
|
||||
CursorEvent = MouseEventFlag + 3,
|
||||
@ -292,6 +293,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
|
||||
return HIWORD(wParamIn) ? QtWindows::AcceleratorCommandEvent : QtWindows::MenuCommandEvent;
|
||||
case WM_DPICHANGED:
|
||||
return QtWindows::DpiChangedEvent;
|
||||
case WM_DPICHANGED_AFTERPARENT:
|
||||
return QtWindows::DpiChangedAfterParentEvent;
|
||||
case WM_GETDPISCALEDSIZE:
|
||||
return QtWindows::DpiScaledSizeEvent;
|
||||
case WM_ENTERSIZEMOVE:
|
||||
|
@ -1325,6 +1325,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
||||
case QtWindows::DpiChangedEvent:
|
||||
platformWindow->handleDpiChanged(hwnd, wParam, lParam);
|
||||
return true;
|
||||
case QtWindows::DpiChangedAfterParentEvent:
|
||||
platformWindow->handleDpiChangedAfterParent(hwnd);
|
||||
return true;
|
||||
#if QT_CONFIG(sessionmanager)
|
||||
case QtWindows::QueryEndSessionApplicationEvent: {
|
||||
QWindowsSessionManager *sessionManager = platformSessionManager();
|
||||
|
@ -2007,6 +2007,14 @@ void QWindowsWindow::handleDpiChanged(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
|
||||
void QWindowsWindow::handleDpiChangedAfterParent(HWND hwnd)
|
||||
{
|
||||
// FIXME: refactor, do we really need this?
|
||||
setSavedDpi(GetDpiForWindow(hwnd));
|
||||
|
||||
checkForScreenChanged(QWindowsWindow::FromDpiChange);
|
||||
}
|
||||
|
||||
static QRect normalFrameGeometry(HWND hwnd)
|
||||
{
|
||||
WINDOWPLACEMENT wp;
|
||||
@ -2150,12 +2158,14 @@ static inline bool equalDpi(const QDpi &d1, const QDpi &d2)
|
||||
|
||||
void QWindowsWindow::checkForScreenChanged(ScreenChangeMode mode)
|
||||
{
|
||||
if (parent() || QWindowsScreenManager::isSingleScreen())
|
||||
if ((parent() && !parent()->isForeignWindow()) || QWindowsScreenManager::isSingleScreen())
|
||||
return;
|
||||
|
||||
QPlatformScreen *currentScreen = screen();
|
||||
auto topLevel = isTopLevel_sys() ? m_data.hwnd : GetAncestor(m_data.hwnd, GA_ROOT);
|
||||
const QWindowsScreen *newScreen =
|
||||
QWindowsContext::instance()->screenManager().screenForHwnd(m_data.hwnd);
|
||||
QWindowsContext::instance()->screenManager().screenForHwnd(topLevel);
|
||||
|
||||
if (newScreen == nullptr || newScreen == currentScreen)
|
||||
return;
|
||||
// For screens with different DPI: postpone until WM_DPICHANGE
|
||||
|
@ -286,6 +286,7 @@ public:
|
||||
void handleCompositionSettingsChanged();
|
||||
void handleDpiScaledSize(WPARAM wParam, LPARAM lParam, LRESULT *result);
|
||||
void handleDpiChanged(HWND hwnd, WPARAM wParam, LPARAM lParam);
|
||||
void handleDpiChangedAfterParent(HWND hwnd);
|
||||
|
||||
static void displayChanged();
|
||||
static void settingsChanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user