sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-visualbell-20170924-b1338e9.diff (1194B)


      1 diff --git a/st.c b/st.c
      2 index 7c7ddff..a3dffe5 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 diff --git a/st.h b/st.h
     14 index 44d4938..24a6eb6 100644
     15 --- a/st.h
     16 +++ b/st.h
     17 @@ -231,6 +231,7 @@ extern char *opt_line;
     18  extern char *opt_name;
     19  extern char *opt_title;
     20  extern int oldbutton;
     21 +extern int bellon;
     22  
     23  extern char *usedfont;
     24  extern double usedfontsize;
     25 diff --git a/x.c b/x.c
     26 index 191e5dc..7be81ea 100644
     27 --- a/x.c
     28 +++ b/x.c
     29 @@ -1483,6 +1483,15 @@ void
     30  xbell(int vol)
     31  {
     32  	XkbBell(xw.dpy, xw.win, vol, (Atom)NULL);
     33 +
     34 +	/* visual bell*/
     35 +	if (!bellon) {
     36 +		bellon = 1;
     37 +		MODBIT(term.mode, !IS_SET(MODE_REVERSE), MODE_REVERSE);
     38 +		redraw();
     39 +		XFlush(xw.dpy);
     40 +		MODBIT(term.mode, !IS_SET(MODE_REVERSE), MODE_REVERSE);
     41 +	}
     42  }
     43  
     44  unsigned long
     45 @@ -1674,7 +1683,12 @@ run(void)
     46  					(handler[ev.type])(&ev);
     47  			}
     48  
     49 -			draw();
     50 +			if (bellon) {
     51 +				bellon = 0;
     52 +				redraw();
     53 +			}
     54 +			else draw();
     55 +
     56  			XFlush(xw.dpy);
     57  
     58  			if (xev && !FD_ISSET(xfd, &rfd))