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>
This commit is contained in:
parent
28414f8e3a
commit
9507edddf2
@ -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;
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user