mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-01 06:38:20 +00:00
windowWillStartLiveResize: legacy OS compatibility fix
(cherry picked from commit d58f026827)
This commit is contained in:
committed by
Sam Lantinga
parent
a5c518bf71
commit
732f779606
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user