X bug fix so that window closes properly when using a window manager

ugfx_release_2.6
inmarket 2014-09-29 16:00:17 +10:00
parent 6b158b8a0b
commit a9e802395e
1 changed files with 9 additions and 0 deletions

View File

@ -81,6 +81,7 @@ static XEvent evt;
static Colormap cmap;
static XVisualInfo vis;
static XContext cxt;
static Atom wmDelete;
typedef struct xPriv {
Pixmap pix;
@ -103,6 +104,12 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
XCloseDisplay(dis);
exit(0);
break;
case ClientMessage:
if ((Atom)evt.xclient.data.l[0] == wmDelete) {
XCloseDisplay(dis);
exit(0);
}
break;
case Expose:
XCopyArea(dis, priv->pix, evt.xexpose.window, priv->gc,
evt.xexpose.x, evt.xexpose.y,
@ -184,6 +191,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
dis = XOpenDisplay(0);
scr = DefaultScreen(dis);
cxt = XUniqueContext();
wmDelete = XInternAtom(dis, "WM_DELETE_WINDOW", False);
XSetIOErrorHandler(FatalXIOError);
#if GDISP_FORCE_24BIT
@ -227,6 +235,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
XSync(dis, TRUE);
XSaveContext(dis, priv->win, cxt, (XPointer)g);
XSetWMProtocols(dis, priv->win, &wmDelete, 1);
{
char buf[132];