From 5f80cc43bfe3e741bdcbed744812472d5edd27c9 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Fri, 8 Dec 2017 02:54:08 -0600 Subject: [PATCH] winemac: Stop the display link after 2 seconds of idleness, not the first time it's idle. Signed-off-by: Ken Thomases Signed-off-by: Alexandre Julliard --- dlls/winemac.drv/cocoa_window.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 03a9e7805d2..991db57f4f6 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -166,6 +166,8 @@ @interface WineDisplayLink : NSObject NSTimeInterval _actualRefreshPeriod; NSTimeInterval _nominalRefreshPeriod; + + NSTimeInterval _lastDisplayTime; } - (id) initWithDisplayID:(CGDirectDisplayID)displayID; @@ -224,7 +226,7 @@ - (void) addWindow:(WineWindow*)window [_windows addObject:window]; } if (firstWindow || !CVDisplayLinkIsRunning(_link)) - CVDisplayLinkStart(_link); + [self start]; } - (void) removeWindow:(WineWindow*)window @@ -256,7 +258,11 @@ - (void) fire anyDisplayed = YES; } } - if (!anyDisplayed) + + NSTimeInterval now = [[NSProcessInfo processInfo] systemUptime]; + if (anyDisplayed) + _lastDisplayTime = now; + else if (_lastDisplayTime + 2.0 < now) CVDisplayLinkStop(_link); }); [windows release]; @@ -279,6 +285,7 @@ - (NSTimeInterval) refreshPeriod - (void) start { + _lastDisplayTime = [[NSProcessInfo processInfo] systemUptime]; CVDisplayLinkStart(_link); }