mirror of https://github.com/encounter/SDL.git
cocoa: Return an error if GetWindowDisplayIndex() is called too early
SDL_CreateWindow() may call GetWindowDisplayIndex() to compute the position of a new window that the caller has requested to be placed on a certain display. Since we haven't fully constructed the window yet, our driverdata will be nil and we will fail to get the NSScreen (which is fine). However, we need to return an error (not 0, which is a valid display index) for SDL_GetWindowDisplayIndex() to know to figure out the display index itself. Fixes positioning new windows on secondary displays when using SDL_WINDOWPOS_CENTERED_DISPLAY() and SDL_WINDOWPOS_UNDEFINED_DISPLAY().
This commit is contained in:
parent
f1416ef2ba
commit
3046d55d0e
|
@ -2228,7 +2228,7 @@ Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window)
|
|||
|
||||
/* Not recognized via CHECK_WINDOW_MAGIC */
|
||||
if (data == nil) {
|
||||
return 0;
|
||||
return SDL_SetError("Window data not set");
|
||||
}
|
||||
|
||||
/* NSWindow.screen may be nil when the window is off-screen. */
|
||||
|
|
Loading…
Reference in New Issue