diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index 9129d814..dc4ca35b 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -719,6 +719,8 @@ glimpParms_t GLimp_GetCurState() ret.width = real_mode.w; ret.height = real_mode.h; ret.displayHz = real_mode.refresh_rate; + } else { + common->Warning( "GLimp_GetCurState(): Can't get display mode: %s\n", SDL_GetError() ); } } if ( ret.width == 0 && ret.height == 0 ) { // windowed mode or SDL_GetWindowDisplayMode() failed @@ -909,10 +911,30 @@ bool GLimp_SetWindowResizable( bool enableResizable ) void GLimp_UpdateWindowSize() { #if SDL_VERSION_ATLEAST(2, 0, 0) - int ww=0, wh=0; - SDL_GetWindowSize( window, &ww, &wh ); - glConfig.winWidth = ww; - glConfig.winHeight = wh; + Uint32 winFlags = SDL_GetWindowFlags( window ); + if ( (winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN ) { + // real fullscreen mode => must use SDL_GetWindowDisplayMode() + // TODO: well, theoretically SDL_GetWindowSize() should work for fullscreen mode as well, + // but not in all SDL versions, I think? + // And in fact it seems like with "real" fullscreen windows on XWayland SDL_GetWindowSize() + // returns the correct values and SDL_GetWindowDisplayMode() doesn't, when the fullscreen + // resolution is lower than the desktop resolution.. it's kind of messy. + SDL_DisplayMode dm = {}; + if ( SDL_GetWindowDisplayMode( window, &dm ) == 0 ) { + glConfig.winWidth = dm.w; + glConfig.winHeight = dm.h; + int ww=0, wh=0; + SDL_GetWindowSize( window, &ww, &wh ); + } else { + common->Warning( "GLimp_UpdateWindowSize(): SDL_GetWindowDisplayMode() failed: %s\n", SDL_GetError() ); + } + + } else { + int ww=0, wh=0; + SDL_GetWindowSize( window, &ww, &wh ); + glConfig.winWidth = ww; + glConfig.winHeight = wh; + } SDL_GL_GetDrawableSize( window, &glConfig.vidWidth, &glConfig.vidHeight ); #endif }