diff options
author | Thomas Adam <thomas@xteddy.org> | 2016-06-15 12:01:11 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2016-06-15 12:01:11 +0100 |
commit | 5c12230a0879c7dd3ac5332dfdb9d0d7416b3557 (patch) | |
tree | 2721e0016e2ca721635e51aa6bf745ed880e6a3b /window.c | |
parent | 150c9f3fe0f7d74677d391d798efe2d49aa58cd9 (diff) | |
parent | bee3e3e28d04a237b1013b1dd3d36cddcd326891 (diff) | |
download | rtmux-5c12230a0879c7dd3ac5332dfdb9d0d7416b3557.tar.gz rtmux-5c12230a0879c7dd3ac5332dfdb9d0d7416b3557.tar.bz2 rtmux-5c12230a0879c7dd3ac5332dfdb9d0d7416b3557.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -17,6 +17,7 @@ */ #include <sys/types.h> +#include <sys/ioctl.h> #include <errno.h> #include <fcntl.h> @@ -1061,15 +1062,38 @@ window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc, wp->flags |= PANE_REDRAW; } +static void +window_pane_mode_timer(__unused int fd, __unused short events, void *arg) +{ + struct window_pane *wp = arg; + struct timeval tv = { .tv_sec = 10 }; + int n = 0; + + evtimer_del(&wp->modetimer); + evtimer_add(&wp->modetimer, &tv); + + log_debug("%%%u in mode: last=%ld", wp->id, (long)wp->modelast); + + if (wp->modelast < time(NULL) - WINDOW_MODE_TIMEOUT) { + if (ioctl(wp->fd, FIONREAD, &n) == -1 || n > 0) + window_pane_reset_mode(wp); + } +} + int window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) { struct screen *s; + struct timeval tv = { .tv_sec = 10 }; if (wp->mode != NULL) return (1); wp->mode = mode; + wp->modelast = time(NULL); + evtimer_set(&wp->modetimer, window_pane_mode_timer, wp); + evtimer_add(&wp->modetimer, &tv); + if ((s = wp->mode->init(wp)) != NULL) wp->screen = s; wp->flags |= (PANE_REDRAW|PANE_CHANGED); @@ -1084,6 +1108,8 @@ window_pane_reset_mode(struct window_pane *wp) if (wp->mode == NULL) return; + evtimer_del(&wp->modetimer); + wp->mode->free(wp); wp->mode = NULL; @@ -1103,6 +1129,7 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s, return; if (wp->mode != NULL) { + wp->modelast = time(NULL); if (wp->mode->key != NULL) wp->mode->key(wp, c, s, key, m); return; |