Permalink
Browse files

don't load invalid window positions, only load window pos on first run

  • Loading branch information...
jacob1 committed May 28, 2018
1 parent d4255d1 commit a40ab1e50d8073cfa1f444fc11d27b92c7ec05c2
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/PowderToySDL.cpp
@@ -88,7 +88,9 @@ void LoadWindowPosition()
int borderTop, borderLeft;
SDL_GetWindowBordersSize(sdl_window, &borderTop, &borderLeft, nullptr, nullptr);

SDL_SetWindowPosition(sdl_window, savedWindowX + borderLeft, savedWindowY + borderTop);
if (savedWindowX + borderLeft > 0 && savedWindowX + borderLeft < desktopWidth
&& savedWindowY + borderTop > 0 && savedWindowY + borderTop < desktopHeight)
SDL_SetWindowPosition(sdl_window, savedWindowX + borderLeft, savedWindowY + borderTop);
}

void SaveWindowPosition()
@@ -141,11 +143,6 @@ int SDLOpen()
return 1;
}

SDL_DisplayMode SDLDisplayMode;
SDL_GetCurrentDisplayMode(0, &SDLDisplayMode);
desktopWidth = SDLDisplayMode.w;
desktopHeight = SDLDisplayMode.h;

unsigned int flags = 0;
if (fullscreen)
flags = altFullscreen ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP;
@@ -164,6 +161,15 @@ int SDLOpen()
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
//SDL_SetWindowResizable(sdl_window, SDL_TRUE);

int displayIndex = SDL_GetWindowDisplayIndex(sdl_window);
if (displayIndex >= 0)
{
SDL_DisplayMode SDLDisplayMode;
SDL_GetCurrentDisplayMode(0, &SDLDisplayMode);
desktopWidth = SDLDisplayMode.w;
desktopHeight = SDLDisplayMode.h;
}

#ifdef WIN
SDL_SysWMinfo SysInfo;
SDL_VERSION(&SysInfo.version);
@@ -602,7 +608,8 @@ int main(int argc, char * argv[])
Client::Ref().SetPref("Scale", 2);
showDoubleScreenDialog = true;
}
LoadWindowPosition();
if (!Client::Ref().IsFirstRun())
LoadWindowPosition();

#ifdef OGLI
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);

0 comments on commit a40ab1e

Please sign in to comment.