Skip to content

Commit

Permalink
Make fullscreen mode with XWayland a bit less broken, #587
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
DanielGibson committed Jul 2, 2024
1 parent cec78b5 commit 5c7aacb
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions neo/sys/glimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 5c7aacb

Please sign in to comment.