diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-10-23 16:02:31 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-10-29 09:39:31 +0100 |
commit | 6c38a82aa8165bbe3cbdc7f17e67999439842c29 (patch) | |
tree | 403211ec68447afe4c5dfb1dce06d89bf18600f0 /src | |
parent | 14e51127cf2ba4fdb3469da90fd2f8f26084bb4b (diff) |
Cocoa: Send obscure events on OcclusionStateHidden
This disables animations for windows that are
completely obscured by other windows.
On examples/quick/animation, obscured CPU usage goes
from 10% to 1%. There has been reports of 100% CPU
usage with Qt before this patch.
Change-Id: Iefea43ed8c1cfaa2df13f1f5a4e4450146ade522
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 1f1bc36bf2..1fb30567bc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -420,12 +420,17 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; #pragma clang diagnostic ignored "-Wobjc-method-access" enum { NSWindowOcclusionStateVisible = 1UL << 1 }; #endif - // Older versions managed in -[QNSView viewDidMoveToWindow]. - // Support QWidgetAction in NSMenu. Mavericks only sends this notification. - // Ideally we should support this in Qt as well, in order to disable animations - // when the window is occluded. - if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) + if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible) { m_platformWindow->exposeWindow(); + } else { + // Send Obscure events on window occlusion to stop animations. Several + // unit tests expect paint and/or expose events for windows that are + // sometimes (unpredictably) occlouded: Don't send Obscure events when + // running under QTestLib. + static bool onTestLib = qt_mac_resolveOption(false, "QT_QTESTLIB_RUNNING"); + if (!onTestLib) + m_platformWindow->obscureWindow(); + } #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 #pragma clang diagnostic pop #endif |