From: Morten Sorvig Date: Tue, 16 Aug 2011 07:25:50 +0000 (+0200) Subject: Cocoa: Fix flicker on window resize. X-Git-Tag: qt-v5.0.0-alpha1~3626^2~203 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30774e9552591746a2640ba39c7afdc052952597;p=profile%2Fivi%2Fqtbase.git Cocoa: Fix flicker on window resize. 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 Reviewed-by: Paul Olav Tvete --- diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 047c134..9b3d691 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -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) { diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 52838e0..dcfd7f1 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -95,6 +95,7 @@ public: static void handleTouchEvent(QWindow *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList &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); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 08a45cb..fefdbc8 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -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();