diff -dupr yadex-1.7.901-patched/src/gfx.cc yadex-1.7.901/src/gfx.cc --- yadex-1.7.901-patched/src/gfx.cc 2015-11-23 15:53:56.087783740 +0100 +++ yadex-1.7.901/src/gfx.cc 2015-11-23 22:17:45.876127582 +0100 @@ -114,6 +114,7 @@ int win_depth; // The depth of win int x_server_big_endian = 0; // Is the X server big endian ? int ximage_bpp; // Number of bytes per pixels in XImages int ximage_quantum;// Pad XImages lines to a multiple of that many bytes +Atom wm_delete; static pcolour_t *app_colour = 0; // Pixel values for the app. colours static int DrawingMode = 0; // 0 = copy, 1 = xor static int LineThickness = 0; // 0 = thin, 1 = thick @@ -471,6 +472,10 @@ int InitGfx (void) | ExposureMask | StructureNotifyMask); + // register for message from window manager if the window is closed + wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + XSetWMProtocols(dpy, win, &wm_delete, 1); + /* * Possibly load and query the font */ diff -dupr yadex-1.7.901-patched/src/gfx.h yadex-1.7.901/src/gfx.h --- yadex-1.7.901-patched/src/gfx.h 2005-02-06 10:45:21.000000000 +0100 +++ yadex-1.7.901/src/gfx.h 2015-11-23 22:16:10.674721105 +0100 @@ -96,6 +96,7 @@ extern int win_bpp; // The depth of extern int x_server_big_endian; // Is the X server big-endian ? extern int ximage_bpp; // Number of bytes per pixels in XImages extern int ximage_quantum; // Pad XImage lines to a mult of that many B. +extern Atom wm_delete; #endif // ifdef X_PROTOCOL #endif // ifdef Y_X11 extern int text_dot; // DrawScreenText()/DrawScreenString() debug flag diff -dupr yadex-1.7.901-patched/src/input.cc yadex-1.7.901/src/input.cc --- yadex-1.7.901-patched/src/input.cc 2006-11-03 14:49:01.000000000 +0100 +++ yadex-1.7.901/src/input.cc 2015-11-23 22:15:21.398133938 +0100 @@ -413,6 +413,12 @@ switch (ev.type) } #endif break; + + case ClientMessage: + if ((Atom)ev.xclient.data.l[0] == wm_delete) + // window has been closed, simulate ESC keypress + is.key = YK_ESC; + break; } } /* switch (ev.type) */ }