MessageBoxes attached to a window in macOS should use modal APIs and not use a poll/sleep pattern on the main thread. Sleeping the main thread makes the NSWindow message loop sluggish and interferes with external applications that need to send messages to that window, such as VoiceOver.
This commit is contained in:
@@ -31,7 +31,6 @@
|
|||||||
NSWindow *nswindow;
|
NSWindow *nswindow;
|
||||||
}
|
}
|
||||||
- (id)initWithParentWindow:(SDL_Window *)window;
|
- (id)initWithParentWindow:(SDL_Window *)window;
|
||||||
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SDLMessageBoxPresenter
|
@implementation SDLMessageBoxPresenter
|
||||||
@@ -55,39 +54,16 @@
|
|||||||
- (void)showAlert:(NSAlert *)alert
|
- (void)showAlert:(NSAlert *)alert
|
||||||
{
|
{
|
||||||
if (nswindow) {
|
if (nswindow) {
|
||||||
#ifdef MAC_OS_X_VERSION_10_9
|
[alert beginSheetModalForWindow:nswindow
|
||||||
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
|
completionHandler:^(NSModalResponse returnCode) {
|
||||||
[alert beginSheetModalForWindow:nswindow
|
[NSApp stopModalWithCode:returnCode];
|
||||||
completionHandler:^(NSModalResponse returnCode) {
|
}];
|
||||||
self->clicked = returnCode;
|
clicked = [NSApp runModalForWindow:nswindow];
|
||||||
}];
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
|
|
||||||
[alert beginSheetModalForWindow:nswindow
|
|
||||||
modalDelegate:self
|
|
||||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
|
||||||
contextInfo:nil];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
while (clicked < 0) {
|
|
||||||
SDL_PumpEvents();
|
|
||||||
SDL_Delay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
nswindow = nil;
|
nswindow = nil;
|
||||||
} else {
|
} else {
|
||||||
clicked = [alert runModal];
|
clicked = [alert runModal];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
|
|
||||||
{
|
|
||||||
clicked = returnCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static void Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue)
|
static void Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user