WM_DELETE_WINDOW does not send ClientMessage

Roland Plüss roland at rptd.ch
Sun Jan 19 12:33:51 UTC 2020

I'm finishing up my software for releasing but run into a big issue. If
I use window mode instead of full-screen mode the user should be able to
close the window using the X button. I can prevent this from happening
using this code:

Atom delAtom = XInternAtom( display, "WM_DELETE_WINDOW", False );
XSetWMProtocols( display, pWindow, &delAtom, 1 );

The window will not be destroyed when X is pressed so I think this
worked. The problem is though that I do not received ClientMessage and
thus I am unable to close the window. This is the event loop:

XEvent event;
while( XPending( pDisplay ) ){
   XNextEvent( pDisplay, &event );
   log("Event %d", event.type);
   switch( event.type ){
   case ClientMessage:
      log("Quit Request Received");

Window is created like this:

#define BASIC_EVENT_MASK     ( StructureNotifyMask | ExposureMask |
PropertyChangeMask \
                             | EnterWindowMask | LeaveWindowMask |
KeyPressMask \
                             | KeyReleaseMask | KeymapStateMask |
FocusChangeMask )

#define NOT_PROPAGATE_MASK   ( KeyPressMask | KeyReleaseMask |
ButtonPressMask \
                             | ButtonReleaseMask | PointerMotionMask |
ButtonMotionMask )

XSetWindowAttributes swa;
swa.colormap = colMap;
swa.backing_store = NotUseful;
swa.border_pixel = 0;
swa.event_mask = BASIC_EVENT_MASK;
swa.do_not_propagate_mask = NOT_PROPAGATE_MASK;
swa.override_redirect = False;
swa.save_under = False;
swa.cursor = 0;
swa.bit_gravity = ForgetGravity;
swa.win_gravity = NorthWestGravity;

Any idea what else I need to do to get this working?

Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- As well as various Blender export scripts und game tools
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <https://lists.x.org/archives/xorg/attachments/20200119/c511b89f/attachment.sig>

More information about the xorg mailing list