From: Ray Strode Date: Tue, 2 Jan 2024 03:04:21 +0000 (-0500) Subject: ply-terminal: Only set keyboard mode when changing it X-Git-Tag: 24.004.60~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e411c7dcb77b69d7d4e897f6a5676f8bfb1c516;p=thirdparty%2Fplymouth.git ply-terminal: Only set keyboard mode when changing it Setting the console keyboard mode is not entirely idempotent. The kernel may flush the input buffer leading to lost key strokes. We currently set the mode explicitly on graphics updates as part of our more general "fix things up in case something during boot screws with the terminal settings" code. That leads to keystrokes getting eaten. This commit makes the terminal more careful about setting the keyboard mode. It now only changes it when plymouth thinks its necessary to do so. In the future we could query the keyboard mode and reset it when it's wrong, but I think we should hold off on doing that until shown we need to. --- diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c index 7afdb754..84ec91ee 100644 --- a/src/libply-splash-core/ply-terminal.c +++ b/src/libply-splash-core/ply-terminal.c @@ -241,13 +241,14 @@ ply_terminal_set_unbuffered_input (ply_terminal_t *terminal) ply_terminal_unlock (terminal); - if (terminal->is_disabled) + if (terminal->is_disabled) { ply_trace ("terminal input is getting enabled in unbuffered mode"); - terminal->is_disabled = false; + if (ply_terminal_is_vt (terminal)) + ioctl (terminal->fd, KDSKBMODE, K_UNICODE); - if (ply_terminal_is_vt (terminal)) - ioctl (terminal->fd, KDSKBMODE, K_UNICODE); + terminal->is_disabled = false; + } tcgetattr (terminal->fd, &term_attributes); @@ -279,13 +280,14 @@ ply_terminal_set_buffered_input (ply_terminal_t *terminal) { struct termios term_attributes; - if (terminal->is_disabled) + if (terminal->is_disabled) { ply_trace ("terminal input is getting enabled in buffered mode"); - terminal->is_disabled = false; + if (ply_terminal_is_vt (terminal)) + ioctl (terminal->fd, KDSKBMODE, K_UNICODE); - if (ply_terminal_is_vt (terminal)) - ioctl (terminal->fd, KDSKBMODE, K_UNICODE); + terminal->is_disabled = false; + } if (!terminal->is_unbuffered) return true; @@ -330,14 +332,15 @@ ply_terminal_set_buffered_input (ply_terminal_t *terminal) bool ply_terminal_set_disabled_input (ply_terminal_t *terminal) { - if (!terminal->is_disabled) + if (!terminal->is_disabled) { ply_trace ("terminal input is getting disabled from %s mode", terminal->is_unbuffered? "unbuffered" : "buffered"); - terminal->is_disabled = true; + if (ply_terminal_is_vt (terminal)) + ioctl (terminal->fd, KDSKBMODE, K_OFF); - if (ply_terminal_is_vt (terminal)) - ioctl (terminal->fd, KDSKBMODE, K_OFF); + terminal->is_disabled = true; + } return true; }