From d87d298c857558df9132c4b74d27b25c41417a92 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 15 Dec 2025 21:21:30 +0100 Subject: [PATCH] getty: fix terminal scrollback issues after login on console Fixes an issue where the mouse scroll wheel and Shift+PgUp/PgDn sometimes would not work properly after login. Signed-off-by: Joachim Wiberg --- src/stty.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/stty.c b/src/stty.c index 4d3176df..495cdb46 100644 --- a/src/stty.c +++ b/src/stty.c @@ -128,11 +128,18 @@ void stty(int fd, speed_t speed) term.c_cc[VERASE] = CERASE; tcsetattr(fd, TCSAFLUSH, &term); - /* Show cursor again, if it was hidden previously */ - dprint(fd, "\033[?25h", 6); - - /* Enable line wrap, if disabled previously */ - dprint(fd, "\033[?7h", 5); + /* Reset terminal to sane state - disable modes that break scrollback */ + dprint(fd, "\033[m", 3); /* Reset SGR attributes */ + dprint(fd, "\033[?1000l", 8); /* Disable X11 mouse tracking */ + dprint(fd, "\033[?1002l", 8); /* Disable button event tracking */ + dprint(fd, "\033[?1003l", 8); /* Disable all mouse tracking */ + dprint(fd, "\033[?1006l", 8); /* Disable SGR mouse mode */ + dprint(fd, "\033[?1015l", 8); /* Disable urxvt mouse mode */ + dprint(fd, "\033[?1049l", 8); /* Exit alternate screen buffer */ + dprint(fd, "\033[?1l", 6); /* Exit application cursor keys mode */ + dprint(fd, "\033[?2004l", 8); /* Disable bracketed paste mode */ + dprint(fd, "\033[?25h", 6); /* Show cursor */ + dprint(fd, "\033[?7h", 5); /* Enable line wrap */ } /**