Skip to content

Commit

Permalink
Reworked fullscreen handling a bit
Browse files Browse the repository at this point in the history
This allows fullscreen toggling to correctly revert window to the previous state
  • Loading branch information
Vultraz committed Jan 1, 2016
1 parent 75080d8 commit 4d9882a
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/video.cpp
Expand Up @@ -996,26 +996,24 @@ bool CVideo::detect_video_settings(std::pair<int,int>& resolution, int& bpp, int

void CVideo::set_fullscreen(bool ison)
{
if(display::get_singleton() != NULL) {
const std::pair<int,int>& res = preferences::resolution();
if(isFullScreen() != ison) {
// When toggling fullscreen off, switch to a maximized window
const int flags = ison ? SDL_FULLSCREEN : SDL_WINDOW_MAXIMIZED;
// Change the config value.
preferences::_set_fullscreen(ison);

if (display::get_singleton() && isFullScreen() != ison) {
const int flags = ison ? SDL_FULLSCREEN : 0;

#if SDL_VERSION_ATLEAST(2, 0, 0)
int bpp = DefaultBpp;
int bpp = DefaultBpp;
#else
int bpp = bppForMode(res.first, res.second, flags);
int bpp = bppForMode(res.first, res.second, flags);
#endif

setMode(res.first,res.second,bpp,flags);
if(display::get_singleton()) {
display::get_singleton()->redraw_everything();
}
}
}
const std::pair<int,int>& res = preferences::resolution();

// Change the config value.
preferences::_set_fullscreen(ison);
setMode(res.first, res.second, bpp, flags);

display::get_singleton()->redraw_everything();
}
}

void CVideo::set_resolution(const std::pair<int,int>& resolution)
Expand Down

0 comments on commit 4d9882a

Please sign in to comment.