]> git.mdlowis.com Git - projs/tide.git/commitdiff
added selection persistence logic on shutdown
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 6 Oct 2018 03:09:34 +0000 (23:09 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 6 Oct 2018 03:09:34 +0000 (23:09 -0400)
lib/x11.c

index 6afd01ab50339fea4ae4c81c4cfb2a4b629b4487..54f57a531482fa14b3242e293dc9b5a6b68a667e 100644 (file)
--- 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;
 }