diff options
author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-05 21:55:45 +0200 |
---|---|---|
committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-05 21:55:45 +0200 |
commit | f471a32d29ad9e5e06cf5e5d5efc8422483f535e (patch) | |
tree | 742598f95bb0b91dce764247ee823b4bbfa32348 /st.c | |
parent | 017af76f5c89fa1acf9b54ceaad2101dcfd880a0 (diff) | |
download | st-f471a32d29ad9e5e06cf5e5d5efc8422483f535e.tar.gz st-f471a32d29ad9e5e06cf5e5d5efc8422483f535e.tar.bz2 st-f471a32d29ad9e5e06cf5e5d5efc8422483f535e.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(+)
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -311,6 +311,7 @@ static void brelease(XEvent *); static void bpress(XEvent *); static void bmotion(XEvent *); static void selnotify(XEvent *); +static void selclear(XEvent *); static void selrequest(XEvent *); static void selinit(void); @@ -336,6 +337,7 @@ static void (*handler[LASTEvent])(XEvent *) = { [MotionNotify] = bmotion, [ButtonPress] = bpress, [ButtonRelease] = brelease, + [SelectionClear] = selclear, [SelectionNotify] = selnotify, [SelectionRequest] = selrequest, }; @@ -612,6 +614,13 @@ selpaste() { 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; |