From 19d1eb06b33237426e643b21ab1122b2aaff3a8c Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 31 Jul 2012 15:27:37 +0100 Subject: QNX: Do not send geometry change events to Qt too early We explicitly do not send geometry change events to Qt from QQnxWindow from the constructor. This prevents us from ending up in resizeEvent() reimplementations from the QWindow ctor. Change-Id: I045b35aa7eb23890772fe131c3d19314252f6a5a Reviewed-by: Kevin Krammer Reviewed-by: Kevin Ottens Reviewed-by: Giuseppe D'Angelo --- src/plugins/platforms/qnx/qqnxwindow.cpp | 52 ++++++++++++++++++-------------- src/plugins/platforms/qnx/qqnxwindow.h | 1 + 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index f717a33d78..dd69d15002 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -139,7 +139,7 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) setWindowState(window->windowState()); if (window->parent()) setParent(window->parent()->handle()); - setGeometry(window->geometry()); + setGeometryHelper(window->geometry()); setVisible(window->isVisible()); } @@ -163,6 +163,34 @@ QQnxWindow::~QQnxWindow() } void QQnxWindow::setGeometry(const QRect &rect) +{ + const QRect oldGeometry = setGeometryHelper(rect); + + // If this is an OpenGL window we need to request that the GL context updates + // the EGLsurface on which it is rendering. The surface will be recreated the + // next time QQnxGLContext::makeCurrent() is called. + { + // We want the setting of the atomic bool in the GL context to be atomic with + // setting m_requestedBufferSize and therefore extended the scope to include + // that test. + const QMutexLocker locker(&m_mutex); + m_requestedBufferSize = rect.size(); + if (m_platformOpenGLContext != 0 && bufferSize() != rect.size()) + m_platformOpenGLContext->requestSurfaceChange(); + } + + // Send a geometry change event to Qt (triggers resizeEvent() in QWindow/QWidget) + QWindowSystemInterface::handleSynchronousGeometryChange(window(), rect); + + // Now move all children. + if (!oldGeometry.isEmpty()) { + const QPoint offset = rect.topLeft() - oldGeometry.topLeft(); + Q_FOREACH (QQnxWindow *childWindow, m_childWindows) + childWindow->setOffset(offset); + } +} + +QRect QQnxWindow::setGeometryHelper(const QRect &rect) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << ", (" << rect.x() << "," << rect.y() @@ -197,27 +225,7 @@ void QQnxWindow::setGeometry(const QRect &rect) qFatal("QQnxWindow: failed to set window source size, errno=%d", errno); } - // If this is an OpenGL window we need to request that the GL context updates - // the EGLsurface on which it is rendering. The surface will be recreated the - // next time QQnxGLContext::makeCurrent() is called. - { - // We want the setting of the atomic bool in the GL context to be atomic with - // setting m_requestedBufferSize and therefore extended the scope to include - // that test. - const QMutexLocker locker(&m_mutex); - m_requestedBufferSize = rect.size(); - if (m_platformOpenGLContext != 0 && bufferSize() != rect.size()) - m_platformOpenGLContext->requestSurfaceChange(); - } - - QWindowSystemInterface::handleSynchronousGeometryChange(window(), rect); - - // Now move all children. - if (!oldGeometry.isEmpty()) { - const QPoint offset = rect.topLeft() - oldGeometry.topLeft(); - Q_FOREACH (QQnxWindow *childWindow, m_childWindows) - childWindow->setOffset(offset); - } + return oldGeometry; } void QQnxWindow::setOffset(const QPoint &offset) diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index 091476edec..5c3f8e6452 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -118,6 +118,7 @@ public: void blitFrom(QQnxWindow *sourceWindow, const QPoint &sourceOffset, const QRegion &targetRegion); private: + QRect setGeometryHelper(const QRect &rect); void removeFromParent(); void setOffset(const QPoint &setOffset); void updateVisibility(bool parentVisible); -- cgit v1.2.3