From 4e6badc3e308fa28e64599d3693539c4f2c3123b Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 2 Dec 2012 14:59:12 +0100 Subject: [PATCH] terminal: use "opened" logic We already keep the open state as "opened" so we should use it instead of always pushing the work down to the pty layer. Signed-off-by: David Herrmann --- src/kmscon_terminal.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kmscon_terminal.c b/src/kmscon_terminal.c index 9ea27ff..d4652a9 100644 --- a/src/kmscon_terminal.c +++ b/src/kmscon_terminal.c @@ -404,15 +404,15 @@ static int terminal_open(struct kmscon_terminal *term) int ret; unsigned short width, height; - kmscon_pty_close(term->pty); + if (term->opened) + return -EALREADY; + tsm_vte_hard_reset(term->vte); width = tsm_screen_get_width(term->console); height = tsm_screen_get_height(term->console); ret = kmscon_pty_open(term->pty, width, height); - if (ret) { - term->opened = false; + if (ret) return ret; - } term->opened = true; redraw_all(term); @@ -476,6 +476,7 @@ static void pty_input(struct kmscon_pty *pty, const char *u8, size_t len, struct kmscon_terminal *term = data; if (!len) { + terminal_close(term); terminal_open(term); } else { tsm_vte_input(term->vte, u8, len);