At the time, I had only implemented the extension for Windows, and promised to revisit this one for Linux. As it turns out, implementing it on Linux was extremely simple, because the Linux implementation of freeglut already had 99% of what was necessary to get this to work. This means that it is very likely that this will work for other *nix/X11 implementations with no additional work, but I don't have access to such environments, so I cannot tell with certainty.
Anyway, as I said, the implementation is very simple. I merely copied the Windows portion that does the callback into glutMainLoopEvent's handler for ClientMessage events. More specifically, for fgDisplay.DeleteWindow ClientMessage events:
case ClientMessage:
/* Destroy the window when the WM_DELETE_WINDOW message arrives */
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
{
GETWINDOW( xclient );
#ifdef GLUTTON
{
int Action = gluttonCloseRequestedDefault;
INVOKE_WCB( *window , GluttonCloseRequested , ( &Action ) );
switch( Action )
{
case gluttonCloseRequestedDefault: break;
/* proceed to close the window (fgDestroyWindow, below) */
case gluttonCloseRequestedIgnore: return;
/* ignore the message. */
}
}
#endif
fgDestroyWindow ( window );
I honestly didn't expect this to be as easy as it was. I was expecting to have to go through the pain of telling X that I wanted it to send a ClientMessage to glutton, and to deal with finding all of the "atoms" involved. Many thanks to the freeglut developers for relieving me of /that/ burden!
Next time: keystroke management for linux. [ Edit: No need - I cannot reproduce the keystroke bug on Fedora 8, so I won't be spending my time on trying to fix it :-) ]
No comments:
Post a Comment