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 4821

Summary: No restore event is emitted after unminimize
Product: SDL Reporter: ryven <ryven.mt>
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: asmith, sezeroz
Version: 2.0.10Keywords: target-2.0.12
Hardware: x86_64   
OS: Linux   
Attachments: Patch to fix the issue.

Description ryven 2019-10-08 19:59:13 UTC
At least on X11, no SDL_WINDOWEVENT_RESTORED event is emitted after the window was unminimized.

This was caused by this commit:
https://github.com/SDL-mirror/SDL/commit/abcfcda0fcc3cdfac632077492b91041acd8890d

Reason:
In X11_DispathEvent on PropertyNotify on _NET_WM_STATE property change, if unminimized is happens, X11_DispatchMapNotify is called:
https://github.com/SDL-mirror/SDL/blob/master/src/video/x11/SDL_x11events.c#L1295 

X11_DispatchMapNotify tries to emit two events: 
* first SDL_SendWindowEvent(SDL_WINDOWEVENT_SHOWN) which resets the minimized flag (see commit),
* then SDL_SendWindowEvent(SDL_WINDOWEVENT_RESTORED) which expects minimized flag set, but it was reset by previous SHOWN event and hence it bails out not emitting RESTORED event:
https://github.com/SDL-mirror/SDL/blob/master/src/events/SDL_windowevents.c#L142
Comment 1 Alex Smith 2019-12-02 15:46:31 UTC
I ran into this issue today. The attached patch fixes it for me.
Comment 2 Alex Smith 2019-12-02 15:47:05 UTC
Created attachment 4085 [details]
Patch to fix the issue.
Comment 3 Sam Lantinga 2019-12-04 05:56:19 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/81ca537d1287