Skip to content

Commit

Permalink
x11: Try to keep SDL_WINDOW_FULLSCREEN* in sync with window manager.
Browse files Browse the repository at this point in the history
So if Gnome/KDE/etc have a keyboard shortcut or titlebar decoration to
make any window go fullscreen (with the _NET_WM_FULLSCREEN flag on the
_NET_WM_STATE property), we update the SDL window flag.

Fixes libsdl-org#5390.
  • Loading branch information
icculus committed Apr 6, 2022
1 parent eb660e8 commit 0249df9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/video/x11/SDL_x11events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,13 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
}
}

if (changed & SDL_WINDOW_FULLSCREEN_DESKTOP) {
/* FULLSCREEN_DESKTOP encompasses two bits: SDL_WINDOW_FULLSCREEN, plus a bit to note it's FULLSCREEN_DESKTOP */
const Uint32 fsmasked = flags & SDL_WINDOW_FULLSCREEN_DESKTOP;
data->window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
data->window->flags |= fsmasked;
}

if (changed & SDL_WINDOW_MAXIMIZED) {
if (flags & SDL_WINDOW_MAXIMIZED) {
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11window.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ X11_GetNetWMState(_THIS, Window xwindow)
}

if (fullscreen == 1) {
flags |= SDL_WINDOW_FULLSCREEN;
flags |= SDL_WINDOW_FULLSCREEN; /* !!! FIXME: arguably this is more like FULLSCREEN_DESKTOP...? */
}

/* If the window is unmapped, numItems will be zero and _NET_WM_STATE_HIDDEN
Expand Down

0 comments on commit 0249df9

Please sign in to comment.