-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leaving Fullscreen doesn't restore original window size on Linux #1444
Comments
Original comment by Hisham Muhammad (Bitbucket: [Hisham Muhammad](https://bitbucket.org/Hisham Muhammad), ). I am having the same issue on Linux running with SDL 2.0.10. I am porting over a program written with Lua-SDL2 and I did not have this problem running the raw SDL bindings, so I don’t think this is an issue on the SDL side. |
Original comment by Hisham Muhammad (Bitbucket: [Hisham Muhammad](https://bitbucket.org/Hisham Muhammad), ). FWIW I’m working around this by storing |
Original comment by Alex Szpakowski (Bitbucket: slime73, GitHub: slime73). I can’t reproduce the issue on macOS unfortunately, and there isn’t any platform-specific code dealing with fullscreen or window positions in love itself (only in SDL). Maybe your Lua-SDL2 program called different SDL APIs than LÖVE does? |
This happen as well with window manager such as i3 |
You can reproduce it using this code:
On Windows 10 it works as expected. On linux (fedora 33) the fullscreen is removed but without resizing the window (it just add the window bar). Tested using love 11.3 from appimage and from a locally compiled one. SDL has a lot of open issues related to that: https://github.com/libsdl-org/SDL/issues?page=2&q=is%3Aissue+is%3Aopen+fullscreen+linux |
This is a minimal code to test the #include <SDL2/SDL.h>
#include <stdio.h>
#include <stdbool.h>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] )
{
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
SDL_Init(SDL_INIT_VIDEO)
window = SDL_CreateWindow( "Fullscreen test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
const Uint8 *keys;
bool keepOpen = true;
while(keepOpen)
{
SDL_Event e;
while(SDL_PollEvent(&e) > 0)
{
switch(e.type)
{
case SDL_QUIT:
keepOpen = false;
break;
case SDL_KEYDOWN:
keys = SDL_GetKeyboardState(NULL);
if(keys[SDL_SCANCODE_F] == 1) {
// press "f" to enable fullscreen
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
} else if(keys[SDL_SCANCODE_G] == 1) {
// press "g" to disable fullscreen
SDL_SetWindowFullscreen(window, 0);
}
break;
}
SDL_UpdateWindowSurface(window);
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
} If you run it with Since love 11.3 calls the same function inside the When the if (SDL_SetWindowFullscreen(window, sdlflags) == 0)
{
SDL_GL_MakeCurrent(window, context);
updateSettings(newsettings, true);
// Apparently this gets un-set when we exit fullscreen (at least in OS X).
if (!fullscreen)
SDL_SetWindowMinimumSize(window, settings.minwidth, settings.minheight);
return true;
} That function call was added in this commit. Adding a } else if(keys[SDL_SCANCODE_G] == 1) {
// press "g" to disable fullscreen
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowMinimumSize(window, SCREEN_WIDTH, SCREEN_HEIGHT); // <--- add this
} If love is compiled with the The window->min_w = min_w;
window->min_h = min_h;
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
if (_this->SetWindowMinimumSize) {
_this->SetWindowMinimumSize(_this, window);
}
/* Ensure that window is not smaller than minimal size */
SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
}
Love defaults for And SDL 2.0.14 doesn't have a Possible solutions:
Sorry for the long comment but I was just exploring love and SDL source code. |
Thanks for the detailed investigation! I haven't tested recently but I suspect the |
SDL 2.0.16 will be released soon https://github.com/libsdl-org/SDL/blob/main/WhatsNew.txt |
Someone retested this and it's still an issue as of SDL 2.0.20 |
I tested on macOS and recent SDL doesn't seem to need the SetWindowMinSize call after exiting fullscreen, so I removed it. I also opened a bug report on the SDL issue tracker about this problem. |
Original report by pragmaticus (Bitbucket: pragmaticus, GitHub: pragmaticus).
followed by
Doesn't restore the original windows size, as stated in the wiki:
If fullscreen mode is entered and the window size doesn't match one of the monitor's display modes (in normal fullscreen mode) or the window size doesn't match the desktop size (in 'desktop' fullscreen mode), the window will be resized appropriately. The window will revert back to its original size again when fullscreen mode is exited using this function.
Tested on Ubuntu 18.04
The text was updated successfully, but these errors were encountered: