|
@@ -2230,9 +2230,6 @@ int
|
|
|
Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window)
|
|
|
{ @autoreleasepool
|
|
|
{
|
|
|
- NSRect displayframe;
|
|
|
- SDL_Point display_center;
|
|
|
- SDL_Rect sdl_display_rect;
|
|
|
SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
|
|
|
|
|
|
/* Not recognized via CHECK_WINDOW_MAGIC */
|
|
@@ -2240,23 +2237,17 @@ Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- Considering that we already have the display coordinates in which the window is placed (described via displayframe)
|
|
|
- instead of checking in which display the window is placed, we should check which SDL display matches the display described
|
|
|
- via displayframe.
|
|
|
- */
|
|
|
- displayframe = data.nswindow.screen.frame;
|
|
|
-
|
|
|
- display_center.x = displayframe.origin.x + displayframe.size.width / 2;
|
|
|
- display_center.y = displayframe.origin.y + displayframe.size.height / 2;
|
|
|
-
|
|
|
- for (int i = 0; i < SDL_GetNumVideoDisplays(); i++){
|
|
|
- SDL_GetDisplayBounds(i, &sdl_display_rect);
|
|
|
- if (SDL_EnclosePoints(&display_center, 1, &sdl_display_rect, NULL)) {
|
|
|
- return i;
|
|
|
- }
|
|
|
+ NSArray *screens = [NSScreen screens];
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ for (NSScreen *screen in screens) {
|
|
|
+ if (screen == data.nswindow.screen)
|
|
|
+ return index;
|
|
|
+
|
|
|
+ index++;
|
|
|
}
|
|
|
- SDL_SetError("Couldn't find the display where the window is attached to.");
|
|
|
+
|
|
|
+ SDL_SetError("Couldn't find the display where the window is attached.");
|
|
|
return -1;
|
|
|
}}
|
|
|
|