Fix high-dpi and QScreen state initialization

Fix bug where QScreen::geometry() returns incorrect
(unscaled) geometry.

We maintain state:

  - QHighDpiScaling::m_active, which is set to true
    if any screen in QGuiApplication::screens() has a
    scale factor > 1, in updateHighDpiScaling()
  - QScreen::m_geometry, which is assigned the scaled
    screen size in QScreenPrivate::updateHighDpi()

Now the problem is that updateHighDpiScaling() requires
an up-to date screens list, and that updateHighDpi()
requires an up-to date m_active, and that currently
updateHighDpi() is called when constructing the QScreen
only.

This is all a bit unsatisfactory, but for now fix this
in the simplest way by adding a second call to
updateHighDpi() in handleScreenAdded(), after the call
to updateHighDpiScaling().

Pick-to: 6.2 6.3
Fixes-number: QTBUG-101601
Change-Id: I5f442ceb966c77d6746ee885203b67da96612587
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2022-03-11 12:00:12 +01:00 committed by Tor Arne Vestbø
parent 32692667a6
commit 942de89562

View File

@ -43,6 +43,7 @@
#include "private/qevent_p.h"
#include "private/qeventpoint_p.h"
#include "private/qpointingdevice_p.h"
#include "private/qscreen_p.h"
#include <QAbstractEventDispatcher>
#include <qpa/qplatformintegration.h>
#include <qdebug.h>
@ -785,6 +786,7 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima
QGuiApplicationPrivate::resetCachedDevicePixelRatio();
QHighDpiScaling::updateHighDpiScaling();
screen->d_func()->updateHighDpi();
emit qGuiApp->screenAdded(screen);