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 5119

Summary: Unexpected resize event sent by SDL_DestroyWindow, patch included
Product: SDL Reporter: Elmar <elmar>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.8   
Hardware: x86_64   
OS: Windows (All)   

Description Elmar 2020-05-01 07:04:55 UTC
Dear SDL team,

when my app left the SDL_WINDOW_FULLSCREEN mode in Windows 10 and switched back to a normal smaller window, it received a resize event to blow the normal window back up to the fullscreen resolution.

I traced it back and found that..

1) My app calls SDL_DestroyWindow when leaving fullscreen.
2) SDL_DestroyWindow calls SDL_HideWindow
3) SDL_HideWindow calls SDL_UpdateFullscreenMode(window, SDL_FALSE);
4) SDL_UpdateFullscreenMode calls SDL_OnWindowResized(window);
5) SDL_OnWindowResized sends the unexpected SDL_WINDOWEVENT_SIZE_CHANGED

I figured it is not really expected to send a SDL_WINDOWEVENT_SIZE_CHANGED event with the old window size when you want to hide a window (but maybe there is a good reason ;-), anyway I patched it away like this


>replace

SDL_OnWindowResized(SDL_Window * window)
{
    window->surface_valid = SDL_FALSE;
    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
}

>with

SDL_OnWindowResized(SDL_Window * window)
{
    window->surface_valid = SDL_FALSE;
    /* Do not generate a size change event if we are hiding the window, e.g. during SDL_DestroyWindow,
       otherwise the App will receive a resize event for the next window opened with the old size */
    if (!window->is_hiding) SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
}


This may be related to bug 4760:
https://bugzilla.libsdl.org/show_bug.cgi?id=4760

It also persists in the latest SDL 2.0.12.

Best regards,
Elmar