aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2023-02-15 10:45:48 +0100
committerdavidpkj <davidpenkow1@gmail.com>2023-02-15 11:03:30 +0100
commit354bf243ff0b3e93e890f3ee34cb85ba95135e8d (patch)
treeafee318346528eb02e13e0045840188427bbc38d /x.c
parentb584a094eeb9fc96cc066471e367da6807ba24bf (diff)
Patch: visualbell2-basic-2020-05-13
Diffstat (limited to 'x.c')
-rw-r--r--x.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/x.c b/x.c
index ff4e284..39af5da 100644
--- a/x.c
+++ b/x.c
@@ -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;