From 26282c26699f61e22014cfc16ac34d04dff9c2db Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sat, 12 May 2018 21:22:28 -0400 Subject: [PATCH] added logic to send messages on window creation and deletion to the registrar service --- lib/x11.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/x11.c b/lib/x11.c index 4ab4fb5..8735b0e 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -45,7 +45,7 @@ struct XWin { }; /******************************************************************************/ - +static Atom XA_REGISTER, XA_DEREGISTER; static struct XWin X; static int KeyBtnState; static WinRegion Focused = EDIT; @@ -146,6 +146,22 @@ static void x11_window(char* name) { X.gc = XCreateGC(X.display, X.self, GCForeground|GCGraphicsExposures, &gcv); } +static void tide_send(char* type) { + XEvent ev; + memset(&ev, 0, sizeof (ev)); + Atom xa_registrar = XInternAtom(X.display, "TIDE_REGISTRAR", 0); + Window regwin = XGetSelectionOwner(X.display, xa_registrar); + if (None != regwin) { + ev.xclient.type = ClientMessage; + ev.xclient.window = X.self; + ev.xclient.message_type = xa_registrar; + ev.xclient.format = 32; + ev.xclient.data.l[0] = XInternAtom(X.display, type, 0); + XSendEvent(X.display, regwin, False, NoEventMask, &ev); + XFlush(X.display); + } +} + /******************************************************************************/ static uint32_t special_keys(uint32_t key) { @@ -557,7 +573,7 @@ void win_save(char* path) { void win_loop(void) { XMapWindow(X.display, X.self); - XFlush(X.display); + tide_send("ADD"); job_spawn(ConnectionNumber(X.display), xupdate, 0, 0); while (1) { job_poll(Timeout); @@ -567,8 +583,10 @@ void win_loop(void) { void win_quit(void) { static uint64_t before = 0; - if ((win_buf(EDIT)->status != MODIFIED) || (X.now - before) <= (uint64_t)ClickTime) + if ((win_buf(EDIT)->status != MODIFIED) || (X.now - before) <= (uint64_t)ClickTime) { + tide_send("DEL"); exit(0); + } before = X.now; } -- 2.49.0