From f2b4438a574a5449aa4d8d56aa80f7e8684931cd Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 1 Aug 2015 16:01:59 -0300 Subject: [PATCH] Fixed love.window.getPosition in fullscreen mode when SDL 2.0.4 is used. --- src/modules/window/sdl/Window.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 9660ad5d9..fb40b1304 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -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; }