Ask the window for it's state when trying to decide what the state is
This commit is contained in:
parent
7913841300
commit
4b2fabfd7e
5 changed files with 16 additions and 4 deletions
|
@ -443,6 +443,7 @@ void pump()
|
|||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
std::cout << "resize event: " << event.window.data1 << "x" << event.window.data2 << "\n";
|
||||
info.resize_dimensions.first = event.window.data1;
|
||||
info.resize_dimensions.second = event.window.data2;
|
||||
break;
|
||||
|
|
|
@ -379,6 +379,8 @@ bool fullscreen()
|
|||
|
||||
void _set_resolution(const std::pair<int, int>& res)
|
||||
{
|
||||
std::cout << "preferences set res: " << res.first << "x" << res.second << "\n";
|
||||
|
||||
const std::string postfix = fullscreen() ? "resolution" : "windowsize";
|
||||
preferences::set('x' + postfix, lexical_cast<std::string>(res.first));
|
||||
preferences::set('y' + postfix, lexical_cast<std::string>(res.second));
|
||||
|
|
|
@ -115,6 +115,11 @@ void twindow::set_icon(const surface& icon)
|
|||
SDL_SetWindowIcon(window_, icon);
|
||||
}
|
||||
|
||||
int twindow::get_flags()
|
||||
{
|
||||
return SDL_GetWindowFlags(window_);
|
||||
}
|
||||
|
||||
void twindow::set_minimum_size(int min_w, int min_h)
|
||||
{
|
||||
SDL_SetWindowMinimumSize(window_, min_w, min_h);
|
||||
|
|
|
@ -142,6 +142,8 @@ public:
|
|||
*/
|
||||
void set_icon(const surface& icon);
|
||||
|
||||
int get_flags();
|
||||
|
||||
/**
|
||||
* Set mimimum size of the window.
|
||||
*
|
||||
|
|
|
@ -601,9 +601,6 @@ int CVideo::setMode( int x, int y, int bits_per_pixel, int flags )
|
|||
|
||||
flags = get_flags(flags);
|
||||
|
||||
is_fullscreen = (flags & SDL_FULLSCREEN ) != 0;
|
||||
is_maximized = (flags & SDL_WINDOW_MAXIMIZED) != 0;
|
||||
|
||||
if (!window) {
|
||||
// SDL_WINDOWPOS_UNDEFINED allows SDL to centre the window in the display instead of using a fixed initial position.
|
||||
// Note that x and y in this particular case refer to width and height of the window, not co-ordinates.
|
||||
|
@ -611,13 +608,18 @@ int CVideo::setMode( int x, int y, int bits_per_pixel, int flags )
|
|||
window->set_minimum_size(preferences::min_allowed_width(), preferences::min_allowed_height());
|
||||
event_handler_.join_global();
|
||||
} else {
|
||||
int window_flags = window->get_flags();
|
||||
is_fullscreen = (window_flags & SDL_FULLSCREEN ) != 0;
|
||||
is_maximized = (window_flags & SDL_WINDOW_MAXIMIZED) != 0;
|
||||
|
||||
window->set_size(x, y);
|
||||
if (is_fullscreen) {
|
||||
window->full_screen();
|
||||
} else if (is_maximized) {
|
||||
window->restore();
|
||||
window->maximize();
|
||||
} else {
|
||||
window->restore();
|
||||
window->set_size(x, y);
|
||||
window->center();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue