mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +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_GetWindowPosition(window, &x, &y);
|
||||||
|
|
||||||
// SDL always reports 0, 0 for fullscreen windows.
|
// In SDL <= 2.0.3, fullscreen windows are always reported as 0,0. In every
|
||||||
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN))
|
// 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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user