Skip to content

Commit 1955f9c

Browse files
committed
windowWillStartLiveResize: legacy OS compatibility fix
1 parent 64d6df3 commit 1955f9c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -747,16 +747,26 @@ - (void)windowWillStartLiveResize:(NSNotification *)aNotification
747747
{
748748
// We'll try to maintain 60 FPS during live resizing
749749
const NSTimeInterval interval = 1.0 / 60.0;
750+
751+
const NSMethodSignature *invocationSig = [SDLWindow
752+
instanceMethodSignatureForSelector:@selector(onLiveResizeTimerFire)];
753+
NSInvocation *invocation = [NSInvocation
754+
invocationWithMethodSignature:invocationSig];
755+
[invocation setTarget:self];
756+
[invocation setSelector:@selector(onLiveResizeTimerFire)];
757+
750758
liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval
751-
repeats:TRUE
752-
block:^(NSTimer *unusedTimer)
753-
{
754-
SDL_OnWindowLiveResizeUpdate(_data.window);
755-
}];
759+
invocation:invocation
760+
repeats:TRUE];
756761

757762
[[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes];
758763
}
759764

765+
- (void)onLiveResizeTimerFire
766+
{
767+
SDL_OnWindowLiveResizeUpdate(_data.window);
768+
}
769+
760770
- (void)windowDidEndLiveResize:(NSNotification *)aNotification
761771
{
762772
[liveResizeTimer invalidate];

0 commit comments

Comments
 (0)