diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 25 | ||||
-rw-r--r-- | src/widgets/kernel/qgesturemanager.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qlayout.cpp | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qtooltip.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwhatsthis.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 19 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 7 | ||||
-rw-r--r-- | src/widgets/kernel/win.pri | 5 |
11 files changed, 52 insertions, 39 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 1d26fb6697..ba8878be57 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1721,7 +1721,7 @@ QWidgetList QApplication::topLevelWidgets() QWidgetList QApplication::allWidgets() { if (QWidgetPrivate::allWidgets) - return QWidgetPrivate::allWidgets->toList(); + return QWidgetPrivate::allWidgets->values(); return QWidgetList(); } @@ -1900,8 +1900,8 @@ void QApplication::aboutQt() This signal is emitted when the widget that has keyboard focus changed from \a old to \a now, i.e., because the user pressed the tab-key, clicked into - a widget or changed the active window. Both \a old and \a now can be the - null-pointer. + a widget or changed the active window. Both \a old and \a now can be \nullptr. + The signal is emitted after both widget have been notified about the change through QFocusEvent. @@ -3696,14 +3696,17 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) // to the ones in QCoreApplicationPrivate::notify_helper; the reason for their // duplication is because tracepoint symbols are not exported by QtCore. // If you adjust the tracepoints here, consider adjusting QCoreApplicationPrivate too. - Q_TRACE_SCOPE(QApplication_notify, receiver, e, e->type()); + Q_TRACE(QApplication_notify_entry, receiver, e, e->type()); + bool consumed = false; + bool filtered = false; + Q_TRACE_EXIT(QApplication_notify_exit, consumed, filtered); // send to all application event filters if (threadRequiresCoreApplication() && receiver->d_func()->threadData->thread == mainThread() && sendThroughApplicationEventFilters(receiver, e)) { - Q_TRACE(QApplication_notify_event_filtered, receiver, e, e->type()); - return true; + filtered = true; + return filtered; } if (receiver->isWidgetType()) { @@ -3725,16 +3728,12 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) // send to all receiver event filters if (sendThroughObjectEventFilters(receiver, e)) { - Q_TRACE(QApplication_notify_event_filtered, receiver, e, e->type()); - return true; + filtered = true; + return filtered; } - Q_TRACE(QApplication_notify_before_delivery, receiver, e, e->type()); - // deliver the event - const bool consumed = receiver->event(e); - - Q_TRACE(QApplication_notify_after_delivery, receiver, e, e->type(), consumed); + consumed = receiver->event(e); QCoreApplicationPrivate::setEventSpontaneous(e, false); return consumed; diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index cd27c9c5be..7632521117 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -171,7 +171,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object) { - QSet<QGesture *> gestures = iter.value().toSet(); + QSet<QGesture *> gestures = QSet<QGesture *>(iter.value().constBegin(), iter.value().constEnd()); for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { it.value() -= gestures; @@ -509,14 +509,14 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) // return true if accepted (consumed) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { - QMap<Qt::GestureType, int> types; + QVarLengthArray<Qt::GestureType, 16> types; QMultiMap<QObject *, Qt::GestureType> contexts; QWidget *w = receiver; typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { for(ContextIterator it = w->d_func()->gestureContext.constBegin(), e = w->d_func()->gestureContext.constEnd(); it != e; ++it) { - types.insert(it.key(), 0); + types.push_back(it.key()); contexts.insert(w, it.key()); } } @@ -528,7 +528,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) e = w->d_func()->gestureContext.constEnd(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { - types.insert(it.key(), 0); + types.push_back(it.key()); contexts.insert(w, it.key()); } } @@ -543,14 +543,14 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) #if QT_CONFIG(graphicsview) bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { - QMap<Qt::GestureType, int> types; + QVarLengthArray<Qt::GestureType, 16> types; QMultiMap<QObject *, Qt::GestureType> contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator ContextIterator; for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.constBegin(), e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) { - types.insert(it.key(), 0); + types.push_back(it.key()); contexts.insert(item, it.key()); } } @@ -563,7 +563,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) e = item->QGraphicsItem::d_func()->gestureContext.constEnd(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { - types.insert(it.key(), 0); + types.push_back(it.key()); contexts.insert(item, it.key()); } } diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index e3f6a56875..f71d038a5f 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -109,7 +109,7 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) /*! Constructs a new top-level QLayout, with parent \a parent. - \a parent may not be a \nullptr. + \a parent may not be \nullptr. The layout is set directly as the top-level layout for \a parent. There can be only one top-level layout for a @@ -419,9 +419,9 @@ void QLayout::setContentsMargins(const QMargins &margins) /*! \since 4.3 - Extracts the left, top, right, and bottom margins used around the - layout, and assigns them to *\a left, *\a top, *\a right, and *\a - bottom (unless they are null pointers). + For each of \a left, \a top, \a right and \a bottom that is not + \nullptr, stores the size of the margin named in the location the + pointer refers to. By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions. @@ -1156,6 +1156,8 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt Q_D(QLayout); if (!from || !to) return 0; + if (from == to) // Do not return a QLayoutItem for \a from, since ownership still + return nullptr; // belongs to the layout (since nothing was changed) int index = -1; QLayoutItem *item = 0; diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index cf15614680..374ea53726 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -1448,7 +1448,8 @@ bool QOpenGLWidget::event(QEvent *e) { // Special case: did grabFramebuffer() for a hidden widget that then became visible. // Recreate all resources since the context now needs to share with the TLW's. - d->reset(); + if (!qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + d->reset(); } if (!d->initialized && !size().isEmpty() && window()->windowHandle()) { d->initialize(); diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h index edf1de0c1d..1b263a6629 100644 --- a/src/widgets/kernel/qtooltip.h +++ b/src/widgets/kernel/qtooltip.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE class Q_WIDGETS_EXPORT QToolTip { - QToolTip() Q_DECL_EQ_DELETE; + QToolTip() = delete; public: // ### Qt 6 - merge the three showText functions below static void showText(const QPoint &pos, const QString &text, QWidget *w = nullptr); diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h index 59c0b01c9b..fa5b97d98a 100644 --- a/src/widgets/kernel/qwhatsthis.h +++ b/src/widgets/kernel/qwhatsthis.h @@ -54,7 +54,7 @@ class QAction; class Q_WIDGETS_EXPORT QWhatsThis { - QWhatsThis() Q_DECL_EQ_DELETE; + QWhatsThis() = delete; public: static void enterWhatsThisMode(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 74b18d9991..8f927e8bee 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2578,14 +2578,15 @@ void QWidgetPrivate::createWinId() /*! \internal Ensures that the widget is set on the screen point is on. This is handy getting a correct -size hint before a resize in e.g QMenu and QToolTip +size hint before a resize in e.g QMenu and QToolTip. +Returns if the screen was changed. */ -void QWidgetPrivate::setScreenForPoint(const QPoint &pos) +bool QWidgetPrivate::setScreenForPoint(const QPoint &pos) { Q_Q(QWidget); if (!q->isWindow()) - return; + return false; // Find the screen for pos and make the widget undertand it is on that screen. const QScreen *currentScreen = windowHandle() ? windowHandle()->screen() : nullptr; QScreen *actualScreen = QGuiApplication::screenAt(pos); @@ -2594,7 +2595,9 @@ void QWidgetPrivate::setScreenForPoint(const QPoint &pos) createWinId(); if (windowHandle()) windowHandle()->setScreen(actualScreen); + return true; } + return false; } /*! @@ -9356,6 +9359,12 @@ bool QWidget::event(QEvent *event) d->renderToTextureReallyDirty = 1; #endif break; + case QEvent::PlatformSurface: { + auto surfaceEvent = static_cast<QPlatformSurfaceEvent*>(event); + if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) + d->setWinId(0); + break; + } #ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: { const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); @@ -13180,7 +13189,7 @@ QDebug operator<<(QDebug debug, const QWidget *widget) if (widget->isWindow()) debug << ", window"; debug << ", " << geometry.width() << 'x' << geometry.height() - << forcesign << geometry.x() << geometry.y() << noforcesign; + << Qt::forcesign << geometry.x() << geometry.y() << Qt::noforcesign; if (frameGeometry != geometry) { const QMargins margins(geometry.x() - frameGeometry.x(), geometry.y() - frameGeometry.y(), @@ -13190,7 +13199,7 @@ QDebug operator<<(QDebug debug, const QWidget *widget) } debug << ", devicePixelRatio=" << widget->devicePixelRatioF(); if (const WId wid = widget->internalWinId()) - debug << ", winId=0x" << hex << wid << dec; + debug << ", winId=0x" << Qt::hex << wid << Qt::dec; } debug << ')'; } else { diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index aec3eee639..e47deb5d0d 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -555,7 +555,7 @@ public: void addAction(QAction *action); #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void addActions(const QList<QAction*> &actions); - void insertActions(const QAction *before, const QList<QAction*> &actions); + void insertActions(QAction *before, const QList<QAction*> &actions); #else void addActions(QList<QAction*> actions); void insertActions(QAction *before, QList<QAction*> actions); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 90c4c2a945..c073b8fb03 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -355,7 +355,7 @@ public: void createRecursively(); void createWinId(); - void setScreenForPoint(const QPoint &pos); + bool setScreenForPoint(const QPoint &pos); void createTLExtra(); void createExtra(); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 5bcf885dfe..70b305326c 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -222,10 +222,9 @@ static inline bool shouldBePropagatedToWidget(QEvent *event) } } -bool QWidgetWindowPrivate::allowClickThrough(const QPoint &globalPos) const +bool QWidgetWindowPrivate::allowClickThrough(const QPoint &) const { - QWidget *w = QApplication::widgetAt(globalPos); - return w && !w->testAttribute(Qt::WA_MacNoClickThrough); + return true; } bool QWidgetWindow::event(QEvent *event) @@ -1107,7 +1106,7 @@ void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e) } } if (fw && fw->isEnabled()) { - QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center(); + QPoint pos = fw->inputMethodQuery(Qt::ImCursorRectangle).toRect().center(); QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos), e->modifiers()); QGuiApplication::forwardEvent(fw, &widgetEvent, e); diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri index f6877b02db..3b3170beb1 100644 --- a/src/widgets/kernel/win.pri +++ b/src/widgets/kernel/win.pri @@ -2,4 +2,7 @@ # -------------------------------------------------------------------- INCLUDEPATH += ../3rdparty/wintab -!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi +!winrt { + LIBS_PRIVATE *= -luxtheme -ldwmapi + QMAKE_USE_PRIVATE += shell32 +} |