diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 110 |
1 files changed, 66 insertions, 44 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 46e5f6be70..334dc4a288 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -68,8 +68,8 @@ #include <qpalette.h> #include <qscreen.h> #include "qsessionmanager.h" +#include <private/qcolorprofile_p.h> #include <private/qscreen_p.h> -#include <private/qdrawhelper_p.h> #include <QtGui/qgenericpluginfactory.h> #include <QtGui/qstylehints.h> @@ -84,6 +84,7 @@ #include "private/qcursor_p.h" #include "private/qopenglcontext_p.h" #include "private/qinputdevicemanager_p.h" +#include "private/qtouchdevice_p.h" #include "private/qdnd_p.h" #include <qpa/qplatformthemefactory_p.h> @@ -107,9 +108,6 @@ #elif defined(Q_OS_WIN) # include <QtCore/qt_windows.h> # include <QtCore/QLibraryInfo> -# if defined(Q_OS_WINPHONE) -# include <Objbase.h> -# endif #endif // Q_OS_WIN #include <ctype.h> @@ -821,19 +819,11 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking for (int i = 0; i < modalWindowList.count(); ++i) { QWindow *modalWindow = modalWindowList.at(i); - { - // check if the modal window is our window or a (transient) parent of our window - QWindow *w = window; - while (w) { - if (w == modalWindow) { - *blockingWindow = 0; - return false; - } - QWindow *p = w->parent(); - if (!p) - p = w->transientParent(); - w = p; - } + // A window is not blocked by another modal window if the two are + // the same, or if the window is a child of the modal window. + if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { + *blockingWindow = 0; + return false; } Qt::WindowModality windowModality = modalWindow->modality(); @@ -940,15 +930,25 @@ QWindowList QGuiApplication::topLevelWindows() { const QWindowList &list = QGuiApplicationPrivate::window_list; QWindowList topLevelWindows; - for (int i = 0; i < list.size(); i++) { - if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) { - // Top windows of embedded QAxServers do not have QWindow parents, - // but they are not true top level windows, so do not include them. - const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(); - if (!embedded) - topLevelWindows.prepend(list.at(i)); - } + for (int i = 0; i < list.size(); ++i) { + QWindow *window = list.at(i); + if (!window->isTopLevel()) + continue; + + // Desktop windows are special, as each individual desktop window + // will report that it's a top level window, but we don't want to + // include them in the application wide list of top level windows. + if (window->type() == Qt::Desktop) + continue; + + // Windows embedded in native windows do not have QWindow parents, + // but they are not true top level windows, so do not include them. + if (window->handle() && window->handle()->isEmbedded()) + continue; + + topLevelWindows.prepend(window); } + return topLevelWindows; } @@ -1124,7 +1124,7 @@ static void init_platform(const QString &pluginArgument, const QString &platform = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\"\nin \"%2\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath)); if (!keys.isEmpty()) { fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( - keys.join(QStringLiteral(", "))); + keys.join(QLatin1String(", "))); } fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) @@ -1523,7 +1523,8 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() platform_theme = 0; delete platform_integration; platform_integration = 0; - delete m_gammaTables.load(); + delete m_a8ColorProfile.load(); + delete m_a32ColorProfile.load(); window_list.clear(); } @@ -1958,7 +1959,8 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo points << point; QEvent::Type type; - QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type); + QList<QTouchEvent::TouchPoint> touchPoints = + QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, QTouchDevicePrivate::get(m_fakeTouchDevice)->id, &type); QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; @@ -2160,7 +2162,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) { if (QWindow *window = wse->window.data()) { - QWindowStateChangeEvent e(window->windowState()); + QWindowStateChangeEvent e(wse->oldState); window->d_func()->windowState = wse->newState; QGuiApplication::sendSpontaneousEvent(window, &e); } @@ -2195,10 +2197,10 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate:: void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) { - if (e->tlw.isNull()) + if (e->window.isNull()) return; - QWindow *window = e->tlw.data(); + QWindow *window = e->window.data(); if (!window) return; @@ -2563,7 +2565,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To Q_ASSERT(w.data() != 0); // make the *scene* functions return the same as the *screen* functions - touchPoint.d->sceneRect = touchPoint.screenRect(); + // Note: touchPoint is a reference to the one from activeTouchPoints, + // so we can modify it as long as we're careful NOT to call setters and + // otherwise NOT to cause the d-pointer to be detached. + touchPoint.d->scenePos = touchPoint.screenPos(); touchPoint.d->startScenePos = touchPoint.startScreenPos(); touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); @@ -2618,8 +2623,8 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QTouchEvent touchEvent(eventType, e->device, e->modifiers, - it.value().first, - it.value().second); + it.value().first, // state flags + it.value().second); // list of touchpoints touchEvent.setTimestamp(e->timestamp); touchEvent.setWindow(w); @@ -2628,13 +2633,14 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; // preserve the sub-pixel resolution - QRectF rect = touchPoint.screenRect(); - const QPointF screenPos = rect.center(); + const QPointF screenPos = touchPoint.screenPos(); const QPointF delta = screenPos - screenPos.toPoint(); - rect.moveCenter(w->mapFromGlobal(screenPos.toPoint()) + delta); - touchPoint.d->rect = rect; + touchPoint.d->pos = w->mapFromGlobal(screenPos.toPoint()) + delta; if (touchPoint.state() == Qt::TouchPointPressed) { + // touchPoint is actually a reference to one that is stored in activeTouchPoints, + // and we are now going to store the startPos and lastPos there, for the benefit + // of future moves and releases. It's important that the d-pointer is NOT detached. touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; } @@ -3674,14 +3680,30 @@ void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) } #endif -const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() +const QColorProfile *QGuiApplicationPrivate::colorProfileForA8Text() +{ +#ifdef Q_OS_WIN + QColorProfile *result = m_a8ColorProfile.load(); + if (!result){ + QColorProfile *cs = QColorProfile::fromGamma(2.31); // This is a hard-coded thing for Windows text rendering + if (!m_a8ColorProfile.testAndSetRelease(0, cs)) + delete cs; + result = m_a8ColorProfile.load(); + } + return result; +#else + return colorProfileForA32Text(); +#endif +} + +const QColorProfile *QGuiApplicationPrivate::colorProfileForA32Text() { - QDrawHelperGammaTables *result = m_gammaTables.load(); + QColorProfile *result = m_a32ColorProfile.load(); if (!result){ - QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(fontSmoothingGamma); - if (!m_gammaTables.testAndSetRelease(0, tables)) - delete tables; - result = m_gammaTables.load(); + QColorProfile *cs = QColorProfile::fromGamma(fontSmoothingGamma); + if (!m_a32ColorProfile.testAndSetRelease(0, cs)) + delete cs; + result = m_a32ColorProfile.load(); } return result; } |