aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-20 22:49:16 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-20 22:49:16 -0400
commit29f45358ccc638f7c2ce951e03d91bbd02d6a109 (patch)
treec21ff9bedb720bd4221b81ae653aa90dbfacd988
parent8744f9406c62994e1078d7d856713e35ee7068ac (diff)
downloadrunes-29f45358ccc638f7c2ce951e03d91bbd02d6a109.tar.gz
runes-29f45358ccc638f7c2ce951e03d91bbd02d6a109.zip
support audible bells (with a config option to disable them)
-rw-r--r--config.c4
-rw-r--r--parser.c7
-rw-r--r--parser.l7
-rw-r--r--term.h1
-rw-r--r--window-xlib.c21
-rw-r--r--window-xlib.h2
6 files changed, 39 insertions, 3 deletions
diff --git a/config.c b/config.c
index d6dd8cd..0becda1 100644
--- a/config.c
+++ b/config.c
@@ -29,6 +29,7 @@ static void runes_config_set_defaults(RunesTerm *t)
t->font_name = "monospace 10";
t->bold_is_bright = 1;
t->bold_is_bold = 1;
+ t->audible_bell = 1;
t->fgdefault = cairo_pattern_create_rgb(0.827, 0.827, 0.827);
t->bgdefault = cairo_pattern_create_rgb(0.0, 0.0, 0.0);
@@ -154,6 +155,9 @@ static void runes_config_set(RunesTerm *t, char *key, char *val)
else if (!strcmp(key, "bold_is_bold")) {
t->bold_is_bold = runes_config_parse_bool(val);
}
+ else if (!strcmp(key, "audible_bell")) {
+ t->audible_bell = runes_config_parse_bool(val);
+ }
else if (!strcmp(key, "bgcolor")) {
cairo_pattern_t *newcolor;
newcolor = runes_config_parse_color(val);
diff --git a/parser.c b/parser.c
index e067bcc..d62b442 100644
--- a/parser.c
+++ b/parser.c
@@ -2331,7 +2331,12 @@ void runes_parser_process_string(RunesTerm *t, char *buf, size_t len)
static void runes_parser_handle_bel(RunesTerm *t)
{
- runes_window_backend_request_visual_bell(t);
+ if (t->audible_bell) {
+ runes_window_backend_request_audible_bell(t);
+ }
+ else {
+ runes_window_backend_request_visual_bell(t);
+ }
}
static void runes_parser_handle_bs(RunesTerm *t)
diff --git a/parser.l b/parser.l
index 2fc1082..a4c4ced 100644
--- a/parser.l
+++ b/parser.l
@@ -232,7 +232,12 @@ void runes_parser_process_string(RunesTerm *t, char *buf, size_t len)
static void runes_parser_handle_bel(RunesTerm *t)
{
- runes_window_backend_request_visual_bell(t);
+ if (t->audible_bell) {
+ runes_window_backend_request_audible_bell(t);
+ }
+ else {
+ runes_window_backend_request_visual_bell(t);
+ }
}
static void runes_parser_handle_bs(RunesTerm *t)
diff --git a/term.h b/term.h
index c2c0b53..8f9d6a4 100644
--- a/term.h
+++ b/term.h
@@ -51,6 +51,7 @@ struct runes_term {
char inverse;
char hide_cursor;
char unfocused;
+ char audible_bell;
char application_keypad;
char application_cursor;
diff --git a/window-xlib.c b/window-xlib.c
index 70cbf22..0051fae 100644
--- a/window-xlib.c
+++ b/window-xlib.c
@@ -19,7 +19,8 @@ static char *atom_names[RUNES_NUM_ATOMS] = {
"UTF8_STRING",
"WM_PROTOCOLS",
"RUNES_FLUSH",
- "RUNES_VISUAL_BELL"
+ "RUNES_VISUAL_BELL",
+ "RUNES_AUDIBLE_BELL"
};
struct function_key {
@@ -218,6 +219,21 @@ void runes_window_backend_request_visual_bell(RunesTerm *t)
XUnlockDisplay(t->w.dpy);
}
+void runes_window_backend_request_audible_bell(RunesTerm *t)
+{
+ XEvent e;
+
+ e.xclient.type = ClientMessage;
+ e.xclient.window = t->w.w;
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = t->w.atoms[RUNES_ATOM_RUNES_AUDIBLE_BELL];
+
+ XSendEvent(t->w.dpy, t->w.w, False, NoEventMask, &e);
+ XLockDisplay(t->w.dpy);
+ XFlush(t->w.dpy);
+ XUnlockDisplay(t->w.dpy);
+}
+
void runes_window_backend_request_close(RunesTerm *t)
{
XEvent e;
@@ -423,6 +439,9 @@ static void runes_window_backend_process_event(uv_work_t *req, int status)
nanosleep(&tm, NULL);
runes_window_backend_flush(t);
}
+ else if (a == w->atoms[RUNES_ATOM_RUNES_AUDIBLE_BELL]) {
+ XBell(w->dpy, 0);
+ }
break;
}
default:
diff --git a/window-xlib.h b/window-xlib.h
index df5eabb..c7b8960 100644
--- a/window-xlib.h
+++ b/window-xlib.h
@@ -14,6 +14,7 @@ enum runes_atoms {
RUNES_ATOM_WM_PROTOCOLS,
RUNES_ATOM_RUNES_FLUSH,
RUNES_ATOM_RUNES_VISUAL_BELL,
+ RUNES_ATOM_RUNES_AUDIBLE_BELL,
RUNES_NUM_ATOMS
};
@@ -34,6 +35,7 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[]);
void runes_window_backend_start_loop(RunesTerm *t);
void runes_window_backend_request_flush(RunesTerm *t);
void runes_window_backend_request_visual_bell(RunesTerm *t);
+void runes_window_backend_request_audible_bell(RunesTerm *t);
void runes_window_backend_request_close(RunesTerm *t);
void runes_window_backend_get_size(RunesTerm *t, int *xpixel, int *ypixel);
void runes_window_backend_set_icon_name(RunesTerm *t, char *name, size_t len);