summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidgetwindow.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-10 11:42:55 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-10 20:20:05 +0200
commit49194275e02a9d6373767d6485bd8ebeeb0abba5 (patch)
treeae3054b67dd6eb05793bf0a6c6bf51622d302482 /src/widgets/kernel/qwidgetwindow.cpp
parent8610534f53b228d996279e1208fcf3ec0f125398 (diff)
Expose screen change event to widgets so that they can check the dpr
Unlike ordinary widgets, the ones that have OpenGL framebuffers must know about screen changes because the device pixel ratio may be different on the new screen. Add an internal event, ScreenChangeInternal, as the counterpart to WindowChangeInternal. Change-Id: I5e55999838e4c0284e7d9832299f7cc6b541ee3f Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index b255bc16f9..dccd7ae2c8 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -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()
@@ -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())