Browse Source

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

Alex Szpakowski 10 years ago
parent
commit
f2b4438a57
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/modules/window/sdl/Window.cpp

+ 4 - 3
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_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_Rect displaybounds = {};
 		SDL_GetDisplayBounds(displayindex, &displaybounds);
 		SDL_GetDisplayBounds(displayindex, &displaybounds);
 
 
-		// The position needs to be in the monitor's coordinate space.
 		x -= displaybounds.x;
 		x -= displaybounds.x;
 		y -= displaybounds.y;
 		y -= displaybounds.y;
 	}
 	}