diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 29 | ||||
-rw-r--r-- | src/widgets/kernel/qtooltip.cpp | 13 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 19 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 4 |
4 files changed, 44 insertions, 21 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6fcfcf1b1ef..53ce4dd8211 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1432,8 +1432,8 @@ void QApplicationPrivate::notifyWindowIconChanged() // in case there are any plain QWindows in this QApplication-using // application, also send the notification to them - for (int i = 0; i < windowList.size(); ++i) - QCoreApplication::sendEvent(windowList.at(i), &ev); + for (QWindow *w : std::as_const(windowList)) + QCoreApplication::sendEvent(w, &ev); } /*! @@ -1774,9 +1774,9 @@ void QApplicationPrivate::notifyLayoutDirectionChange() // in case there are any plain QWindows in this QApplication-using // application, also send the notification to them - for (int i = 0; i < windowList.size(); ++i) { + for (QWindow *w: std::as_const(windowList)) { QEvent ev(QEvent::ApplicationLayoutDirectionChange); - QCoreApplication::sendEvent(windowList.at(i), &ev); + QCoreApplication::sendEvent(w, &ev); } } @@ -1863,14 +1863,12 @@ void QApplicationPrivate::setActiveWindow(QWidget* act) QEvent windowActivate(QEvent::WindowActivate); QEvent windowDeactivate(QEvent::WindowDeactivate); - for (int i = 0; i < toBeActivated.size(); ++i) { - QWidget *w = toBeActivated.at(i); + for (QWidget *w : std::as_const(toBeActivated)) { QApplication::sendSpontaneousEvent(w, &windowActivate); QApplication::sendSpontaneousEvent(w, &activationChange); } - for(int i = 0; i < toBeDeactivated.size(); ++i) { - QWidget *w = toBeDeactivated.at(i); + for (QWidget *w : std::as_const(toBeDeactivated)) { QApplication::sendSpontaneousEvent(w, &windowDeactivate); QApplication::sendSpontaneousEvent(w, &activationChange); } @@ -2082,8 +2080,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con } QEvent leaveEvent(QEvent::Leave); - for (int i = 0; i < leaveList.size(); ++i) { - auto *w = leaveList.at(i); + for (QWidget *w : std::as_const(leaveList)) { if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) { QCoreApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && @@ -2125,8 +2122,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con // Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor. // This is not required on Windows as the cursor is reset on every single mouse move. QWidget *parentOfLeavingCursor = nullptr; - for (int i = 0; i < leaveList.size(); ++i) { - auto *w = leaveList.at(i); + for (QWidget *w : std::as_const(leaveList)) { if (!isAlien(w)) break; if (w->testAttribute(Qt::WA_SetCursor)) { @@ -3085,7 +3081,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) const QPoint offset = w->pos(); w = w->parentWidget(); QMutableTouchEvent::setTarget(touchEvent, w); - for (int i = 0; i < touchEvent->pointCount(); ++i) { + for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) { auto &pt = touchEvent->point(i); QMutableEventPoint::setPosition(pt, pt.position() + offset); } @@ -3164,8 +3160,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) res = d->notify_helper(w, &ge); gestureEvent->m_spont = false; eventAccepted = ge.isAccepted(); - for (int i = 0; i < gestures.size(); ++i) { - QGesture *g = gestures.at(i); + for (QGesture *g : std::as_const(gestures)) { // Ignore res [event return value] because handling of multiple gestures // packed into a single QEvent depends on not consuming the event if (eventAccepted || ge.isAccepted(g)) { @@ -3708,7 +3703,7 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven { bool containsPress = false; - for (int i = 0; i < touchEvent->pointCount(); ++i) { + for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) { auto &pt = touchEvent->point(i); QMutableEventPoint::setPosition(pt, widget->mapFromGlobal(pt.globalPosition())); @@ -3768,7 +3763,7 @@ void QApplicationPrivate::activateImplicitTouchGrab(QWidget *widget, QTouchEvent // If the widget dispatched the event further (see QGraphicsProxyWidget), then // there might already be an implicit grabber. Don't override that. A widget that // has partially recognized a gesture needs to grab all points. - for (int i = 0; i < touchEvent->pointCount(); ++i) { + for (qsizetype cnt = touchEvent->pointCount(), i = 0; i < cnt; ++i) { auto &ep = touchEvent->point(i); if (!QMutableEventPoint::target(ep) && (ep.isAccepted() || grabMode == GrabAllPoints)) QMutableEventPoint::setTarget(ep, widget); diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 9e6aaf4b95f..d989feb7f91 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -20,6 +20,8 @@ #if QT_CONFIG(style_stylesheet) #include <private/qstylesheetstyle_p.h> #endif +#include <qpa/qplatformwindow.h> +#include <qpa/qplatformwindow_p.h> #include <qlabel.h> #include <QtWidgets/private/qlabel_p.h> @@ -386,6 +388,17 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) p += offset; +#if QT_CONFIG(wayland) + create(); + if (auto waylandWindow = dynamic_cast<QNativeInterface::Private::QWaylandWindow*>(windowHandle()->handle())) { + // based on the existing code below, by default position at 'p' stored at the bottom right of our rect + // then flip to the other arbitrary 4x24 space if constrained + const QRect controlGeometry(QRect(p.x() - 4, p.y() - 24, 4, 24)); + waylandWindow->setParentControlGeometry(controlGeometry); + waylandWindow->setExtendedWindowType(QNativeInterface::Private::QWaylandWindow::ToolTip); + } +#endif + QRect screenRect = screen->geometry(); if (p.x() + this->width() > screenRect.x() + screenRect.width()) p.rx() -= 4 + this->width(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 36446c3e5c4..9499c88af12 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -13144,11 +13144,22 @@ int QWidget::metric(PaintDeviceMetric m) const void QWidget::initPainter(QPainter *painter) const { const QPalette &pal = palette(); - painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1); - painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); + QPainterPrivate *painterPrivate = QPainterPrivate::get(painter); + + painterPrivate->state->pen = QPen(pal.brush(foregroundRole()), 1); + painterPrivate->state->bgBrush = pal.brush(backgroundRole()); QFont f(font(), this); - painter->d_func()->state->deviceFont = f; - painter->d_func()->state->font = f; + painterPrivate->state->deviceFont = f; + painterPrivate->state->font = f; + + painterPrivate->setEngineDirtyFlags({ + QPaintEngine::DirtyPen, + QPaintEngine::DirtyBrush, + QPaintEngine::DirtyFont, + }); + + if (painterPrivate->extended) + painterPrivate->extended->penChanged(); } /*! diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 737ccb0e807..622f1548756 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -591,6 +591,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) } } + // Event delivery above might have destroyed this object. See QTBUG-138419. + if (self.isNull()) + return; + if (QApplication::activePopupWidget() != activePopupWidget && QApplicationPrivate::replayMousePress && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { |