Skip to content

Commit 158c088

Browse files
committed
windowWillStartLiveResize: legacy OS compatibility fix
1 parent 64d6df3 commit 158c088

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/video/cocoa/SDL_cocoawindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef enum
7878
/* Window delegate functionality */
7979
-(BOOL) windowShouldClose:(id) sender;
8080
-(void) windowDidExpose:(NSNotification *) aNotification;
81+
-(void) onLiveResizeTimerFire:(id) sender;
8182
-(void) windowWillStartLiveResize:(NSNotification *)aNotification;
8283
-(void) windowDidEndLiveResize:(NSNotification *)aNotification;
8384
-(void) windowDidMove:(NSNotification *) aNotification;

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,26 @@ - (void)windowDidExpose:(NSNotification *)aNotification
743743
SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
744744
}
745745

746+
- (void)onLiveResizeTimerFire:(id)sender
747+
{
748+
SDL_OnWindowLiveResizeUpdate(_data.window);
749+
}
750+
746751
- (void)windowWillStartLiveResize:(NSNotification *)aNotification
747752
{
748753
// We'll try to maintain 60 FPS during live resizing
749754
const NSTimeInterval interval = 1.0 / 60.0;
755+
756+
NSMethodSignature *invocationSig = [Cocoa_WindowListener
757+
instanceMethodSignatureForSelector:@selector(onLiveResizeTimerFire:)];
758+
NSInvocation *invocation = [NSInvocation
759+
invocationWithMethodSignature:invocationSig];
760+
[invocation setTarget:self];
761+
[invocation setSelector:@selector(onLiveResizeTimerFire:)];
762+
750763
liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval
751-
repeats:TRUE
752-
block:^(NSTimer *unusedTimer)
753-
{
754-
SDL_OnWindowLiveResizeUpdate(_data.window);
755-
}];
764+
invocation:invocation
765+
repeats:TRUE];
756766

757767
[[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes];
758768
}

0 commit comments

Comments
 (0)