From a599974a9b7fc92d68011dafc969e83e469a6472 Mon Sep 17 00:00:00 2001 From: Martin Plicht Date: Sun, 3 Nov 2013 01:41:16 +0100 Subject: [PATCH] mac: Use OSX Mavericks occlusionState API to test whether window is visible and needs drawing or not (should still work on Mountain Lion due to runtime check for API availability) --- src/graphics/C4DrawGLMac.mm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/graphics/C4DrawGLMac.mm b/src/graphics/C4DrawGLMac.mm index f29191dc4..cae0b1e82 100644 --- a/src/graphics/C4DrawGLMac.mm +++ b/src/graphics/C4DrawGLMac.mm @@ -115,12 +115,22 @@ // better not to draw anything when the game has already finished if (Application.fQuitMsgReceived) return; + // don't draw if tab-switched away from fullscreen - if ([self.controller isFullScreenConsideringLionFullScreen] && ![NSApp isActive]) - return; - if ([self.window isMiniaturized] || ![self.window isVisible]) - return; - //[self.context update]; + if ([NSApp respondsToSelector:@selector(occlusionState)]) + { + // Mavericks - query app occlusion state + if (([NSApp occlusionState] & NSApplicationOcclusionStateVisible) == 0) + return; + } + else + { + if ([self.controller isFullScreenConsideringLionFullScreen] && ![NSApp isActive]) + return; + if ([self.window isMiniaturized] || ![self.window isVisible]) + return; + } + C4Window* stdWindow = self.controller.stdWindow; if (stdWindow)