diff options
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -1704,6 +1704,27 @@ xsettitle(char *p) XFree(prop.value); } + +static int vbellset = 0; /* 1 during visual bell, 0 otherwise */ +static struct timespec lastvbell = {0}; + +static int +isvbellcell(int x, int y) +{ + int right = win.tw / win.cw - 1, bottom = win.th / win.ch - 1; + return VBCELL; /* logic condition defined at config.h */ +} + +static void +vbellbegin() { + clock_gettime(CLOCK_MONOTONIC, &lastvbell); + if (vbellset) + return; + vbellset = 1; + redraw(); + XFlush(xw.dpy); +} + int xstartdraw(void) { @@ -1725,6 +1746,8 @@ xdrawline(Line line, int x1, int y1, int x2) continue; if (selected(x, y1)) new.mode ^= ATTR_REVERSE; + if (vbellset && isvbellcell(x, y1)) + new.mode ^= ATTR_REVERSE; if (i > 0 && ATTRCMP(base, new)) { xdrawglyphfontspecs(specs, base, i, ox, y1); specs += i; @@ -1828,6 +1851,8 @@ xbell(void) xseturgency(1); if (bellvolume) XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); + if (vbelltimeout) + vbellbegin(); } void @@ -2080,6 +2105,16 @@ run(void) } } + if (vbellset) { + double remain = vbelltimeout - TIMEDIFF(now, lastvbell); + if (remain <= 0) { + vbellset = 0; + redraw(); + } else if (timeout < 0 || remain < timeout) { + timeout = remain; + } + } + draw(); XFlush(xw.dpy); drawing = 0; |