diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-08-30 19:22:40 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-09-01 02:42:36 +0000 |
commit | 9507edddf239eb3130535a4d3e0d74b6502ed555 (patch) | |
tree | 5a248c30bab305c7720c13eb62a41fd289e67cad /src/plugins/platforms/cocoa | |
parent | 28414f8e3a25f6ac913d14542866a7d1745b4df1 (diff) |
macOS: Implement QWindow::requestUpdate() in terms of setNeedsDisplay
This is preferable to the timer-based default implementation of
QPlatformWindow, as it gives AppKit more control of when to schedule
the update, and makes sure the update is scheduled along with other
views in the normal display-cycle, reducing the number of push flushes
we do. QtWidgets still need to plumb the update() method to updateRequest
for that to have any real effect though.
In the future we may consider scheduling the update via a display link,
if the window surface is set up for GL, for example.
Ideally we'd also have a platform hook for the repaint() method, so that
we could funnel it through display and get synchronous painting with
AppKit still taking care of drawing and compositing child views.
Change-Id: I136a9afa087b922aad69086548c2aa190ce75b6b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index e20f033a43..052d8f838c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -123,6 +123,7 @@ public: bool isForeignWindow() const Q_DECL_OVERRIDE; + void requestUpdate() override; void requestActivateWindow() Q_DECL_OVERRIDE; WId winId() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f37c95aa77..aaa7a8798f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1069,6 +1069,15 @@ void QCocoaWindow::handleExposeEvent(const QRegion ®ion) && !region.isEmpty() && !m_view.hiddenOrHasHiddenAncestor; + + QWindowPrivate *windowPrivate = qt_window_private(window()); + if (m_isExposed && windowPrivate->updateRequestPending) { + // FIXME: Should this logic for expose events be in QGuiApplication? + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request"; + windowPrivate->deliverUpdateRequest(); + return; + } + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "isExposed" << isExposed(); QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(window(), region); } @@ -1239,6 +1248,12 @@ void QCocoaWindow::recreateWindowIfNeeded() updateNSToolbar(); } +void QCocoaWindow::requestUpdate() +{ + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::requestUpdate" << window(); + [m_view setNeedsDisplay:YES]; +} + void QCocoaWindow::requestActivateWindow() { NSWindow *window = [m_view window]; |