diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-04-09 21:20:51 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-04-09 21:20:51 -0400 |
commit | e9a9a54540ec467a5435c0b16fe2d9692e22cf7a (patch) | |
tree | 6c139ffa0614e61aac6c27ee39664b2e63da5c76 /window-xlib.c | |
parent | c1b938e0388146dac6f82a65f6b972519cc6532b (diff) | |
download | runes-e9a9a54540ec467a5435c0b16fe2d9692e22cf7a.tar.gz runes-e9a9a54540ec467a5435c0b16fe2d9692e22cf7a.zip |
the subprocess dying should also close the window
Diffstat (limited to 'window-xlib.c')
-rw-r--r-- | window-xlib.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/window-xlib.c b/window-xlib.c index e5449a7..0e2deb9 100644 --- a/window-xlib.c +++ b/window-xlib.c @@ -14,7 +14,8 @@ static char *atom_names[RUNES_NUM_ATOMS] = { "_NET_WM_PID", "_NET_WM_ICON_NAME", "_NET_WM_NAME", - "UTF8_STRING" + "UTF8_STRING", + "WM_PROTOCOLS" }; static void runes_get_next_event(uv_work_t *req) @@ -31,6 +32,7 @@ static void runes_process_event(uv_work_t *req, int status) XEvent *e; RunesTerm *t; RunesWindowBackend *w; + int should_close = 0; UNUSED(status); @@ -67,7 +69,7 @@ static void runes_process_event(uv_work_t *req, int status) case ClientMessage: { Atom a = e->xclient.data.l[0]; if (a == w->atoms[RUNES_ATOM_WM_DELETE_WINDOW]) { - runes_handle_close_window(t); + should_close = 1; } else if (a == w->atoms[RUNES_ATOM_NET_WM_PING]) { e->xclient.window = DefaultRootWindow(w->dpy); @@ -84,10 +86,11 @@ static void runes_process_event(uv_work_t *req, int status) } } - if (t->loop) { + if (!should_close) { uv_queue_work(t->loop, req, runes_get_next_event, runes_process_event); } else { + runes_handle_close_window(t); free(req); } } @@ -201,6 +204,20 @@ void runes_window_backend_flush(RunesTerm *t) XFlush(t->w.dpy); } +void runes_window_backend_request_close(RunesTerm *t) +{ + XEvent e; + + e.xclient.type = ClientMessage; + e.xclient.window = t->w.w; + e.xclient.message_type = t->w.atoms[RUNES_ATOM_WM_PROTOCOLS]; + e.xclient.format = 32; + e.xclient.data.l[0] = t->w.atoms[RUNES_ATOM_WM_DELETE_WINDOW]; + e.xclient.data.l[1] = CurrentTime; + + XSendEvent(t->w.dpy, t->w.w, False, NoEventMask, &e); +} + void runes_window_backend_cleanup(RunesTerm *t) { RunesWindowBackend *w; |