diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-12-30 17:39:21 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-02 09:58:44 +0100 |
commit | 0f315adf9199efcfafa44371464ab6d1fc866774 (patch) | |
tree | 35b67591255624c670aff0579e45b2973f56fd81 /src/gui/kernel | |
parent | 2b0eb3fac319a17dd92903106d501f0f06df871f (diff) | |
parent | 52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
.qmake.conf
sc/corelib/io/qfsfileengine_p.h
src/corelib/io/qstorageinfo_unix.cpp
src/platformsupport/eglconvenience/qeglpbuffer_p.h
src/platformsupport/input/libinput/qlibinputkeyboard.cpp
src/platformsupport/input/libinput/qlibinputpointer.cpp
src/plugins/platforms/cocoa/qcocoamenu.mm
src/plugins/platforms/ios/qiosscreen.h
src/plugins/platforms/ios/qioswindow.h
src/plugins/platforms/ios/quiview.mm
src/printsupport/dialogs/qpagesetupdialog_unix_p.h
src/printsupport/dialogs/qprintpreviewdialog.cpp
src/printsupport/widgets/qcupsjobwidget_p.h
src/widgets/widgets/qmenu.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 16 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 18 | ||||
-rw-r--r-- | src/gui/kernel/qinputdevicemanager.cpp | 44 | ||||
-rw-r--r-- | src/gui/kernel/qinputdevicemanager_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qinputdevicemanager_p_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 12 |
14 files changed, 121 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5004582c5f..b7c61779e6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1787,6 +1787,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv case QWindowSystemInterfacePrivate::WindowScreenChanged: QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e)); break; + case QWindowSystemInterfacePrivate::SafeAreaMarginsChanged: + QGuiApplicationPrivate::processSafeAreaMarginsChangedEvent(static_cast<QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *>(e)); + break; case QWindowSystemInterfacePrivate::ApplicationStateChanged: { QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e); QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); } @@ -2284,6 +2287,17 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf } } +void QGuiApplicationPrivate::processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *wse) +{ + if (wse->window.isNull()) + return; + + // Handle by forwarding directly to QWindowPrivate, instead of sending spontaneous + // QEvent like most other functions, as there's no QEvent type for the safe area + // change, and we don't want to add one until we know that this is a good API. + qt_window_private(wse->window)->processSafeAreaMarginsChanged(); +} + void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) { if (self) @@ -2979,7 +2993,7 @@ QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QM static QPointer<QWindow> currentDragWindow; static Qt::DropAction lastAcceptedDropAction = Qt::IgnoreAction; QPlatformDrag *platformDrag = platformIntegration()->drag(); - if (!platformDrag) { + if (!platformDrag || (w && w->d_func()->blockedByModalWindow)) { lastAcceptedDropAction = Qt::IgnoreAction; return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index b7b847785c..75cbc7abde 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -133,6 +133,8 @@ public: static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e); static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e); + static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e); + static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e); static void updateFilteredScreenOrientation(QScreen *screen); diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index caef942840..8689f9f3b1 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -376,8 +376,22 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen) { qreal factor = qreal(1.0); if (screen) { - if (m_usePixelDensity) - factor *= screen->pixelDensity(); + if (m_usePixelDensity) { + qreal pixelDensity = screen->pixelDensity(); + + // Pixel density reported by the screen is sometimes not precise enough, + // so recalculate it: divide px (physical pixels) by dp (device-independent pixels) + // for both width and height, and then use the average if it is different from + // the one initially reported by the screen + QRect screenGeometry = screen->geometry(); + qreal wFactor = qreal(screenGeometry.width()) / qRound(screenGeometry.width() / pixelDensity); + qreal hFactor = qreal(screenGeometry.height()) / qRound(screenGeometry.height() / pixelDensity); + qreal averageDensity = (wFactor + hFactor) / 2; + if (!qFuzzyCompare(pixelDensity, averageDensity)) + pixelDensity = averageDensity; + + factor *= pixelDensity; + } if (m_screenFactorSet) { QVariant screenFactor = screen->screen()->property(scaleFactorProperty); if (screenFactor.isValid()) diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp index 2d231ae26f..37b1450d5a 100644 --- a/src/gui/kernel/qinputdevicemanager.cpp +++ b/src/gui/kernel/qinputdevicemanager.cpp @@ -92,4 +92,48 @@ void QInputDeviceManager::setCursorPos(const QPoint &pos) emit cursorPositionChangeRequested(pos); } +/*! + \return the keyboard modifier state stored in the QInputDeviceManager object. + + Keyboard input handlers are expected to keep this up-to-date via + setKeyboardModifiers(). + + Querying the state via this function (e.g. from a mouse handler that needs + to include the modifier state in mouse events) is the preferred alternative + over QGuiApplication::keyboardModifiers() since the latter may not report + the current state due to asynchronous QPA event processing. + */ +Qt::KeyboardModifiers QInputDeviceManager::keyboardModifiers() const +{ + Q_D(const QInputDeviceManager); + return d->keyboardModifiers; +} + +void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key) +{ + Q_D(QInputDeviceManager); + Qt::KeyboardModifiers mods; + switch (key) { + case Qt::Key_Shift: + mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ShiftModifier); + break; + case Qt::Key_Control: + mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ControlModifier); + break; + case Qt::Key_Alt: + mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::AltModifier); + break; + case Qt::Key_Meta: + mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::MetaModifier); + break; + case Qt::Key_AltGr: + mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::GroupSwitchModifier); + break; + default: + mods = modsBeforeEvent; + break; + } + d->keyboardModifiers = mods; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index db9d0596b6..ddf1e6befa 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -78,6 +78,9 @@ public: void setCursorPos(const QPoint &pos); + Qt::KeyboardModifiers keyboardModifiers() const; + void setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key); + signals: void deviceListChanged(QInputDeviceManager::DeviceType type); void cursorPositionChangeRequested(const QPoint &pos); diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index ae91f3a2ab..0a91252fbc 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -69,6 +69,8 @@ public: void setDeviceCount(QInputDeviceManager::DeviceType type, int count); QMap<QInputDeviceManager::DeviceType, int> m_deviceCount; + + Qt::KeyboardModifiers keyboardModifiers; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 6298dd5f45..27ea3864b9 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -937,7 +937,9 @@ GLuint QOpenGLContext::defaultFramebufferObject() const /*! Makes the context current in the current thread, against the given - \a surface. Returns \c true if successful. + \a surface. Returns \c true if successful; otherwise returns \c false. + The latter may happen if the surface is not exposed, or the graphics + hardware is not available due to e.g. the application being suspended. If \a surface is 0 this is equivalent to calling doneCurrent(). diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 2284290d6c..4bf96e277f 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -166,6 +166,16 @@ QMargins QPlatformWindow::frameMargins() const } /*! + The safe area margins of a window represent the area that is safe to + place content within, without intersecting areas of the screen where + system UI is placed, or where a screen bezel may cover the content. +*/ +QMargins QPlatformWindow::safeAreaMargins() const +{ + return QMargins(); +} + +/*! Reimplemented in subclasses to show the surface if \a visible is \c true, and hide it if \a visible is \c false. diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 4105ef1c1a..61f1cb624c 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -88,6 +88,7 @@ public: virtual QRect normalGeometry() const; virtual QMargins frameMargins() const; + virtual QMargins safeAreaMargins() const; virtual void setVisible(bool visible); virtual void setWindowFlags(Qt::WindowFlags flags); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index fea55e459d..3e5777ad49 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2790,6 +2790,8 @@ bool QWindowPrivate::applyCursor() if (!platformWindow) return true; QCursor *c = QGuiApplication::overrideCursor(); + if (c != nullptr && platformCursor->capabilities().testFlag(QPlatformCursor::OverrideCursor)) + return true; if (!c && hasCursor) c = &cursor; platformCursor->changeCursor(c, q); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 2de5aab2c4..7ef73eb410 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -155,6 +155,8 @@ public: virtual void clearFocusObject(); virtual QRectF closestAcceptableGeometry(const QRectF &rect) const; + virtual void processSafeAreaMarginsChanged() {}; + bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; } static QWindowPrivate *get(QWindow *window) { return window->d_func(); } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index a47bac8f39..35a9ede227 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -265,6 +265,13 @@ void QWindowSystemInterface::handleWindowScreenChanged(QWindow *window, QScreen QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } +QT_DEFINE_QPA_EVENT_HANDLER(void, handleSafeAreaMarginsChanged, QWindow *window) +{ + QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e = + new QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent(window); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); +} + QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate) { Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)); diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 960f79b5ba..b22495f9d0 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -208,6 +208,9 @@ public: static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen); template<typename Delivery = QWindowSystemInterface::DefaultDelivery> + static void handleSafeAreaMarginsChanged(QWindow *window); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); #ifndef QT_NO_DRAGANDDROP diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 152ea92919..c3fb19d21a 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -98,7 +98,8 @@ public: #endif ApplicationStateChanged = 0x19, FlushEvents = 0x20, - WindowScreenChanged = 0x21 + WindowScreenChanged = 0x21, + SafeAreaMarginsChanged = 0x22 }; class WindowSystemEvent { @@ -185,6 +186,15 @@ public: QPointer<QScreen> screen; }; + class SafeAreaMarginsChangedEvent : public WindowSystemEvent { + public: + SafeAreaMarginsChangedEvent(QWindow *w) + : WindowSystemEvent(SafeAreaMarginsChanged), window(w) + { } + + QPointer<QWindow> window; + }; + class ApplicationStateChangedEvent : public WindowSystemEvent { public: ApplicationStateChangedEvent(Qt::ApplicationState newState, bool forcePropagate = false) |