summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-12 13:30:20 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-18 10:05:55 +0200
commitadd7c0aadd5b4195f39a7a547f2f5b2fa36636f0 (patch)
tree297d6c85ee59ce286801bfda4439ff07d82bb6e0
parent40d59496fb718614f78b737fc2ebc271af657280 (diff)
Propagate swap interval from QOpenGLWidget to the tlw
Otherwise it is impossible to set a swap interval different than the one set by QSurfaceFormat::setDefaultFormat(). Both windows and xcb will pick up the updated interval from the window on the next frame. Change-Id: I55a59f83a62d3adcea687adf28639646b576ed58 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 22ea852d99..2abddd8941 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -587,7 +587,8 @@ void QOpenGLWidgetPrivate::initialize()
// Get our toplevel's context with which we will share in order to make the
// texture usable by the underlying window's backingstore.
- QOpenGLContext *shareContext = get(q->window())->shareContext();
+ QWidget *tlw = q->window();
+ QOpenGLContext *shareContext = get(tlw)->shareContext();
if (!shareContext) {
qWarning("QOpenGLWidget: Cannot be used without a context shared with the toplevel.");
return;
@@ -601,6 +602,19 @@ void QOpenGLWidgetPrivate::initialize()
return;
}
+ // Propagate settings that make sense only for the tlw.
+ QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
+ if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
+ // Most platforms will pick up the changed swap interval on the next
+ // makeCurrent or swapBuffers.
+ tlwFormat.setSwapInterval(requestedFormat.swapInterval());
+ tlw->windowHandle()->setFormat(tlwFormat);
+ }
+ if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
+ tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
+ tlw->windowHandle()->setFormat(tlwFormat);
+ }
+
// The top-level window's surface is not good enough since it causes way too
// much trouble with regards to the QSurfaceFormat for example. So just like
// in QQuickWidget, use a dedicated QOffscreenSurface.