st-visualbell-20180101-1f24bde.diff (1508B)
1 diff --git a/st.c b/st.c 2 index 7c7ddff..2dc10c2 100644 3 --- a/st.c 4 +++ b/st.c 5 @@ -218,6 +218,7 @@ char *opt_line = NULL; 6 char *opt_name = NULL; 7 char *opt_title = NULL; 8 int oldbutton = 3; /* button event on startup: 3 = release */ 9 +int bellon = 0; 10 11 static CSIEscape csiescseq; 12 static STREscape strescseq; 13 @@ -2187,8 +2188,7 @@ tcontrolcode(uchar ascii) 14 } else { 15 if (!(win.state & WIN_FOCUSED)) 16 xseturgency(1); 17 - if (bellvolume) 18 - xbell(bellvolume); 19 + xbell(bellvolume); 20 } 21 break; 22 case '\033': /* ESC */ 23 diff --git a/st.h b/st.h 24 index 44d4938..24a6eb6 100644 25 --- a/st.h 26 +++ b/st.h 27 @@ -231,6 +231,7 @@ extern char *opt_line; 28 extern char *opt_name; 29 extern char *opt_title; 30 extern int oldbutton; 31 +extern int bellon; 32 33 extern char *usedfont; 34 extern double usedfontsize; 35 diff --git a/x.c b/x.c 36 index c484dfc..0b59d0e 100644 37 --- a/x.c 38 +++ b/x.c 39 @@ -1484,7 +1484,17 @@ xseturgency(int add) 40 void 41 xbell(int vol) 42 { 43 - XkbBell(xw.dpy, xw.win, vol, (Atom)NULL); 44 + if (vol) 45 + XkbBell(xw.dpy, xw.win, vol, (Atom)NULL); 46 + 47 + /* visual bell*/ 48 + if (!bellon) { 49 + bellon = 1; 50 + MODBIT(term.mode, !IS_SET(MODE_REVERSE), MODE_REVERSE); 51 + redraw(); 52 + XFlush(xw.dpy); 53 + MODBIT(term.mode, !IS_SET(MODE_REVERSE), MODE_REVERSE); 54 + } 55 } 56 57 unsigned long 58 @@ -1676,7 +1686,12 @@ run(void) 59 (handler[ev.type])(&ev); 60 } 61 62 - draw(); 63 + if (bellon) { 64 + bellon = 0; 65 + redraw(); 66 + } 67 + else draw(); 68 + 69 XFlush(xw.dpy); 70 71 if (xev && !FD_ISSET(xfd, &rfd)) 72 -- 73 2.15.1 74