Skip to content
Permalink
Browse files

Allow loading window positions on 2nd monitor

  • Loading branch information...
jacob1 committed Mar 25, 2019
1 parent 89c7d9e commit e9011033eb9677651433b288743e241d78b1c546
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/PowderToySDL.cpp
@@ -95,8 +95,21 @@ void LoadWindowPosition()
if (borderTop == 0)
borderTop = 5;

if (savedWindowX + borderLeft > 0 && savedWindowX + borderLeft < desktopWidth
&& savedWindowY + borderTop > 0 && savedWindowY + borderTop < desktopHeight)
int numDisplays = SDL_GetNumVideoDisplays();
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);
}

0 comments on commit e901103

Please sign in to comment.
You can’t perform that action at this time.