SDL_WINDOWEVENT_SHOWN or SDL_WINDOWEVENT_EXPOSED?

Viewed 334

What is the difference between these two window event types? I've looked at this documentation, but it didn't give very detailed descriptions. I'm trying to get an SDL application to redraw itself after being un-minimized, and my current solution is to handle both event types. Handling just SDL_WINDOWEVENT_EXPOSED does not work on Ubuntu MATE 1.24.0.

1 Answers

When using Xorg the SDL_WINDOWEVENT_SHOWN is generated by SDL at least in the following cases:

  1. When a MapNotify event is received from the X server;
  2. When the window looses the SDL_WINDOW_HIDDEN flag;
  3. When the window gains the SDL_WINDOW_FULLSCREEN flag;

In regards to cases 2 and 3 the comment in SDL source code mentions:

... Compositing window managers can alter visibility of windows without ever mapping / unmapping them, so we handle that here ...

Per the X Window System Glossary unmapped windows are never shown:

A window is said to be mapped if a map call has been performed on it. Unmapped windows and their inferiors are never viewable or visible.

The SDL_WINDOWEVENT_EXPOSED event is generated by the SDL when it receives the Expose event from the X server.

The X Window System Glossary says this about the "exposure" events:

Servers do not guarantee to preserve the contents of windows when windows are obscured or reconfigured. Exposure events are sent to clients to inform them when contents of regions of windows have been lost.

Based on this data it appears that the SDL_WINDOWEVENT_SHOWN event will be generated whenever a window changes state from hidden to visible and the SDL_WINDOWEVENT_EXPOSED event will be generated when any part of the window becomes obscured.

Related