diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2016-01-08 12:30:57 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2016-01-08 12:35:24 +0100 |
commit | ad16478a76815f8f61d454bf7760aaf9ffbb4b51 (patch) | |
tree | eefdd9219cc9d59b62e042f49fc7555b980cb7a4 /src/gui/kernel | |
parent | 80a741f3616290897ba0d9f1cbd3c9c5ee62da37 (diff) | |
parent | 09c92863001790a0304a5ef389901ee2b5b6cdc2 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Based on merge done by Liang Qi
Change-Id: Id566e5b9f284d29bff2199f13f9417c660f5b26f
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 50 | ||||
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 6 |
3 files changed, 40 insertions, 18 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 6fa974829f..777ecbdb09 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -996,18 +996,38 @@ qreal QGuiApplication::devicePixelRatio() const */ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) { - QList<QScreen *> screens = QGuiApplication::screens(); - QList<QScreen *>::const_iterator screen = screens.constBegin(); - QList<QScreen *>::const_iterator end = screens.constEnd(); - - while (screen != end) { - if ((*screen)->geometry().contains(pos)) { - const QPoint devicePosition = QHighDpi::toNativePixels(pos, *screen); - return (*screen)->handle()->topLevelAt(devicePosition); + const QList<QScreen *> screens = QGuiApplication::screens(); + if (!screens.isEmpty()) { + const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings(); + QScreen *windowScreen = Q_NULLPTR; + + // Find the window on the primary virtual desktop first + foreach (QScreen *screen, primaryScreens) { + if (screen->geometry().contains(pos)) { + windowScreen = screen; + break; + } + } + + // If the window is not found on primary virtual desktop, find it on all screens + // except the first which was for sure in the previous loop. Some other screens + // may repeat. Find only when there is more than one virtual desktop. + if (!windowScreen && screens.count() != primaryScreens.count()) { + for (int i = 1; i < screens.size(); ++i) { + QScreen *screen = screens[i]; + if (screen->geometry().contains(pos)) { + windowScreen = screen; + break; + } + } + } + + if (windowScreen) { + const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); + return windowScreen->handle()->topLevelAt(devicePosition); } - ++screen; } - return 0; + return Q_NULLPTR; } /*! @@ -2102,10 +2122,12 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse) { if (QWindow *window = wse->window.data()) { - if (QScreen *screen = wse->screen.data()) - window->d_func()->setTopLevelScreen(screen, false /* recreate */); - else // Fall back to default behavior, and try to find some appropriate screen - window->setScreen(0); + if (window->isTopLevel()) { + if (QScreen *screen = wse->screen.data()) + window->d_func()->setTopLevelScreen(screen, false /* recreate */); + else // Fall back to default behavior, and try to find some appropriate screen + window->setScreen(0); + } // we may have changed scaling, so trigger resize event if needed if (window->handle()) { QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index a3201aa23f..b0ef2a284f 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -173,7 +173,7 @@ static inline qreal initialGlobalScaleFactor() include X11, Windows, and Android. There are two APIs for enabling or disabling this behavior: - - The QT_AUTO_SCALE_FACTOR environment variable. + - The QT_AUTO_SCREEN_SCALE_FACTOR environment variable. - The AA_EnableHighDpiScaling and AA_DisableHighDpiScaling application attributes diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 3a51c2b7b2..8258e3999c 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1459,11 +1459,11 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx) { QMutexLocker locker(&m_mutex); - QList<QOpenGLSharedResource *> pending = m_pendingDeletion; + const QList<QOpenGLSharedResource *> pending = m_pendingDeletion; m_pendingDeletion.clear(); - QList<QOpenGLSharedResource *>::iterator it = pending.begin(); - QList<QOpenGLSharedResource *>::iterator end = pending.end(); + QList<QOpenGLSharedResource *>::const_iterator it = pending.begin(); + QList<QOpenGLSharedResource *>::const_iterator end = pending.end(); while (it != end) { (*it)->freeResource(ctx); delete *it; |