RMB to close window

SDLers,
SDL-1.1.8, SDL-image 1.1.0, linux rh6.2

I can open a window, display stuff in it, and everything is nice.

Then I start to check for events.
I can detect key clicks in the SDL window
I can detect when the user clicks with the left mouse button on the cross
at the top right of the SDL window.
(just look for events of type SDL_QUIT returned from SDL_PollEvent() )

All works fine, until the user selects the cross with the right mouse button.
You get messages like:
X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
Major opcode of failed request: 129 (MIT-SHM)
Minor opcode of failed request: 3 (X_ShmPutImage)
Resource id in failed request: 0x440000c
Serial number of failed request: 98
Current serial number in output stream: 99
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 10 (X_UnmapWindow)
Resource id in failed request: 0x4400002
Serial number of failed request: 83
Current serial number in output stream: 88

I looked at several packages, eggchess, bugsquish, flywindows (apologies to authors
for naming your packages) and each produced the same error message on using the
right mouse button to close/destroy the window.

Sure, I can do some fancy things with wm_delete_atom (under X) to trap for RMB.
But, I want to be cross platform in the software.
So how does one trap the RMB on the cross under SDL ???

Thanks in advance,
Derek.

I can detect when the user clicks with the left mouse button on the cross
at the top right of the SDL window.

there is no such cross in general, it must be a decoration of your own
window manager, which completely determines its semantics. SDL handles
the WM_DELETE protocol which is the usual way of closing a window from
a window manager

if you forcibly kill the window (via your WM or an other client such
as xkill) then SDL does not attempt to handle this gracefully since
doing so is a lot of complexity for little gain. Almost no X11 apps do
this at all since it’s an emergency thing - you can see it as the X11
window equivalent of sending a SIGKILL