| Summary: | Cocoa_GetDisplayUsableBounds returns incorrect bounds | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Tim McDaniel <tmcdaniel> |
| Component: | video | Assignee: | Alex Szpakowski <amaranth72> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.9 | ||
| Hardware: | All | ||
| OS: | Mac OS X (All) | ||
Alex, can you take a look at this? I've applied and tested the change and it works well. Thanks! https://hg.libsdl.org/SDL/rev/e3213f8d6c16 |
Cocoa_GetDisplayUsableBounds is incorrectly calculating the usable bounds. [NSScreen visibleFrame] returns a rect in global screen coords (same as [NSScreen frame], not coords relative to the origin of the particular screen. Also the rect's origin needs to be converted to SDL's top-left convention instead of Cocoa's bottom-left. This: const CGRect cgrect = CGDisplayBounds(cgdisplay); const NSRect frame = [screen visibleFrame]; // !!! FIXME: I assume -[NSScreen visibleFrame] is relative to the origin of the screen in question and not the whole desktop. // !!! FIXME: The math vs CGDisplayBounds might be incorrect if that's not the case, though. Check this. rect->x = (int)(cgrect.origin.x + frame.origin.x); rect->y = (int)(cgrect.origin.y + frame.origin.y); rect->w = (int)frame.size.width; rect->h = (int)frame.size.height; Should be: const NSRect frame = [screen visibleFrame]; rect->x = (int)frame.origin.x; rect->y = (int)(CGDisplayPixelsHigh(kCGDirectMainDisplay) - frame.origin.y - frame.size.height); rect->w = (int)frame.size.width; rect->h = (int)frame.size.height;