mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Fixed love.window.getPosition in fullscreen mode when SDL 2.0.4 is used.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user