csi: implement ‘CSI ? 1042 h/l’ - enable/disable bell-is-urgent

This commit is contained in:
Daniel Eklöf 2020-10-11 17:44:29 +02:00
parent c650862b0d
commit 17761dce63
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 21 additions and 10 deletions

View file

@ -23,8 +23,10 @@
(https://codeberg.org/dnkl/foot/issues/150). (https://codeberg.org/dnkl/foot/issues/150).
* **bell** option to `foot.ini`. Can be set to `set-urgency` to make * **bell** option to `foot.ini`. Can be set to `set-urgency` to make
foot render the margins in red when receiving `BEL` while **not** foot render the margins in red when receiving `BEL` while **not**
having keyboard focus. Note that Wayland does **not** implement an having keyboard focus. Applications can dynamically enable/disable
_urgency_ hint like X11, but that there is a this with the `CSI ? 1042 h` and `CSI ? 1042 l` escape
sequences. Note that Wayland does **not** implement an _urgency_
hint like X11, but that there is a
[proposal](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9) [proposal](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9)
to add support for this. The value `set-urgency` was chosen for to add support for this. The value `set-urgency` was chosen for
forward-compatibility, in the hopes that this proposal eventualizes forward-compatibility, in the hopes that this proposal eventualizes

View file

@ -519,14 +519,14 @@ parse_section_main(const char *key, const char *value, struct config *conf,
else if (strcmp(key, "bell") == 0) { else if (strcmp(key, "bell") == 0) {
if (strcmp(value, "set-urgency") == 0) if (strcmp(value, "set-urgency") == 0)
conf->bell_set_urgency = true; conf->bell_is_urgent = true;
else if (strcmp(value, "none") == 0) else if (strcmp(value, "none") == 0)
conf->bell_set_urgency = false; conf->bell_is_urgent = false;
else { else {
LOG_AND_NOTIFY_ERR( LOG_AND_NOTIFY_ERR(
"%s:%d: [default]: bell: " "%s:%d: [default]: bell: "
"expected either 'set-urgency' or 'none'", path, lineno); "expected either 'set-urgency' or 'none'", path, lineno);
conf->bell_set_urgency = false; conf->bell_is_urgent = false;
return false; return false;
} }
} }
@ -1902,7 +1902,7 @@ config_load(struct config *conf, const char *conf_path,
}, },
.pad_x = 2, .pad_x = 2,
.pad_y = 2, .pad_y = 2,
.bell_set_urgency = false, .bell_is_urgent = false,
.startup_mode = STARTUP_WINDOWED, .startup_mode = STARTUP_WINDOWED,
.fonts = tll_init(), .fonts = tll_init(),
.scrollback = { .scrollback = {

View file

@ -73,7 +73,7 @@ struct config {
unsigned pad_x; unsigned pad_x;
unsigned pad_y; unsigned pad_y;
bool bell_set_urgency; bool bell_is_urgent;
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode; enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;

6
csi.c
View file

@ -476,11 +476,11 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
term->meta.esc_prefix = enable; term->meta.esc_prefix = enable;
break; break;
#if 0
case 1042: case 1042:
LOG_WARN("unimplemented: 'urgency' window manager hint on ctrl-g"); term->bell_is_urgent = enable;
break; break;
#if 0
case 1043: case 1043:
LOG_WARN("unimplemented: raise window on ctrl-g"); LOG_WARN("unimplemented: raise window on ctrl-g");
break; break;
@ -593,6 +593,7 @@ xtsave(struct terminal *term, unsigned param)
case 1015: term->xtsave.mouse_urxvt = term->mouse_reporting == MOUSE_URXVT; break; case 1015: term->xtsave.mouse_urxvt = term->mouse_reporting == MOUSE_URXVT; break;
case 1034: term->xtsave.meta_eight_bit = term->meta.eight_bit; break; case 1034: term->xtsave.meta_eight_bit = term->meta.eight_bit; break;
case 1036: term->xtsave.meta_esc_prefix = term->meta.esc_prefix; break; case 1036: term->xtsave.meta_esc_prefix = term->meta.esc_prefix; break;
case 1042: term->xtsave.bell_is_urgent = term->bell_is_urgent; break;
case 1049: term->xtsave.alt_screen = term->grid == &term->alt; break; case 1049: term->xtsave.alt_screen = term->grid == &term->alt; break;
case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break; case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break;
} }
@ -624,6 +625,7 @@ xtrestore(struct terminal *term, unsigned param)
case 1015: enable = term->xtsave.mouse_urxvt; break; case 1015: enable = term->xtsave.mouse_urxvt; break;
case 1034: enable = term->xtsave.meta_eight_bit; break; case 1034: enable = term->xtsave.meta_eight_bit; break;
case 1036: enable = term->xtsave.meta_esc_prefix; break; case 1036: enable = term->xtsave.meta_esc_prefix; break;
case 1042: enable = term->xtsave.bell_is_urgent; break;
case 1049: enable = term->xtsave.alt_screen; break; case 1049: enable = term->xtsave.alt_screen; break;
case 2004: enable = term->xtsave.bracketed_paste; break; case 2004: enable = term->xtsave.bracketed_paste; break;

View file

@ -103,6 +103,9 @@ in this order:
protocol is added in the future (in which case foot will use that protocol is added in the future (in which case foot will use that
instead of painting its margins red). instead of painting its margins red).
Applications can enable/disable this feature programatically with
the *CSI ? 1042 h* and *CSI ? 1042 l* escape sequences.
_Note_: expect this feature to be *replaced* with proper _Note_: expect this feature to be *replaced* with proper
compositor urgency support once/if that gets implemented. compositor urgency support once/if that gets implemented.

View file

@ -996,6 +996,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.esc_prefix = true, .esc_prefix = true,
.eight_bit = true, .eight_bit = true,
}, },
.bell_is_urgent = conf->bell_is_urgent,
.tab_stops = tll_init(), .tab_stops = tll_init(),
.wl = wayl, .wl = wayl,
.render = { .render = {
@ -2374,7 +2375,7 @@ term_flash(struct terminal *term, unsigned duration_ms)
void void
term_bell(struct terminal *term) term_bell(struct terminal *term)
{ {
if (term->kbd_focus || !term->conf->bell_set_urgency) if (term->kbd_focus || !term->bell_is_urgent)
return; return;
/* There's no 'urgency' hint in Wayland - we just paint the margins red */ /* There's no 'urgency' hint in Wayland - we just paint the margins red */

View file

@ -251,6 +251,8 @@ struct terminal {
bool eight_bit; bool eight_bit;
} meta; } meta;
bool bell_is_urgent;
/* Saved DECSET modes - we save the SET state */ /* Saved DECSET modes - we save the SET state */
struct { struct {
uint32_t origin:1; uint32_t origin:1;
@ -272,6 +274,7 @@ struct terminal {
uint32_t mouse_urxvt:1; uint32_t mouse_urxvt:1;
uint32_t meta_eight_bit:1; uint32_t meta_eight_bit:1;
uint32_t meta_esc_prefix:1; uint32_t meta_esc_prefix:1;
uint32_t bell_is_urgent:1;
uint32_t alt_screen:1; uint32_t alt_screen:1;
} xtsave; } xtsave;