aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-05 21:55:45 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2012-09-05 21:55:45 +0200
commit62c5abf2a72e6e4f15031ad5b4e8738a6f866ea9 (patch)
tree742598f95bb0b91dce764247ee823b4bbfa32348
parenta683de536474e0870d663af7122ccad3d863379d (diff)
downloadst-patched-62c5abf2a72e6e4f15031ad5b4e8738a6f866ea9.tar.bz2
st-patched-62c5abf2a72e6e4f15031ad5b4e8738a6f866ea9.tar.xz
st-patched-62c5abf2a72e6e4f15031ad5b4e8738a6f866ea9.zip
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(+)
-rw-r--r--st.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/st.c b/st.c
index 8e31a73..bf3993a 100644
--- a/st.c
+++ b/st.c
@@ -311,6 +311,7 @@ static void brelease(XEvent *);
311static void bpress(XEvent *); 311static void bpress(XEvent *);
312static void bmotion(XEvent *); 312static void bmotion(XEvent *);
313static void selnotify(XEvent *); 313static void selnotify(XEvent *);
314static void selclear(XEvent *);
314static void selrequest(XEvent *); 315static void selrequest(XEvent *);
315 316
316static void selinit(void); 317static void selinit(void);
@@ -336,6 +337,7 @@ static void (*handler[LASTEvent])(XEvent *) = {
336 [MotionNotify] = bmotion, 337 [MotionNotify] = bmotion,
337 [ButtonPress] = bpress, 338 [ButtonPress] = bpress,
338 [ButtonRelease] = brelease, 339 [ButtonRelease] = brelease,
340 [SelectionClear] = selclear,
339 [SelectionNotify] = selnotify, 341 [SelectionNotify] = selnotify,
340 [SelectionRequest] = selrequest, 342 [SelectionRequest] = selrequest,
341}; 343};
@@ -612,6 +614,13 @@ selpaste() {
612 XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime); 614 XConvertSelection(xw.dpy, XA_PRIMARY, sel.xtarget, XA_PRIMARY, xw.win, CurrentTime);
613} 615}
614 616
617void selclear(XEvent *e) {
618 if(sel.bx == -1)
619 return;
620 sel.bx = -1;
621 tsetdirt(sel.b.y, sel.e.y);
622}
623
615void 624void
616selrequest(XEvent *e) { 625selrequest(XEvent *e) {
617 XSelectionRequestEvent *xsre; 626 XSelectionRequestEvent *xsre;