The display link may be stopped even if there are associated windows, due to idleness. So, it may need to be started when a window is added even if it's not the first window.
Signed-off-by: Ken Thomases ken@codeweavers.com --- dlls/winemac.drv/cocoa_window.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 65dc392..1b1d171 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -218,25 +218,25 @@ - (void) dealloc
- (void) addWindow:(WineWindow*)window { - BOOL needsStart; + BOOL firstWindow; @synchronized(self) { - needsStart = !_windows.count; + firstWindow = !_windows.count; [_windows addObject:window]; } - if (needsStart) + if (firstWindow || !CVDisplayLinkIsRunning(_link)) CVDisplayLinkStart(_link); }
- (void) removeWindow:(WineWindow*)window { - BOOL shouldStop = FALSE; + BOOL lastWindow = FALSE; @synchronized(self) { - BOOL wasRunning = _windows.count > 0; + BOOL hadWindows = _windows.count > 0; [_windows removeObject:window]; - if (wasRunning && !_windows.count) - shouldStop = TRUE; + if (hadWindows && !_windows.count) + lastWindow = TRUE; } - if (shouldStop) + if (lastWindow && CVDisplayLinkIsRunning(_link)) CVDisplayLinkStop(_link); }
This fixes an issue where some windows (on some systems) would never display their content area. If they had a title bar, they'd just display that and nothing else.
Signed-off-by: Ken Thomases ken@codeweavers.com --- dlls/winemac.drv/cocoa_window.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 1b1d171..03a9e78 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -2427,6 +2427,8 @@ - (void) setViewsNeedDisplay:(BOOL)value _lastDisplayTime = now; } } + else + [self setAutodisplay:YES]; } [super setViewsNeedDisplay:value]; } @@ -2435,14 +2437,16 @@ - (void) display { _lastDisplayTime = [[NSProcessInfo processInfo] systemUptime]; [super display]; - [self setAutodisplay:NO]; + if (_lastDisplayID) + [self setAutodisplay:NO]; }
- (void) displayIfNeeded { _lastDisplayTime = [[NSProcessInfo processInfo] systemUptime]; [super displayIfNeeded]; - [self setAutodisplay:NO]; + if (_lastDisplayID) + [self setAutodisplay:NO]; }
- (void) windowDidDrawContent
Signed-off-by: Ken Thomases ken@codeweavers.com --- 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 03a9e78..991db57 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); }