We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5400

Summary: No SDL_WINDOWEVENT_RESIZED event after after leaving fullscreen on Windows
Product: SDL Reporter: Roman Shuvalov <roman>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: x86_64   
OS: Windows (All)   

Description Roman Shuvalov 2020-12-16 18:42:42 UTC
After leaving fullscreen (SDL_SetWindowFullscreen(window, 0)), SDL_WINDOWEVENT_RESIZED event appears on Linux version but doesn't appear on Windows.

Minimal program to reproduce error:

// ------

#include <SDL2/SDL.h>

SDL_Window* window;
int fs = 0;

void toggle_fs() {
    fs ^= 1;
    printf("Setting fullscreen to %d\n", fs);
    SDL_SetWindowFullscreen( window, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
};

int main (int argc, char ** args) {

    if( SDL_Init( SDL_INIT_EVERYTHING ) != 0 ) {
        return 1;
    };
    window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 400, 300, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE );
    if ( window == NULL ) {
        return 1;
    };
    int quit = 0;
    SDL_Event e;
    while ( !quit ) {
        while( SDL_PollEvent( &e ) != 0 ) {
            if ( e.type == SDL_KEYDOWN ) {
                toggle_fs();
            }
            else if (e.type == SDL_WINDOWEVENT) {
                if (e.window.event == SDL_WINDOWEVENT_RESIZED) {
                    printf("Got SDL_WINDOWEVENT_RESIZED event\n");
                };
            }
            else if( e.type == SDL_QUIT ) {
                quit = 1;
            };
        };
        SDL_Delay(100);
    };
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
};

// ------

Results on Linux:

Setting fullscreen to 1
Got SDL_WINDOWEVENT_RESIZED event
Setting fullscreen to 0
Got SDL_WINDOWEVENT_RESIZED event
Setting fullscreen to 1
Got SDL_WINDOWEVENT_RESIZED event
Setting fullscreen to 0
Got SDL_WINDOWEVENT_RESIZED event

Results on Windows:

Setting fullscreen to 1
Got SDL_WINDOWEVENT_RESIZED event
Setting fullscreen to 0
Setting fullscreen to 1
Got SDL_WINDOWEVENT_RESIZED event
Setting fullscreen to 0
Comment 1 Roman Shuvalov 2020-12-16 19:53:02 UTC
Also, SDL_GetWindowSize() after SDL_SetWindowFullscreen() on Windows returns new size, but on Linux it returns previous size which is not actual.