From 9bbf92e3da2b519ff267dae41b93b354f356fe36 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 25 Oct 2017 18:02:11 -0400 Subject: [PATCH] cocoa: Don't change the NSWindow background color. Changing the background color causes the titlebar to blend against it on modern macOS releases, making all SDL windows look wrong by default. This was set to make the window not flash white before a GL context is ready, but we can accomplish this in our window's view's drawRect implementation, too. --- src/video/cocoa/SDL_cocoawindow.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index c92590bae235a..13c8c74a571a2 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1152,6 +1152,11 @@ - (void)setSDLWindow:(SDL_Window*)window - (void)drawRect:(NSRect)dirtyRect { + /* Force the graphics context to clear to black so we don't get a flash of + white until the app is ready to draw. In practice on modern macOS, this + only gets called for window creation and other extraordinary events. */ + [[NSColor blackColor] setFill]; + NSRectFill(dirtyRect); SDL_SendWindowEvent(_sdlWindow, SDL_WINDOWEVENT_EXPOSED, 0, 0); } @@ -1316,7 +1321,6 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent @catch (NSException *e) { return SDL_SetError("%s", [[e reason] UTF8String]); } - [nswindow setBackgroundColor:[NSColor blackColor]]; if (videodata->allow_spaces) { SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);