Skip to content

Fullscreen windows minimized on focus loss don't restore correctly in Wine #5320

@madewokherd

Description

@madewokherd

In SDL 2.0.18 on Wine, if a fullscreen window loses focus and is minimized, it's no longer restored fullscreen.

I don't think this technically a regression, as previous versions did not notice the focus loss at all. So minimization would've always caused this problem, it just never happened before. When SDL minimizes its own window, it unsets fullscreen first and, in Wine specifically, it fails to set it to fullscreen on restore.

I haven't been able to figure out exactly why this is. SDL definitely requests that its window be resized/moved to fullscreen. Wine responds by requesting a resize/move and requesting NET_WM_STATE_FULLSCREEN. Yet for some reason, afterwards we get a ConfigureNotify with the old size/position, and the window is never changed back to fullscreen. So it looks like a window manager bug to me, but I don't know what we could be doing to cause this behavior.

Test case:

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

int wmain(int argc, wchar_t* argv[])
{
    SDL_Window *window;
    int is_fullscreen = 0;

    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "1");

    window = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 240, 0);

    if (!window)
        return 1;

    while (1)
    {
        SDL_Event event;

        if (SDL_WaitEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT:
                printf("got SDL_QUIT\n");
                SDL_DestroyWindow(window);
                SDL_Quit();
                return 0;
            case SDL_MOUSEBUTTONDOWN:
                is_fullscreen = !is_fullscreen;
                printf("Setting fullscreen: %i\n", is_fullscreen);
                SDL_SetWindowFullscreen(window, is_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
                printf("Done setting fullscreen\n");
                break;
            default:
                break;
            }
        }
        else
        {
            printf("SDL_WaitEvent failed %s\n", SDL_GetError());
        }
    }

    return 0;
}

int main(int argc, char* argv[])
{
    return wmain(0, NULL);
}

To reproduce the bug:

  • Run the test program in Wine.
  • Click the window to fullscreen.
  • Alt+tab to switch away.
  • Switch back.
  • Window is borderless 320x240, rather than fullscreen.

This doesn't happen on X11, even though SDL should interact with the window manager in the same way, and the window is not fullscreen when minimized. I don't know why.

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