From f4f1989b6ef341557cc90a6805d745fef2a7a815 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 6 Oct 2022 17:23:56 +0200 Subject: render: resize: ignore ptmx read events during interactive resize --- terminal.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index df17201b..ee12ae32 100644 --- a/terminal.c +++ b/terminal.c @@ -233,6 +233,18 @@ static struct timespec last = {0}; static bool cursor_blink_rearm_timer(struct terminal *term); +void +term_ptmx_pause(struct terminal *term) +{ + fdm_event_del(term->fdm, term->ptmx, EPOLLIN); +} + +void +term_ptmx_resume(struct terminal *term) +{ + fdm_event_add(term->fdm, term->ptmx, EPOLLIN); +} + /* Externally visible, but not declared in terminal.h, to enable pgo * to call this function directly */ bool -- cgit v1.3 From 66e4592d91312568c8948ddda850ba8b1c31c87d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 9 Oct 2022 16:14:49 +0200 Subject: term: use SIZE_MAX instead of (size_t)-1ll --- terminal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index ee12ae32..5dd261bb 100644 --- a/terminal.c +++ b/terminal.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -268,7 +269,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) } uint8_t buf[24 * 1024]; - const size_t max_iterations = !hup ? 10 : (size_t)-1ll; + const size_t max_iterations = !hup ? 10 : SIZE_MAX; for (size_t i = 0; i < max_iterations && pollin; i++) { xassert(pollin); -- cgit v1.3 From 54d637e2b47fd55e4abde1e28f7f665e69c2a995 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 9 Oct 2022 16:15:29 +0200 Subject: term: ptmx: don’t consume anything while doing an interactive resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ‘normal’ grid in use during an interactive resize is temporary; all changes done to it will be lost when the resize is finished. --- terminal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 5dd261bb..4fb13f44 100644 --- a/terminal.c +++ b/terminal.c @@ -268,6 +268,16 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) cursor_blink_rearm_timer(term); } + if (unlikely(term->interactive_resizing.grid != NULL)) { + /* + * Don’t consume PTMX while we’re doing an interactive resize, + * since the ‘normal’ grid we’re currently using is a + * temporary one - all changes done to it will be lost when + * the interactive resize ends. + */ + return 0; + } + uint8_t buf[24 * 1024]; const size_t max_iterations = !hup ? 10 : SIZE_MAX; @@ -291,6 +301,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) break; } + xassert(term->interactive_resizing.grid == NULL); vt_from_slave(term, buf, count); } -- cgit v1.3 From c5c97c2fd4a674d0fcce16d40e0e56994195e9b0 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 9 Oct 2022 16:16:23 +0200 Subject: term_ptmx_{pause,resume}: return success/fail --- terminal.c | 24 ++++++++++++------------ terminal.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 4fb13f44..16486d82 100644 --- a/terminal.c +++ b/terminal.c @@ -234,18 +234,6 @@ static struct timespec last = {0}; static bool cursor_blink_rearm_timer(struct terminal *term); -void -term_ptmx_pause(struct terminal *term) -{ - fdm_event_del(term->fdm, term->ptmx, EPOLLIN); -} - -void -term_ptmx_resume(struct terminal *term) -{ - fdm_event_add(term->fdm, term->ptmx, EPOLLIN); -} - /* Externally visible, but not declared in terminal.h, to enable pgo * to call this function directly */ bool @@ -382,6 +370,18 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data) return true; } +bool +term_ptmx_pause(struct terminal *term) +{ + return fdm_event_del(term->fdm, term->ptmx, EPOLLIN); +} + +bool +term_ptmx_resume(struct terminal *term) +{ + return fdm_event_add(term->fdm, term->ptmx, EPOLLIN); +} + static bool fdm_flash(struct fdm *fdm, int fd, int events, void *data) { diff --git a/terminal.h b/terminal.h index 7a281e72..16c8e776 100644 --- a/terminal.h +++ b/terminal.h @@ -810,8 +810,8 @@ void term_collect_urls(struct terminal *term); void term_osc8_open(struct terminal *term, uint64_t id, const char *uri); void term_osc8_close(struct terminal *term); -void term_ptmx_pause(struct terminal *term); -void term_ptmx_resume(struct terminal *term); +bool term_ptmx_pause(struct terminal *term); +bool term_ptmx_resume(struct terminal *term); static inline void term_reset_grapheme_state(struct terminal *term) { -- cgit v1.3