diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-21 17:14:19 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-21 17:14:19 +0000 |
| commit | 0dd8951cb3d3b260575162ebbd1914c61a10d876 (patch) | |
| tree | e05b6e5584516e97a285780c9fec8e114a2123fc /main.c | |
| parent | csi: remove erronous final (diff) | |
flash: implement 'flash'
Use our own escape sequence for the 'flash' terminfo entry.
Implemented by arming a timer FD and setting a boolean that indicates
we're currently "flashing".
The renderer draws a semi-transparent yellowish layer over the entire
window when "flashing" is active.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -10,6 +10,8 @@ #include <poll.h> #include <errno.h> +#include <sys/timerfd.h> + #include <freetype/tttables.h> #include <cairo-ft.h> #include <wayland-client.h> @@ -325,6 +327,7 @@ main(int argc, char *const *argv) .keypad_keys_mode = KEYPAD_NUMERICAL, .auto_margin = true, .window_title_stack = tll_init(), + .flash_timer_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC), .vt = { .state = 1, /* STATE_GROUND */ .attrs = { @@ -681,6 +684,7 @@ main(int argc, char *const *argv) {.fd = wl_display_get_fd(term.wl.display), .events = POLLIN}, {.fd = term.ptmx, .events = POLLIN}, {.fd = term.kbd.repeat.pipe_read_fd, .events = POLLIN}, + {.fd = term.flash_timer_fd, .events = POLLIN}, }; wl_display_flush(term.wl.display); @@ -775,6 +779,23 @@ main(int argc, char *const *argv) if (fds[2].revents & POLLHUP) LOG_ERR("keyboard repeat handling thread died"); + + if (fds[3].revents & POLLIN) { + uint64_t expiration_count; + ssize_t ret = read( + term.flash_timer_fd, &expiration_count, sizeof(expiration_count)); + + if (ret < 0) + LOG_ERRNO("failed to read flash timer"); + else + LOG_DBG("flash timer expired %llu times", + (unsigned long long)expiration_count); + + term.flash_active = false; + term_damage_view(&term); + if (term.frame_callback == NULL) + grid_render(&term); + } } out: @@ -862,6 +883,9 @@ out: cairo_glyph_free(f->glyph_cache[j].glyphs); } + if (term.flash_timer_fd != -1) + close(term.flash_timer_fd); + if (term.ptmx != -1) close(term.ptmx); |
