Fixed love.window.getPosition in fullscreen mode when SDL 2.0.4 is used.

This commit is contained in:
Alex Szpakowski
2015-08-01 16:01:59 -03:00
parent c15f4b5f26
commit f2b4438a57
+4 -3
View File
@@ -709,13 +709,14 @@ void Window::getPosition(int &x, int &y, int &displayindex)
SDL_GetWindowPosition(window, &x, &y);
// SDL always reports 0, 0 for fullscreen windows.
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN))
// In SDL <= 2.0.3, fullscreen windows are always reported as 0,0. In every
// other case we need to convert the position from global coordinates to the
// monitor's coordinate space.
if (x != 0 || y != 0)
{
SDL_Rect displaybounds = {};
SDL_GetDisplayBounds(displayindex, &displaybounds);
// The position needs to be in the monitor's coordinate space.
x -= displaybounds.x;
y -= displaybounds.y;
}