Skip to content

Commit f97fa3a

Browse files
authored
Fix Windowed fullscreen using wrong resolution (#3249)
This happens because when moving SuperTux to the secondary monitor, the Viewport will take the size of the primary monitor
1 parent 80a3a47 commit f97fa3a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/video/sdlbase_video_system.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,33 @@ SDLBaseVideoSystem::create_sdl_window(Uint32 flags)
135135
void
136136
SDLBaseVideoSystem::apply_video_mode()
137137
{
138+
const int displayidx = SDL_GetWindowDisplayIndex(m_sdl_window.get());
139+
if (displayidx < 0)
140+
{
141+
log_warning << "Unable to get display index of window: "
142+
<< SDL_GetError() << std::endl;
143+
return;
144+
}
145+
146+
SDL_DisplayMode display;
147+
if (SDL_GetDesktopDisplayMode(displayidx, &display) != 0)
148+
{
149+
log_warning << "Unable to get information for display number "
150+
<< displayidx << ": "
151+
<< SDL_GetError() << std::endl;
152+
return;
153+
}
154+
155+
m_desktop_size.width = display.w;
156+
m_desktop_size.height = display.h;
157+
138158
if (!g_config->use_fullscreen)
139159
{
140160
SDL_SetWindowFullscreen(m_sdl_window.get(), 0);
141161

142162
Size window_size;
143163
SDL_GetWindowSize(m_sdl_window.get(), &window_size.width, &window_size.height);
164+
144165
if (g_config->window_size != window_size)
145166
{
146167
SDL_SetWindowSize(m_sdl_window.get(), g_config->window_size.width, g_config->window_size.height);

0 commit comments

Comments
 (0)