windowWillStartLiveResize: legacy OS compatibility fix

This commit is contained in:
Joshua Root
2025-01-03 04:19:51 +11:00
committed by Sam Lantinga
parent ed0eb7714a
commit d58f026827
2 changed files with 16 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ typedef enum
/* Window delegate functionality */
-(BOOL) windowShouldClose:(id) sender;
-(void) windowDidExpose:(NSNotification *) aNotification;
-(void) onLiveResizeTimerFire:(id) sender;
-(void) windowWillStartLiveResize:(NSNotification *)aNotification;
-(void) windowDidEndLiveResize:(NSNotification *)aNotification;
-(void) windowDidMove:(NSNotification *) aNotification;

View File

@@ -743,16 +743,26 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
}
- (void)onLiveResizeTimerFire:(id)sender
{
SDL_OnWindowLiveResizeUpdate(_data.window);
}
- (void)windowWillStartLiveResize:(NSNotification *)aNotification
{
// We'll try to maintain 60 FPS during live resizing
const NSTimeInterval interval = 1.0 / 60.0;
NSMethodSignature *invocationSig = [Cocoa_WindowListener
instanceMethodSignatureForSelector:@selector(onLiveResizeTimerFire:)];
NSInvocation *invocation = [NSInvocation
invocationWithMethodSignature:invocationSig];
[invocation setTarget:self];
[invocation setSelector:@selector(onLiveResizeTimerFire:)];
liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval
repeats:TRUE
block:^(NSTimer *unusedTimer)
{
SDL_OnWindowLiveResizeUpdate(_data.window);
}];
invocation:invocation
repeats:TRUE];
[[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes];
}