[SDL] Alt-F4 not working on Windows

Pierre Phaneuf pphaneuf at gmail.com
Sat May 3 17:43:32 PDT 2008


On Sat, May 3, 2008 at 7:47 PM, Bill Kendrick <nbs at sonic.net> wrote:

>  Holy crap, people.  Can't we all just get along?  And by "get along,"
>  I mean: I suggest we DO have SDL support ALT+F4 keypresses.  It keeps MY life
>  simple. (I don't have to add "#ifdef WINDOWS if (event.type == yadayada...)"
>  in every event loop of every app, when I'm _already_ doing
>  "if (event.type == SDL_QUIT)")

Traditionally, in GUI toolkit, what happens is that either the
application provides a callback to the toolkit that gets called for
each messages and returns whether the application handled the message
or not, or there is a "get message" function, and an application is
supposed to call some "dispatch message" if it's not a message that it
found "interesting" (i.e. it didn't handle it). SDL does *not* provide
this mechanism: either the application handles the message, or it's
dropped on the floor without further processing.

If I remember correctly, what happens on Windows is that the
application gets the Alt-F4 key pressed (well, okay, released,
actually, if I'm not mistaken, but you get the idea) message, and if
you want to do something with it, you do so, and don't call
DispatchMessage. If your application didn't handle it and calls
DispatchMessage, it will post itself a WM_DESTROY (or WM_CLOSE? I
don't remember) message, which the application will then shortly
receive.

IMHO, the *real* bug is that SDL doesn't have this structure that
usually handles that case, making it just plain hard in general to
"fit in" and forcing applications to re-implement those default
behaviours itself, and often in weird ways (the game I work on,
Quadra, quits with Alt-F4 on every platforms!).

Note that someone used to Xlib programming might think that this is
incorrect (there is no equivalent to DispatchEvent in Xlib), but it's
just that Xlib is at lower level. The morally equivalent layer would
be Xt (among others, X11 is well known for giving a lot of choices,
for better or for worse), where you will find that an application does
XtAppNextEvent and XtAppDispatchEvent.

-- 
http://pphaneuf.livejournal.com/


More information about the SDL mailing list