term: break out 'flash' to a separate 'term' function

This commit is contained in:
Daniel Eklöf 2019-07-30 22:06:02 +02:00
parent 89f1b3ae73
commit e3dc184882
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 19 additions and 13 deletions

View file

@ -4,6 +4,7 @@
#include <unistd.h>
#include <assert.h>
#include <sys/timerfd.h>
#include <linux/input-event-codes.h>
#define LOG_MODULE "terminal"
@ -485,3 +486,19 @@ term_set_window_title(struct terminal *term, const char *title)
term->window_title = strdup(title);
render_set_title(term, term->window_title);
}
void
term_flash(struct terminal *term, unsigned duration_ms)
{
LOG_DBG("FLASH for %ums", duration_ms);
struct itimerspec alarm = {
.it_value = {.tv_sec = 0, .tv_nsec = duration_ms * 1000000},
};
if (timerfd_settime(term->flash.fd, 0, &alarm, NULL) < 0)
LOG_ERRNO("failed to arm flash timer");
else {
term->flash.active = true;
}
}