mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Fix setting window position
This commit is contained in:
@@ -539,16 +539,16 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
|||||||
{
|
{
|
||||||
// The position needs to be in the global coordinate space.
|
// The position needs to be in the global coordinate space.
|
||||||
SDL_Rect displaybounds = {};
|
SDL_Rect displaybounds = {};
|
||||||
SDL_GetDisplayBounds(f.displayindex, &displaybounds);
|
SDL_GetDisplayBounds(displays.ids[f.displayindex], &displaybounds);
|
||||||
x += displaybounds.x;
|
x += displaybounds.x;
|
||||||
y += displaybounds.y;
|
y += displaybounds.y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (f.centered)
|
if (f.centered)
|
||||||
x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.displayindex);
|
x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(displays.ids[f.displayindex]);
|
||||||
else
|
else
|
||||||
x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.displayindex);
|
x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(displays.ids[f.displayindex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 sdlflags = 0;
|
Uint32 sdlflags = 0;
|
||||||
@@ -969,10 +969,12 @@ void Window::setPosition(int x, int y, int displayindex)
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
displayindex = std::min(std::max(displayindex, 0), getDisplayCount() - 1);
|
SDLDisplayIDs displayids;
|
||||||
|
|
||||||
|
displayindex = std::min(std::max(displayindex, 0), displayids.count - 1);
|
||||||
|
|
||||||
SDL_Rect displaybounds = {};
|
SDL_Rect displaybounds = {};
|
||||||
SDL_GetDisplayBounds(displayindex, &displaybounds);
|
SDL_GetDisplayBounds(displayids.ids[displayindex], &displaybounds);
|
||||||
|
|
||||||
// The position needs to be in the global coordinate space.
|
// The position needs to be in the global coordinate space.
|
||||||
x += displaybounds.x;
|
x += displaybounds.x;
|
||||||
|
|||||||
Reference in New Issue
Block a user