diff options
Diffstat (limited to 'src/gui/kernel')
| -rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 29 | ||||
| -rw-r--r-- | src/gui/kernel/qinputdevicemanager_p.h | 2 | ||||
| -rw-r--r-- | src/gui/kernel/qplatformdialoghelper.cpp | 2 | ||||
| -rw-r--r-- | src/gui/kernel/qplatformintegration.cpp | 2 | ||||
| -rw-r--r-- | src/gui/kernel/qplatformintegration.h | 3 | ||||
| -rw-r--r-- | src/gui/kernel/qplatformscreen.cpp | 49 | ||||
| -rw-r--r-- | src/gui/kernel/qplatformscreen.h | 10 | ||||
| -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/qstylehints.cpp | 31 | ||||
| -rw-r--r-- | src/gui/kernel/qstylehints.h | 4 | ||||
| -rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 7 |
14 files changed, 168 insertions, 31 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 3438fc0dcd..e4eabc815e 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); } } @@ -2470,7 +2474,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QWindow *window = e->window.data(); typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; - bool velocityOnly = false; + bool stationaryTouchPointChangedVelocity = false; for (int i = 0; i < e->points.count(); ++i) { QTouchEvent::TouchPoint touchPoint = e->points.at(i); @@ -2550,7 +2554,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (touchPoint.state() == Qt::TouchPointStationary) { if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) { touchInfo.touchPoint.setVelocity(touchPoint.velocity()); - velocityOnly = true; + stationaryTouchPointChangedVelocity = true; } } else { touchInfo.touchPoint = touchPoint; @@ -2591,10 +2595,9 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To break; case Qt::TouchPointStationary: // don't send the event if nothing changed - if (velocityOnly) - eventType = QEvent::TouchUpdate; - else + if (!stationaryTouchPointChangedVelocity) continue; + Q_FALLTHROUGH(); default: eventType = QEvent::TouchUpdate; break; 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/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index 16f31db50d..01cf98c7c9 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -278,7 +278,7 @@ void QColorDialogStaticData::readSettings() void QColorDialogStaticData::writeSettings() const { #ifndef QT_NO_SETTINGS - if (!customSet) { + if (customSet) { QSettings settings(QSettings::UserScope, QStringLiteral("QtProject")); for (int i = 0; i < int(CustomColorCount); ++i) settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), customRgb[i]); diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index fd7f475bee..fe1861e08b 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -409,6 +409,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick); case UiEffects: return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects); + case WheelScrollLines: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 22a834f0e1..466b3348bd 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -157,7 +157,8 @@ public: TabFocusBehavior, ReplayMousePressOutsidePopup, ItemViewActivateItemOnSingleClick, - UiEffects + UiEffects, + WheelScrollLines, }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index bbe984bebe..e22037c1e9 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -533,4 +533,53 @@ void QPlatformScreen::setPowerState(PowerState state) Q_UNUSED(state); } +/*! + Reimplement this function in subclass to return the list + of modes for this screen. + + The default implementation returns a list with + only one mode from the current screen size and refresh rate. + + \sa QPlatformScreen::geometry + \sa QPlatformScreen::refreshRate + + \since 5.9 +*/ +QVector<QPlatformScreen::Mode> QPlatformScreen::modes() const +{ + QVector<QPlatformScreen::Mode> list; + list.append({geometry().size(), refreshRate()}); + return list; +} + +/*! + Reimplement this function in subclass to return the + index of the current mode from the modes list. + + The default implementation returns 0. + + \sa QPlatformScreen::modes + + \since 5.9 +*/ +int QPlatformScreen::currentMode() const +{ + return 0; +} + +/*! + Reimplement this function in subclass to return the preferred + mode index from the modes list. + + The default implementation returns 0. + + \sa QPlatformScreen::modes + + \since 5.9 +*/ +int QPlatformScreen::preferredMode() const +{ + return 0; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index aa32917b6c..97fe3fed03 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -95,6 +95,11 @@ public: PowerStateOff }; + struct Mode { + QSize size; + qreal refreshRate; + }; + QPlatformScreen(); virtual ~QPlatformScreen(); @@ -139,6 +144,11 @@ public: virtual PowerState powerState() const; virtual void setPowerState(PowerState state); + virtual QVector<Mode> modes() const; + + virtual int currentMode() const; + virtual int preferredMode() const; + static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b); static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target); static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect); 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/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 22c077da41..85c0768e35 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -78,6 +78,7 @@ public: , m_cursorFlashTime(-1) , m_tabFocusBehavior(-1) , m_uiEffects(-1) + , m_wheelScrollLines(-1) {} int m_mouseDoubleClickInterval; @@ -88,6 +89,7 @@ public: int m_cursorFlashTime; int m_tabFocusBehavior; int m_uiEffects; + int m_wheelScrollLines; }; /*! @@ -495,4 +497,33 @@ void QStyleHints::setUseHoverEffects(bool useHoverEffects) emit useHoverEffectsChanged(useHoverEffects); } +/*! + \property QStyleHints::wheelScrollLines + \brief Number of lines to scroll by default for each wheel click. + + \since 5.9 +*/ +int QStyleHints::wheelScrollLines() const +{ + Q_D(const QStyleHints); + if (d->m_wheelScrollLines > 0) + return d->m_wheelScrollLines; + return themeableHint(QPlatformTheme::WheelScrollLines, QPlatformIntegration::WheelScrollLines).toInt(); +} + +/*! + Sets the \a wheelScrollLines. + \internal + \sa wheelScrollLines() + \since 5.9 +*/ +void QStyleHints::setWheelScrollLines(int scrollLines) +{ + Q_D(QStyleHints); + if (d->m_wheelScrollLines == scrollLines) + return; + d->m_wheelScrollLines = scrollLines; + emit wheelScrollLinesChanged(scrollLines); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index fb55cc7ed6..b9bf428edd 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -71,6 +71,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL) Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL) Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL) + Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); @@ -99,6 +100,8 @@ public: bool singleClickActivation() const; bool useHoverEffects() const; void setUseHoverEffects(bool useHoverEffects); + int wheelScrollLines() const; + void setWheelScrollLines(int scrollLines); Q_SIGNALS: void cursorFlashTimeChanged(int cursorFlashTime); @@ -109,6 +112,7 @@ Q_SIGNALS: void startDragTimeChanged(int startDragTime); void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior); void useHoverEffectsChanged(bool useHoverEffects); + void wheelScrollLinesChanged(int scrollLines); private: friend class QGuiApplication; 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); |
