[hackers] [st] Unhighlight selection when selection is owner by other window || "Roberto E. Vargas Caballero"

From: <hg_AT_suckless.org>
Date: Wed, 5 Sep 2012 22:19:29 +0200 (CEST)

changeset: 284:07a1189fbf89
user: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>
date: Wed Sep 05 21:55:45 2012 +0200
files: st.c
description:
Unhighlight selection when selection is owner by other window
st marks the active selection using reverse colors in the box selection, but
once that another window becomes owner of the selection, it is very
confusing that st keeps highlight the old selection. Usually terminal
emulators remove the highlight when it is not valid anymore.

X sends a SelectionClear event in this situation, so we only have to add a
callback which unhighlight the selectin box.
---
 st.c |    9 +++++++++
 1 file changed, 9 insertions(+)
diff -r a15194f48b1c -r 07a1189fbf89 st.c
--- a/st.c	Wed Sep 05 21:54:52 2012 +0200
+++ b/st.c	Wed Sep 05 21:55:45 2012 +0200
_AT_@ -311,6 +311,7 @@
 static void bpress(XEvent *);
 static void bmotion(XEvent *);
 static void selnotify(XEvent *);
+static void selclear(XEvent *);
 static void selrequest(XEvent *);
 
 static void selinit(void);
_AT_@ -336,6 +337,7 @@
 	[MotionNotify] = bmotion,
 	[ButtonPress] = bpress,
 	[ButtonRelease] = brelease,
+	[SelectionClear] = selclear,
 	[SelectionNotify] = selnotify,
 	[SelectionRequest] = selrequest,
 };
_AT_@ -612,6 +614,13 @@
 	XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime);
 }
 
+void selclear(XEvent *e) {
+	if(sel.bx == -1)
+		return;
+	sel.bx = -1;
+	tsetdirt(sel.b.y, sel.e.y);
+}
+
 void
 selrequest(XEvent *e) {
 	XSelectionRequestEvent *xsre;
Received on Wed Sep 05 2012 - 22:19:29 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 05 2012 - 22:24:08 CEST