SDL2’s X11 target now respects the _NET_WM_PING protocol, which means
that if you fail to process the event loop, the Window Manager may now,
at its discretion, kill your app.

How this works in practice is this:

  • When creating a window, SDL tells the window manager that it knows
    about _NET_WM_PING.
  • If you stop handling events (such as, your program is hung up), and
    the user tries to close the window, the Window Manager will notice it
    didn’t actually close after a short time and send a “ping” event to SDL,
    which responds to the ping next time you call SDL_PollEvent().
  • If you’re pumping the event loop and had a good reason to not close
    the window, your app is left alone. If you don’t pump the event loop,
    it’s possible your process will be terminated…usually the Window
    Manager should prompt the user with a “hey, we think this program is
    broken, should I kill it?” dialog first.

For Ubuntu users, it looks like Unity supports this behavior, but
Unity2D does not (it’ll just leave your window alone in all cases). I
don’t know what Gnome/KDE/XFCE/etc do at the moment.

What this means for you:

  • Most apps don’t need to do anything. Those that do need to do
    something are already poorly behaved, and should be fixed in any case.
    This change just makes the app a better desktop citizen.
  • If you aren’t listening for SDL_WINDOWEVENT (subtype
    SDL_WINDOWEVENT_CLOSE), you should handle it, presumably by destroying
    the window. If you have only one window ever, you can watch for SDL_QUIT
    instead, if you like, and terminate your app in response…this is more
    like how SDL 1.2 works.
  • If you aren’t pumping the event queue regularly by calling
    SDL_PollEvent(), you should. It’s better to handle events during a long
    processing job, if you can, so the window is still responsive. If you
    wait too long, the user might get a "do you want to kill this program?"
    message that will go away when your app finishes working and starts
    processing events again. This is better than nothing, but it’s better to
    never see this message.
  • Most other OSes already do this without an opt-in mechanism like X11,
    so fix your app!