diff options
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index fc328e7af0..dccd7ae2c8 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "private/qwindow_p.h" -#include "qwidgetwindow_qpa_p.h" +#include "qwidgetwindow_p.h" #include "private/qwidget_p.h" #include "private/qapplication_p.h" @@ -99,7 +99,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) setSurfaceType(QSurface::RasterGLSurface); } connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); - connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(repaintWindow())); + connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChange())); } QWidgetWindow::~QWidgetWindow() @@ -443,7 +443,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec() const QPoint localPos = win->mapFromGlobal(event->globalPos()); QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); - e->spont = 1; + QCoreApplicationPrivate::setEventSpontaneous(e, true); QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event)); e->setTimestamp(event->timestamp()); QCoreApplication::postEvent(win, e); @@ -558,8 +558,27 @@ void QWidgetWindow::updateGeometry() m_widget->data->fstrut_dirty = false; } -// Invalidates the backing store buffer and repaints immediately. -// ### Qt 5.4: replace with QUpdateWindowRequestEvent. +static void sendScreenChangeRecursively(QWidget *widget) +{ + QEvent e(QEvent::ScreenChangeInternal); + QApplication::sendEvent(widget, &e); + QWidgetPrivate *d = QWidgetPrivate::get(widget); + for (int i = 0; i < d->children.size(); ++i) { + QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); + if (w) + sendScreenChangeRecursively(w); + } +} + +void QWidgetWindow::handleScreenChange() +{ + // Send an event recursively to the widget and its children. + sendScreenChangeRecursively(m_widget); + + // Invalidate the backing store buffer and repaint immediately. + repaintWindow(); +} + void QWidgetWindow::repaintWindow() { if (!m_widget->isVisible() || !m_widget->updatesEnabled()) @@ -795,7 +814,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) QPointF mapped = qt_tablet_target->mapFromGlobal(event->globalPos()) + delta; QTabletEvent ev(event->type(), mapped, event->globalPosF(), event->device(), event->pointerType(), event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(), - event->rotation(), event->z(), event->modifiers(), event->uniqueId()); + event->rotation(), event->z(), event->modifiers(), event->uniqueId(), event->button(), event->buttons()); ev.setTimestamp(event->timestamp()); QGuiApplication::sendSpontaneousEvent(qt_tablet_target, &ev); } |