Allow loading window positions on 2nd monitor
This commit is contained in:
parent
89c7d9ea02
commit
e9011033eb
@ -95,8 +95,21 @@ void LoadWindowPosition()
|
|||||||
if (borderTop == 0)
|
if (borderTop == 0)
|
||||||
borderTop = 5;
|
borderTop = 5;
|
||||||
|
|
||||||
if (savedWindowX + borderLeft > 0 && savedWindowX + borderLeft < desktopWidth
|
int numDisplays = SDL_GetNumVideoDisplays();
|
||||||
&& savedWindowY + borderTop > 0 && savedWindowY + borderTop < desktopHeight)
|
SDL_Rect displayBounds;
|
||||||
|
bool ok = false;
|
||||||
|
for (int i = 0; i < numDisplays; i++)
|
||||||
|
{
|
||||||
|
SDL_GetDisplayBounds(i, &displayBounds);
|
||||||
|
if (savedWindowX + borderTop > displayBounds.x && savedWindowY + borderLeft > displayBounds.y &&
|
||||||
|
savedWindowX + borderTop < displayBounds.x + displayBounds.w &&
|
||||||
|
savedWindowY + borderLeft < displayBounds.y + displayBounds.h)
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok)
|
||||||
SDL_SetWindowPosition(sdl_window, savedWindowX + borderLeft, savedWindowY + borderTop);
|
SDL_SetWindowPosition(sdl_window, savedWindowX + borderLeft, savedWindowY + borderTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user