Skip to content

Commit 5c7aacb

Browse files
committed
Make fullscreen mode with XWayland a bit less broken, #587
assert( ret.width == glConfig.winWidth && ret.height == glConfig.winHeight ); in GLimp_GetCurState() triggered, because SDL_GetWindowSize(), which was used to set glConfig.winWidth/Height in GLimp_UpdateWindowSize(), returned different values than SDL_GetWindowDisplayMode(). Now use SDL_GetWindowDisplayMode() in GLimp_UpdateWindowSize() so it's at least consistent. However it seems like SDL_GetWindowSize() returns the correct values (IN THAT CASE), because with this change the mouse cursor doesn't work that well (in the specific case described above). In the end this is an SDL or Wayland bug or something, and I can only recommend not using "real" fullscreen mode with Wayland, as it's fake anyway (Wayland doesn't allow switching the display resolution, so you get a magically scaled borderless fullscreen window at best)
1 parent cec78b5 commit 5c7aacb

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

neo/sys/glimp.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ glimpParms_t GLimp_GetCurState()
719719
ret.width = real_mode.w;
720720
ret.height = real_mode.h;
721721
ret.displayHz = real_mode.refresh_rate;
722+
} else {
723+
common->Warning( "GLimp_GetCurState(): Can't get display mode: %s\n", SDL_GetError() );
722724
}
723725
}
724726
if ( ret.width == 0 && ret.height == 0 ) { // windowed mode or SDL_GetWindowDisplayMode() failed
@@ -909,10 +911,30 @@ bool GLimp_SetWindowResizable( bool enableResizable )
909911
void GLimp_UpdateWindowSize()
910912
{
911913
#if SDL_VERSION_ATLEAST(2, 0, 0)
912-
int ww=0, wh=0;
913-
SDL_GetWindowSize( window, &ww, &wh );
914-
glConfig.winWidth = ww;
915-
glConfig.winHeight = wh;
914+
Uint32 winFlags = SDL_GetWindowFlags( window );
915+
if ( (winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN ) {
916+
// real fullscreen mode => must use SDL_GetWindowDisplayMode()
917+
// TODO: well, theoretically SDL_GetWindowSize() should work for fullscreen mode as well,
918+
// but not in all SDL versions, I think?
919+
// And in fact it seems like with "real" fullscreen windows on XWayland SDL_GetWindowSize()
920+
// returns the correct values and SDL_GetWindowDisplayMode() doesn't, when the fullscreen
921+
// resolution is lower than the desktop resolution.. it's kind of messy.
922+
SDL_DisplayMode dm = {};
923+
if ( SDL_GetWindowDisplayMode( window, &dm ) == 0 ) {
924+
glConfig.winWidth = dm.w;
925+
glConfig.winHeight = dm.h;
926+
int ww=0, wh=0;
927+
SDL_GetWindowSize( window, &ww, &wh );
928+
} else {
929+
common->Warning( "GLimp_UpdateWindowSize(): SDL_GetWindowDisplayMode() failed: %s\n", SDL_GetError() );
930+
}
931+
932+
} else {
933+
int ww=0, wh=0;
934+
SDL_GetWindowSize( window, &ww, &wh );
935+
glConfig.winWidth = ww;
936+
glConfig.winHeight = wh;
937+
}
916938
SDL_GL_GetDrawableSize( window, &glConfig.vidWidth, &glConfig.vidHeight );
917939
#endif
918940
}

0 commit comments

Comments
 (0)