mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
cocoa: Re-add sync timeout
This should never happen, but it's a failsafe against future bugs or odd configurations
This commit is contained in:
@@ -3265,14 +3265,23 @@ bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float op
|
||||
|
||||
bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
bool result = true;
|
||||
bool result = false;
|
||||
|
||||
@autoreleasepool {
|
||||
const Uint64 timeout = SDL_GetTicksNS() + SDL_MS_TO_NS(2500);
|
||||
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
SDL_PumpEvents();
|
||||
} while ([data.listener hasPendingWindowOperation]);
|
||||
|
||||
result = ![data.listener hasPendingWindowOperation];
|
||||
if (result || SDL_GetTicksNS() >= timeout) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Small delay before going again.
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user