diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 2201c46414..64e06a644f 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1723,6 +1723,12 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) /* Need to restore or update any limits changed while the window was fullscreen. */ X11_SetWindowMinMax(data->window, !!(flags & SDL_WINDOW_MAXIMIZED)); + + /* Toggle the borders if they were forced on while creating a borderless fullscreen window. */ + if (data->fullscreen_borders_forced_on) { + data->toggle_borders = SDL_TRUE; + data->fullscreen_borders_forced_on = SDL_FALSE; + } } if ((flags & SDL_WINDOW_FULLSCREEN) && diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index fda1f07812..628e21206f 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -755,6 +755,10 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } windowdata = window->driverdata; + /* Set the flag if the borders were forced on when creating a fullscreen window for later removal. */ + windowdata->fullscreen_borders_forced_on = !!(window->pending_flags & SDL_WINDOW_FULLSCREEN) && + !!(window->flags & SDL_WINDOW_BORDERLESS); + #if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL) if ((window->flags & SDL_WINDOW_OPENGL) && ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || @@ -1320,6 +1324,7 @@ void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool } else { /* If fullscreen, set a flag to toggle the borders when returning to windowed mode. */ data->toggle_borders = SDL_TRUE; + data->fullscreen_borders_forced_on = SDL_FALSE; } } @@ -1734,10 +1739,6 @@ static int X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *wind X11_SetNetWMState(_this, data->xwindow, flags); } - if ((window->flags & SDL_WINDOW_BORDERLESS) && !fullscreen) { - SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE); - } - if (data->visual->class == DirectColor) { if (fullscreen) { X11_XInstallColormap(display, data->colormap); diff --git a/src/video/x11/SDL_x11window.h b/src/video/x11/SDL_x11window.h index 204c7e4af5..0681bf7dfb 100644 --- a/src/video/x11/SDL_x11window.h +++ b/src/video/x11/SDL_x11window.h @@ -101,6 +101,7 @@ struct SDL_WindowData SDL_bool disable_size_position_events; SDL_bool previous_borders_nonzero; SDL_bool toggle_borders; + SDL_bool fullscreen_borders_forced_on; SDL_HitTestResult hit_test_result; };