diff options
author | Liang Qi <liang.qi@qt.io> | 2017-01-26 00:37:14 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-01-26 00:37:14 +0000 |
commit | 398a7e736cb42ac42f0887989585b1121b7e6e62 (patch) | |
tree | 916854b706b9b057fa1483f76dd48998a8aa28a0 /src/gui/kernel | |
parent | 4d3a35f63788fa5ff7a11a5bb7bd6176bd2ac70e (diff) | |
parent | 318b58562ae89453fb98e8145cd0440e14ba60b0 (diff) |
Merge "Merge remote-tracking branch 'origin/5.8' into dev" into refs/staging/dev
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 20 | ||||
-rw-r--r-- | src/gui/kernel/qinputdevicemanager_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformsystemtrayicon.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag.cpp | 37 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 7 |
7 files changed, 65 insertions, 24 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3438fc0dcd..2faf970855 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -757,6 +757,14 @@ void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) updateBlockedStatusRecursion(window, shouldBeBlocked); } +// Return whether the window needs to be notified about window blocked events. +// As opposed to QGuiApplication::topLevelWindows(), embedded windows are +// included in this list (QTBUG-18099). +static inline bool needsWindowBlockedEvent(const QWindow *w) +{ + return w->isTopLevel() && w->type() != Qt::Desktop; +} + void QGuiApplicationPrivate::showModalWindow(QWindow *modal) { self->modalWindowList.prepend(modal); @@ -774,10 +782,8 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) } } - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (!window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && !window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } @@ -788,10 +794,8 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) { self->modalWindowList.removeAll(window); - QWindowList windows = QGuiApplication::topLevelWindows(); - for (int i = 0; i < windows.count(); ++i) { - QWindow *window = windows.at(i); - if (window->d_func()->blockedByModalWindow) + for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) { + if (needsWindowBlockedEvent(window) && window->d_func()->blockedByModalWindow) updateBlockedStatus(window); } } diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index 11bbaae592..db9d0596b6 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -79,7 +79,7 @@ public: void setCursorPos(const QPoint &pos); signals: - void deviceListChanged(DeviceType type); + void deviceListChanged(QInputDeviceManager::DeviceType type); void cursorPositionChangeRequested(const QPoint &pos); }; diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp index 30db966df7..973b998059 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon.cpp @@ -40,6 +40,9 @@ #include "qplatformsystemtrayicon.h" +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformtheme.h> + #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE @@ -158,11 +161,10 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() */ /*! - This method is called in case there is no QPlatformMenu available when - updating the menu. This allows the abstraction to provide a menu for the - system tray icon even if normally a non-native menu is used. - - The default implementation returns a null pointer. + This method allows platforms to use a different QPlatformMenu for system + tray menus than what would normally be used for e.g. menu bars. The default + implementation falls back to a platform menu created by the platform theme, + which may be null on platforms without native menus. \sa updateMenu() \since 5.3 @@ -170,7 +172,7 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const { - return Q_NULLPTR; + return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); } QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 931c784d08..878f656f2e 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -80,6 +80,10 @@ QT_BEGIN_NAMESPACE \value MouseDoubleClickInterval (int) Mouse double click interval in ms, overriding QPlatformIntegration::styleHint. + \value MouseDoubleClickDistance (int) The maximum distance in logical pixels which the mouse can travel + between clicks in order for the click sequence to be handled as a double click. + The default value is 5 logical pixels. + \value MousePressAndHoldInterval (int) Mouse press and hold interval in ms, overriding QPlatformIntegration::styleHint. @@ -89,6 +93,9 @@ QT_BEGIN_NAMESPACE \value StartDragTime (int) Start drag time in ms, overriding QPlatformIntegration::styleHint. + \value WheelScrollLines (int) The number of lines to scroll a widget, when the mouse wheel is rotated. + The default value is 3. \sa QApplication::wheelScrollLines() + \value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate, overriding QPlatformIntegration::styleHint. diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 2f8a678c38..6fd2afb1aa 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -60,7 +60,7 @@ QPlatformWindow::QPlatformWindow(QWindow *window) , d_ptr(new QPlatformWindowPrivate) { Q_D(QPlatformWindow); - d->rect = window->geometry(); + d->rect = QHighDpi::toNativePixels(window->geometry(), window); } /*! diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index a6ce04dc34..fc62273325 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -53,6 +53,8 @@ #include "qdir.h" #include "qimagereader.h" #include "qimagewriter.h" +#include "qplatformscreen.h" +#include "qplatformwindow.h" #include <QtCore/QEventLoop> #include <QtCore/QDebug> @@ -316,6 +318,25 @@ void QBasicDrag::updateCursor(Qt::DropAction action) updateAction(action); } + +static inline QPoint fromNativeGlobalPixels(const QPoint &point) +{ +#ifndef QT_NO_HIGHDPISCALING + QPoint res = point; + if (QHighDpiScaling::isActive()) { + for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) { + if (s->handle()->geometry().contains(point)) { + res = QHighDpi::fromNativePixels(point, s); + break; + } + } + } + return res; +#else + return point; +#endif +} + /*! \class QSimpleDrag \brief QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself. @@ -344,7 +365,7 @@ void QSimpleDrag::startDrag() QBasicDrag::startDrag(); m_current_window = topLevelAt(QCursor::pos()); if (m_current_window) { - QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions()); + QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QHighDpi::toNativePixels(QCursor::pos(), m_current_window), drag()->supportedActions()); setCanDrop(response.isAccepted()); updateCursor(response.acceptedAction()); } else { @@ -363,15 +384,15 @@ void QSimpleDrag::cancel() } } -void QSimpleDrag::move(const QPoint &globalPos) +void QSimpleDrag::move(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); moveShapedPixmapWindow(globalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDragQtResponse qt_response = QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); @@ -379,16 +400,16 @@ void QSimpleDrag::move(const QPoint &globalPos) setCanDrop(qt_response.isAccepted()); } -void QSimpleDrag::drop(const QPoint &globalPos) +void QSimpleDrag::drop(const QPoint &nativeGlobalPos) { - //### not high-DPI aware + QPoint globalPos = fromNativeGlobalPixels(nativeGlobalPos); - QBasicDrag::drop(globalPos); + QBasicDrag::drop(nativeGlobalPos); QWindow *window = topLevelAt(globalPos); if (!window) return; - const QPoint pos = globalPos - window->geometry().topLeft(); + const QPoint pos = nativeGlobalPos - window->handle()->geometry().topLeft(); const QPlatformDropQtResponse response = QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); if (response.isAccepted()) { diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 813b0f72bb..b273682b97 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -962,6 +962,13 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *window, const QPointF &local, con QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(window, timestamp, local * factor, global * factor, b, mods); } +// Wrapper for compatibility with Qt < 5.6 +// ### Qt6: Remove +Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) +{ + qt_handleMouseEvent(w, local, global, b, mods, QWindowSystemInterfacePrivate::eventTime.elapsed()); +} + Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(window, t, k, mods, text, autorep, count); |