diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 26 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication_qpa.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qgesturemanager.cpp | 184 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow_qpa.cpp | 2 |
5 files changed, 102 insertions, 126 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 22589a4170..b910d21cb8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1965,12 +1965,11 @@ void QApplication::syncX() void QApplicationPrivate::notifyLayoutDirectionChange() { - Q_Q(QApplication); - QWidgetList list = q->topLevelWidgets(); + QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); QEvent ev(QEvent::ApplicationLayoutDirectionChange); - q->sendEvent(w, &ev); + QCoreApplication::sendEvent(w, &ev); } } @@ -2030,7 +2029,7 @@ void QApplication::setActiveWindow(QWidget* act) if (QApplicationPrivate::focus_widget) { if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); @@ -3913,13 +3912,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) */ /*! - \typedef QApplication::ColorMode - \compat - - Use ColorSpec instead. -*/ - -/*! \fn Qt::MacintoshVersion QApplication::macVersion() Use QSysInfo::MacintoshVersion instead. @@ -4011,18 +4003,6 @@ bool QApplicationPrivate::inPopupMode() const return QApplicationPrivate::popupWidgets != 0; } -/*! \variable QApplication::NormalColors - \compat - - Use \l NormalColor instead. -*/ - -/*! \variable QApplication::CustomColors - \compat - - Use \l CustomColor instead. -*/ - #ifdef QT_KEYPAD_NAVIGATION /*! Sets the kind of focus navigation Qt should use to \a mode. diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index da6a02a41d..74a299ba54 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -162,12 +162,11 @@ QWidget *qt_tlw_for_window(QWindow *wnd) void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) { Q_UNUSED(previous); - Q_Q(QApplication); QWindow *wnd = QGuiApplicationPrivate::focus_window; if (inPopupMode()) // some delayed focus event to ignore return; QWidget *tlw = qt_tlw_for_window(wnd); - q->setActiveWindow(tlw); + QApplication::setActiveWindow(tlw); } static void ungrabKeyboardForPopup(QWidget *popup) @@ -201,7 +200,6 @@ static void grabForPopup(QWidget *popup) void QApplicationPrivate::closePopup(QWidget *popup) { - Q_Q(QApplication); if (!popupWidgets) return; popupWidgets->removeAll(popup); @@ -241,7 +239,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) fw->setFocus(Qt::PopupFocusReason); } else { QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); - q->sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } } } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 296d8d31e7..f4bf667ef8 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -285,106 +285,104 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *, } } } - if (triggeredGestures.isEmpty() && finishedGestures.isEmpty() - && newMaybeGestures.isEmpty() && notGestures.isEmpty()) - return consumeEventHint; - - QSet<QGesture *> startedGestures = triggeredGestures - m_activeGestures; - triggeredGestures &= m_activeGestures; - - // check if a running gesture switched back to maybe state - QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures; - - // check if a maybe gesture switched to canceled - reset it but don't send an event - QSet<QGesture *> maybeToCanceledGestures = m_maybeGestures & notGestures; - - // check if a running gesture switched back to not gesture state, - // i.e. were canceled - QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; - - // new gestures in maybe state - m_maybeGestures += newMaybeGestures; - - // gestures that were in maybe state - QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures - | finishedGestures | canceledGestures - | notGestures); - m_maybeGestures -= notMaybeGestures; - - Q_ASSERT((startedGestures & finishedGestures).isEmpty()); - Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); - Q_ASSERT((startedGestures & canceledGestures).isEmpty()); - Q_ASSERT((finishedGestures & newMaybeGestures).isEmpty()); - Q_ASSERT((finishedGestures & canceledGestures).isEmpty()); - Q_ASSERT((canceledGestures & newMaybeGestures).isEmpty()); - - QSet<QGesture *> notStarted = finishedGestures - m_activeGestures; - if (!notStarted.isEmpty()) { - // there are some gestures that claim to be finished, but never started. - // probably those are "singleshot" gestures so we'll fake the started state. - foreach (QGesture *gesture, notStarted) + if (!triggeredGestures.isEmpty() || !finishedGestures.isEmpty() + || !newMaybeGestures.isEmpty() || !notGestures.isEmpty()) { + QSet<QGesture *> startedGestures = triggeredGestures - m_activeGestures; + triggeredGestures &= m_activeGestures; + + // check if a running gesture switched back to maybe state + QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures; + + // check if a maybe gesture switched to canceled - reset it but don't send an event + QSet<QGesture *> maybeToCanceledGestures = m_maybeGestures & notGestures; + + // check if a running gesture switched back to not gesture state, + // i.e. were canceled + QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; + + // new gestures in maybe state + m_maybeGestures += newMaybeGestures; + + // gestures that were in maybe state + QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures + | finishedGestures | canceledGestures + | notGestures); + m_maybeGestures -= notMaybeGestures; + + Q_ASSERT((startedGestures & finishedGestures).isEmpty()); + Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); + Q_ASSERT((startedGestures & canceledGestures).isEmpty()); + Q_ASSERT((finishedGestures & newMaybeGestures).isEmpty()); + Q_ASSERT((finishedGestures & canceledGestures).isEmpty()); + Q_ASSERT((canceledGestures & newMaybeGestures).isEmpty()); + + QSet<QGesture *> notStarted = finishedGestures - m_activeGestures; + if (!notStarted.isEmpty()) { + // there are some gestures that claim to be finished, but never started. + // probably those are "singleshot" gestures so we'll fake the started state. + foreach (QGesture *gesture, notStarted) + gesture->d_func()->state = Qt::GestureStarted; + QSet<QGesture *> undeliveredGestures; + deliverEvents(notStarted, &undeliveredGestures); + finishedGestures -= undeliveredGestures; + } + + m_activeGestures += startedGestures; + // sanity check: all triggered gestures should already be in active gestures list + Q_ASSERT((m_activeGestures & triggeredGestures).size() == triggeredGestures.size()); + m_activeGestures -= finishedGestures; + m_activeGestures -= activeToMaybeGestures; + m_activeGestures -= canceledGestures; + + // set the proper gesture state on each gesture + foreach (QGesture *gesture, startedGestures) gesture->d_func()->state = Qt::GestureStarted; - QSet<QGesture *> undeliveredGestures; - deliverEvents(notStarted, &undeliveredGestures); - finishedGestures -= undeliveredGestures; - } + foreach (QGesture *gesture, triggeredGestures) + gesture->d_func()->state = Qt::GestureUpdated; + foreach (QGesture *gesture, finishedGestures) + gesture->d_func()->state = Qt::GestureFinished; + foreach (QGesture *gesture, canceledGestures) + gesture->d_func()->state = Qt::GestureCanceled; + foreach (QGesture *gesture, activeToMaybeGestures) + gesture->d_func()->state = Qt::GestureFinished; + + if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || + !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || + !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { + DEBUG() << "QGestureManager::filterEventThroughContexts:" + << "\n\tactiveGestures:" << m_activeGestures + << "\n\tmaybeGestures:" << m_maybeGestures + << "\n\tstarted:" << startedGestures + << "\n\ttriggered:" << triggeredGestures + << "\n\tfinished:" << finishedGestures + << "\n\tcanceled:" << canceledGestures + << "\n\tmaybe-canceled:" << maybeToCanceledGestures; + } - m_activeGestures += startedGestures; - // sanity check: all triggered gestures should already be in active gestures list - Q_ASSERT((m_activeGestures & triggeredGestures).size() == triggeredGestures.size()); - m_activeGestures -= finishedGestures; - m_activeGestures -= activeToMaybeGestures; - m_activeGestures -= canceledGestures; - - // set the proper gesture state on each gesture - foreach (QGesture *gesture, startedGestures) - gesture->d_func()->state = Qt::GestureStarted; - foreach (QGesture *gesture, triggeredGestures) - gesture->d_func()->state = Qt::GestureUpdated; - foreach (QGesture *gesture, finishedGestures) - gesture->d_func()->state = Qt::GestureFinished; - foreach (QGesture *gesture, canceledGestures) - gesture->d_func()->state = Qt::GestureCanceled; - foreach (QGesture *gesture, activeToMaybeGestures) - gesture->d_func()->state = Qt::GestureFinished; - - if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || - !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || - !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { - DEBUG() << "QGestureManager::filterEventThroughContexts:" - << "\n\tactiveGestures:" << m_activeGestures - << "\n\tmaybeGestures:" << m_maybeGestures - << "\n\tstarted:" << startedGestures - << "\n\ttriggered:" << triggeredGestures - << "\n\tfinished:" << finishedGestures - << "\n\tcanceled:" << canceledGestures - << "\n\tmaybe-canceled:" << maybeToCanceledGestures; - } + QSet<QGesture *> undeliveredGestures; + deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, + &undeliveredGestures); - QSet<QGesture *> undeliveredGestures; - deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, - &undeliveredGestures); - - foreach (QGesture *g, startedGestures) { - if (undeliveredGestures.contains(g)) - continue; - if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { - DEBUG() << "lets try to cancel some"; - // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them - cancelGesturesForChildren(g); + foreach (QGesture *g, startedGestures) { + if (undeliveredGestures.contains(g)) + continue; + if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { + DEBUG() << "lets try to cancel some"; + // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them + cancelGesturesForChildren(g); + } } - } - m_activeGestures -= undeliveredGestures; + m_activeGestures -= undeliveredGestures; - // reset gestures that ended - QSet<QGesture *> endedGestures = - finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; - foreach (QGesture *gesture, endedGestures) { - recycle(gesture); - m_gestureTargets.remove(gesture); + // reset gestures that ended + QSet<QGesture *> endedGestures = + finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; + foreach (QGesture *gesture, endedGestures) { + recycle(gesture); + m_gestureTargets.remove(gesture); + } } - //Clean up the Gestures qDeleteAll(m_gesturesToDelete); m_gesturesToDelete.clear(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 8e6e4368e8..3ab777ad60 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -3090,7 +3090,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) qApp->inputMethod()->update(Qt::ImEnabled); } else { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } } @@ -5948,7 +5948,7 @@ void QWidget::setFocus(Qt::FocusReason reason) if (prev) { if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason && prev->testAttribute(Qt::WA_InputMethodEnabled)) { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); } if (reason != Qt::NoFocusReason) { @@ -6057,7 +6057,7 @@ void QWidget::clearFocus() { if (hasFocus()) { if (testAttribute(Qt::WA_InputMethodEnabled)) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); QApplication::sendEvent(this, &focusAboutToChange); @@ -10087,7 +10087,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) QWidget *focusWidget = d->effectiveFocusWidget(); if (on && !internalWinId() && hasFocus() && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget() @@ -10137,7 +10137,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) #ifndef QT_NO_IM if (qApp->focusObject() == this) { if (!on) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } #endif //QT_NO_IM diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 4723901625..40b6f486be 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -374,7 +374,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(m_widget, event->pos()); - QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->pixelDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); + QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(widget, &translated); } |