diff options
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index c6dd0955aa..fa99390af0 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -404,6 +404,11 @@ void QWindowPrivate::create(bool recursive) window->d_func()->platformWindow->setParent(platformWindow); } } + + if (platformWindow) { + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); + QGuiApplication::sendEvent(q, &e); + } } } @@ -1594,6 +1599,10 @@ void QWindow::destroy() bool wasVisible = isVisible(); setVisible(false); + + QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); + QGuiApplication::sendEvent(this, &e); + delete d->platformWindow; d->resizeEventPending = true; d->receivedExpose = false; @@ -2043,12 +2052,56 @@ bool QWindow::event(QEvent *ev) break; #endif + case QEvent::Timer: { + Q_D(QWindow); + if (static_cast<QTimerEvent *>(ev)->timerId() == d->updateTimer) { + killTimer(d->updateTimer); + d->updateTimer = 0; + d->deliverUpdateRequest(); + } else { + QObject::event(ev); + } + break; + } + default: return QObject::event(ev); } return true; } +void QWindowPrivate::deliverUpdateRequest() +{ + Q_Q(QWindow); + updateRequestPending = false; + QEvent request(QEvent::UpdateRequest); + QCoreApplication::sendEvent(q, &request); +} + +/*! + Schedules a QEvent::UpdateRequest event to be delivered to this window. + + The event is delivered in sync with the display vsync on platforms + where this is possible. When driving animations, this function should + be called once after drawing has completed. + + Calling this function multiple times will result in a single event + being delivered to the window. + + Subclasses of QWindow should reimplement QWindow::event(), intercept + the event and call the application's rendering code, then call the + base class implementation. +*/ + +void QWindow::requestUpdate() +{ + Q_D(QWindow); + if (d->updateRequestPending || !d->platformWindow) + return; + d->updateRequestPending = true; + d->platformWindow->requestUpdate(); +} + /*! Override this to handle key press events (\a ev). |