Skip to content

Linux: unexpected window size when setting minimum window size after exiting fullscreen #5233

@slime73

Description

@slime73

I have a report on my issue tracker here love2d/love#1444 about a problem when SDL_SetWindowFullscreen(window, 0) is called. Our code was calling SetWindowMinimumSize directly after that SetFullscreen call, which on Linux apparently prevents the window from downsizing to its original size after it was fullscreen.

I don't have a Linux setup to test myself, but this code (according to the issue comments) might reproduce it:

#include <SDL.h>
#include <stdio.h>

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;

int main(int argc, char* argv[])
{
    SDL_Window *window = NULL;
    SDL_Renderer *renderer = NULL;
    int quit = 0;
    Uint32 flags = SDL_WINDOW_SHOWN;

    SDL_Init(SDL_INIT_VIDEO);
    SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, flags, &window, &renderer);

    SDL_SetWindowMinimumSize(window, WINDOW_WIDTH, WINDOW_HEIGHT);
    SDL_RenderSetVSync(renderer, 1);

    while (!quit)
    {
        SDL_Event e;
        while (SDL_PollEvent(&e) > 0)
        {
          switch (e.type)
          {
            case SDL_QUIT:
                quit = 1;
                break;
            case SDL_KEYDOWN:
                if (e.key.keysym.scancode == SDL_SCANCODE_F) {
                    // press "f" to enable fullscreen
                    SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
                } if (e.key.keysym.scancode == SDL_SCANCODE_G) {
                    // press "g" to disable fullscreen
                    SDL_SetWindowFullscreen(window, 0);

                    // Problem call is here:
                    SDL_SetWindowMinimumSize(window, WINDOW_WIDTH, WINDOW_HEIGHT);
                }
                break;
            }
        }

        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
    }

    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}

The issue doesn't occur on macOS. If you're not able to reproduce it on Linux I can try to help narrow it down.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions