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 <qt_sanity_bot@ovi.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
This commit is contained in:
Morten Sorvig 2011-08-16 09:25:50 +02:00 committed by Paul Olav Tvete
parent 7589bdc720
commit 30774e9552
3 changed files with 7 additions and 2 deletions

View 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)
{

View 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);

View 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();