diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f43329afd0..51653d9f8a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -164,8 +164,6 @@ QString *QGuiApplicationPrivate::desktopFileName = 0; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette -Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; - ulong QGuiApplicationPrivate::mousePressTime = 0; Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; int QGuiApplicationPrivate::mousePressX = 0; @@ -570,6 +568,15 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. \li \c {fontengine=freetype}, uses the FreeType font engine. + \li \c {menus=[native|none]}, controls the use of native menus. + + Native menus are implemented using Win32 API and are simpler than + QMenu-based menus in for example that they do allow for placing + widgets on them or changing properties like fonts and do not + provide hover signals. They are mainly intended for Qt Quick. + By default, they will be used if the application is not an + instance of QApplication or for Qt Quick Controls 2 + applications. \endlist For more information about the platform-specific arguments available for @@ -1838,7 +1845,7 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) { QEvent::Type type; - Qt::MouseButtons stateChange = e->buttons ^ buttons; + Qt::MouseButtons stateChange = e->buttons ^ mouse_buttons; if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { // A mouse event should not change both position and buttons at the same time. Instead we // should first send a move event followed by a button changed event. Since this is not the case @@ -1847,7 +1854,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source); if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic) mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; - e->buttons = buttons; + e->buttons = mouse_buttons; processMouseEvent(e); processMouseEvent(&mouseButtonEvent); return; @@ -1901,7 +1908,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo // Ignore mouse events that don't change the current state. return; } - mouse_buttons = buttons = e->buttons; + mouse_buttons = e->buttons; if (button & e->buttons) { ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval()); doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton; @@ -1926,14 +1933,14 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo const QPointF nativeLocalPoint = QHighDpi::toNativePixels(localPoint, screen); const QPointF nativeGlobalPoint = QHighDpi::toNativePixels(globalPoint, screen); QMouseEvent ev(type, nativeLocalPoint, nativeLocalPoint, nativeGlobalPoint, - button, buttons, e->modifiers, e->source); + button, mouse_buttons, e->modifiers, e->source); ev.setTimestamp(e->timestamp); cursor->pointerEvent(ev); } } #endif - QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source); + QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, mouse_buttons, e->modifiers, e->source); ev.setTimestamp(e->timestamp); if (window->d_func()->blockedByModalWindow && !qApp->d_func()->popupActive()) { @@ -1967,7 +1974,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo point.state = Qt::TouchPointPressed; } else if (type == QEvent::MouseButtonRelease && button == Qt::LeftButton) { point.state = Qt::TouchPointReleased; - } else if (type == QEvent::MouseMove && (buttons & Qt::LeftButton)) { + } else if (type == QEvent::MouseMove && (mouse_buttons & Qt::LeftButton)) { point.state = Qt::TouchPointMoved; } else { return; @@ -1988,7 +1995,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick; QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, - button, buttons, e->modifiers, e->source); + button, mouse_buttons, e->modifiers, e->source); dblClickEvent.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent); } @@ -2022,7 +2029,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh } QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, - buttons, e->modifiers, e->phase, e->source, e->inverted); + mouse_buttons, e->modifiers, e->phase, e->source, e->inverted); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); #else @@ -2479,7 +2486,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To e->timestamp, synthIt->pos, synthIt->screenPos, - buttons & ~Qt::LeftButton, + mouse_buttons & ~Qt::LeftButton, e->modifiers, Qt::MouseEventSynthesizedByQt); fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; @@ -2694,7 +2701,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, touchPoint.pos(), touchPoint.screenPos(), - b | (buttons & ~Qt::LeftButton), + b | (mouse_buttons & ~Qt::LeftButton), e->modifiers, Qt::MouseEventSynthesizedByQt); fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; @@ -3534,6 +3541,22 @@ static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) } } +static inline void applyOverrideCursor(const QList<QScreen *> &screens, const QCursor &c) +{ + for (QScreen *screen : screens) { + if (QPlatformCursor *cursor = screen->handle()->cursor()) + cursor->setOverrideCursor(c); + } +} + +static inline void clearOverrideCursor(const QList<QScreen *> &screens) +{ + for (QScreen *screen : screens) { + if (QPlatformCursor *cursor = screen->handle()->cursor()) + cursor->clearOverrideCursor(); + } +} + static inline void applyWindowCursor(const QList<QWindow *> &l) { for (int i = 0; i < l.size(); ++i) { @@ -3578,7 +3601,10 @@ void QGuiApplication::setOverrideCursor(const QCursor &cursor) { CHECK_QAPP_INSTANCE() qGuiApp->d_func()->cursor_list.prepend(cursor); - applyCursor(QGuiApplicationPrivate::window_list, cursor); + if (QPlatformCursor::capabilities().testFlag(QPlatformCursor::OverrideCursor)) + applyOverrideCursor(QGuiApplicationPrivate::screen_list, cursor); + else + applyCursor(QGuiApplicationPrivate::window_list, cursor); } /*! @@ -3600,9 +3626,15 @@ void QGuiApplication::restoreOverrideCursor() qGuiApp->d_func()->cursor_list.removeFirst(); if (qGuiApp->d_func()->cursor_list.size() > 0) { QCursor c(qGuiApp->d_func()->cursor_list.value(0)); - applyCursor(QGuiApplicationPrivate::window_list, c); + if (QPlatformCursor::capabilities().testFlag(QPlatformCursor::OverrideCursor)) + applyOverrideCursor(QGuiApplicationPrivate::screen_list, c); + else + applyCursor(QGuiApplicationPrivate::window_list, c); } else { - applyWindowCursor(QGuiApplicationPrivate::window_list); + if (QPlatformCursor::capabilities().testFlag(QPlatformCursor::OverrideCursor)) + clearOverrideCursor(QGuiApplicationPrivate::screen_list); + else + applyWindowCursor(QGuiApplicationPrivate::window_list); } } #endif// QT_NO_CURSOR |