summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Smith2008-03-09 15:21:28 +0000
committerBradley Smith2008-03-09 15:21:28 +0000
commitd5c7727c2c8a3140c0276547b77f979785c8bec7 (patch)
treef2aa7a401b50d2acd88e39598002df0ee0a5ef12
parentRemove config.h.in which shouldn't be under version control. (diff)
downloadgnurobots-d5c7727c2c8a3140c0276547b77f979785c8bec7.tar.gz
Correctly handle ClientMessage.
Signed-off-by: Bradley Smith <brad@brad-smith.co.uk>
-rw-r--r--lib/x11plugin.c21
-rw-r--r--lib/x11plugin.h2
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/x11plugin.c b/lib/x11plugin.c
index f259606..a051ffa 100644
--- a/lib/x11plugin.c
+++ b/lib/x11plugin.c
@@ -150,11 +150,9 @@ x11_plugin_constructor (GType type,
#include "xpm/robot_south.xpm"
#include "xpm/robot_west.xpm"
#include "xpm/robot.xpm"
- Atom prots[6];
XClassHint classhint;
XWMHints wmhints;
XGCValues values;
- Atom delete_win;
/* Chain up to the parent first */
object = parent_class->constructor (type, n_construct_properties,
@@ -167,15 +165,16 @@ x11_plugin_constructor (GType type,
exit (1); /* Exit nicely isn't needed yet, and causes segfault */
}
- delete_win = XInternAtom (x11->dpy, "WM_DELETE_WINDOW", False);
+ x11->wm_delete_win = XInternAtom (x11->dpy, "WM_DELETE_WINDOW", False);
x11->win_width = x11->map_size->num_cols * TILE_SIZE;
x11->win_height = x11->map_size->num_rows * TILE_SIZE + 32;
x11->x_win = XCreateSimpleWindow (x11->dpy, DefaultRootWindow (x11->dpy),
0, 0, x11->win_width, x11->win_height, 0, 0, 0);
- prots[0] = delete_win;
- XSetWMProtocols (x11->dpy, x11->x_win, prots, 1);
+ XSetWMProtocols (x11->dpy, x11->x_win, &(x11->wm_delete_win), 1);
+
+ x11->wm_protocols = XInternAtom(x11->dpy, "WM_PROTOCOLS", False);
XStoreName (x11->dpy, x11->x_win, "GNU Robots");
@@ -641,6 +640,7 @@ inline void x11_plugin_update_status (X11Plugin *x11,
glong shields)
{
XEvent ev;
+ XClientMessageEvent* evt;
x11_update_status (x11, s, energy, score, shields);
@@ -658,9 +658,14 @@ inline void x11_plugin_update_status (X11Plugin *x11,
exit (0);
break;
}
- case DestroyNotify:
- case ClientMessage: /* Need to do some checks? */
- exit(0);
+ case ClientMessage:
+ evt = (XClientMessageEvent*)&ev;
+ if (evt->message_type == x11->wm_protocols
+ && evt->data.l[0] == x11->wm_delete_win)
+ {
+ g_printf("Exited\n");
+ exit(0);
+ }
break;
}
}
diff --git a/lib/x11plugin.h b/lib/x11plugin.h
index 8c9b01e..d8b4550 100644
--- a/lib/x11plugin.h
+++ b/lib/x11plugin.h
@@ -43,6 +43,8 @@ struct _X11Plugin {
Display *dpy;
Window x_win;
+ Atom wm_delete_win;
+ Atom wm_protocols;
GC gc;
GC buf_gc;
Font text;