foxygit / dotfiles Log in
commits tags

/st-patches/03-clipboard.patch · 628 B

raw
diff --git a/x.c b/x.c
index f0c0837..5fba5db 100644
--- a/x.c
+++ b/x.c
@@ -679,6 +679,8 @@ selrequest(XEvent *e)
 void
 setsel(char *str, Time t)
 {
+	char *p;
+
 	if (!str)
 		return;
 
@@ -688,6 +690,15 @@ setsel(char *str, Time t)
 	XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
 	if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
 		selclear();
+
+	/* an empty or whitespace-only selection (a click that jittered, a
+	 * drag over blank cells) must not overwrite CLIPBOARD */
+	for (p = str; *p; p++) {
+		if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') {
+			xclipcopy();
+			break;
+		}
+	}
 }
 
 void