From: Michael D. Lowis Date: Sat, 6 Oct 2018 03:09:34 +0000 (-0400) Subject: added selection persistence logic on shutdown X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=67dd56cf6dd7d1c0da671684c1af1ce667feeb8f;p=projs%2Ftide.git added selection persistence logic on shutdown --- diff --git a/lib/x11.c b/lib/x11.c index 6afd01a..54f57a5 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -429,6 +429,11 @@ static void xselclear(XEvent* e) { sel->text = NULL; } +static void xselquit(XEvent* e) { + xselclear(e); + exit(0); +} + static void xselnotify(XEvent* e) { /* bail if the selection cannot be converted */ if (e->xselection.property == None) @@ -612,7 +617,10 @@ void win_quit(void) { static uint64_t before = 0; if ((win_buf(EDIT)->status != MODIFIED) || (X.now - before) <= (uint64_t)ClickTime) { tide_send("DEL"); - exit(0); + EventHandlers[SelectionClear] = xselquit; + XUnmapWindow(X.display, X.self); + if (!Selections[PRIMARY].text && !Selections[CLIPBOARD].text) + exit(0); } before = X.now; }