From 2cc6d7ab9e11ad04d9f71775a692ca17fd708f99 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 3 Jan 2021 18:32:07 -0800 Subject: vmon: handle WM_DELETE_WINDOW client messages This makes vmon exit more cooperatively when window managers kindly ask it to with a message rather than requiring XKillClient(). --- src/vmon.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vmon.c b/src/vmon.c index bcdeb0a..2c04842 100644 --- a/src/vmon.c +++ b/src/vmon.c @@ -37,6 +37,8 @@ typedef struct vmon_t { vwm_xserver_t *xserver; vwm_charts_t *charts; vwm_chart_t *chart; + Atom wm_protocols_atom; + Atom wm_delete_atom; Window window; int width, height; Picture picture; @@ -309,6 +311,9 @@ static vmon_t * vmon_startup(int argc, char * const argv[]) goto _err_free; } + vmon->wm_delete_atom = XInternAtom(vmon->xserver->display, "WM_DELETE_WINDOW", False); + vmon->wm_protocols_atom = XInternAtom(vmon->xserver->display, "WM_PROTOCOLS", False); + vmon->charts = vwm_charts_create(vmon->xserver); if (!vmon->charts) { VWM_ERROR("unable to create charts instance"); @@ -387,9 +392,21 @@ static void vmon_process_event(vmon_t *vmon) vwm_chart_compose(vmon->charts, vmon->chart, NULL); vwm_chart_render(vmon->charts, vmon->chart, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height); break; + case Expose: vwm_chart_render(vmon->charts, vmon->chart, PictOpSrc, vmon->picture, 0, 0, vmon->width, vmon->height); break; + + case ClientMessage: + if (ev.xclient.message_type != vmon->wm_protocols_atom) + break; + + if (ev.xclient.data.l[0] != vmon->wm_delete_atom) + break; + + vmon->done = 1; + break; + default: VWM_TRACE("unhandled event: %x\n", ev.type); } -- cgit v1.2.3