mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-23 05:33:57 -04:00
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.
This commit is contained in:
parent
1ff04c5e36
commit
0dd8951cb3
5 changed files with 84 additions and 22 deletions
24
main.c
24
main.c
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue