Cocoa: Fix flicker on window resize.
authorMorten Sorvig <morten.sorvig@nokia.com>
Tue, 16 Aug 2011 07:25:50 +0000 (09:25 +0200)
committerPaul Olav Tvete <paul.tvete@nokia.com>
Tue, 16 Aug 2011 07:36:43 +0000 (09:36 +0200)
During window resizing the geometry change events
must be processed before returning from the event
handler.

New API: QWindowSystemInterface::handleSynchronousGeometryChange,
similar to handleGeometryChange but sends the event
immediately instead of queueing it.

Change-Id: I7dc809b3fd2e8a933c100fef3f5144972f46e363
Reviewed-on: http://codereview.qt.nokia.com/2993
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
src/gui/kernel/qwindowsysteminterface_qpa.cpp
src/gui/kernel/qwindowsysteminterface_qpa.h
src/plugins/platforms/cocoa/qcocoawindow.mm

index 047c134..9b3d691 100644 (file)
@@ -93,6 +93,11 @@ void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &new
     QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
 }
 
+void QWindowSystemInterface::handleSynchronousGeometryChange(QWindow *tlw, const QRect &newRect)
+{
+    QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
+    QGuiApplicationPrivate::processWindowSystemEvent(e); // send event immediately.
+}
 
 void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
 {
index 52838e0..dcfd7f1 100644 (file)
@@ -95,6 +95,7 @@ public:
     static void handleTouchEvent(QWindow *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
 
     static void handleGeometryChange(QWindow *w, const QRect &newRect);
+    static void handleSynchronousGeometryChange(QWindow *w, const QRect &newRect);
     static void handleCloseEvent(QWindow *w);
     static void handleEnterEvent(QWindow *w);
     static void handleLeaveEvent(QWindow *w);
index 08a45cb..fefdbc8 100644 (file)
@@ -154,10 +154,9 @@ void QCocoaWindow::windowDidMove()
 
 void QCocoaWindow::windowDidResize()
 {
-    //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
     NSRect rect = [[m_nsWindow contentView]frame];
     QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
-    QWindowSystemInterface::handleGeometryChange(window(),geo);
+    QWindowSystemInterface::handleSynchronousGeometryChange(window(), geo);
 
     if (m_glContext)
         m_glContext->update();