From ca869a3fff761ea014e87db63c631fb85d968d91 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 13:07:32 +0100 Subject: [PATCH 1/6] ply-logger: Add a ply_is_tracing_to_terminal () helper Track if we are logging to the terminal (or to a file) and add a new ply_is_tracing_to_terminal () helper. This will be used in follow-up patches to replace some ply_is_tracing () checks for things which should only be done when tracing to a terminal (and not when tracing to a file). Signed-off-by: Hans de Goede --- src/libply/ply-logger.c | 12 ++++++++++++ src/libply/ply-logger.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c index 03dd347f..749c9da5 100644 --- a/src/libply/ply-logger.c +++ b/src/libply/ply-logger.c @@ -61,6 +61,7 @@ typedef struct struct _ply_logger { int output_fd; + bool output_fd_is_terminal; char *filename; char *buffer; @@ -229,6 +230,7 @@ ply_logger_new (void) logger = calloc (1, sizeof(ply_logger_t)); logger->output_fd = -1; + logger->output_fd_is_terminal = false; logger->filename = NULL; logger->is_enabled = true; logger->tracing_is_enabled = false; @@ -363,6 +365,7 @@ ply_logger_set_output_fd (ply_logger_t *logger, assert (logger != NULL); logger->output_fd = fd; + logger->output_fd_is_terminal = isatty(fd); } int @@ -580,6 +583,15 @@ ply_logger_is_tracing_enabled (ply_logger_t *logger) return logger->tracing_is_enabled != false; } + +bool +ply_logger_is_tracing_to_terminal (ply_logger_t *logger) +{ + assert (logger != NULL); + + return logger->tracing_is_enabled && logger->output_fd_is_terminal; +} + #endif /* PLY_ENABLE_TRACING */ /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/libply/ply-logger.h b/src/libply/ply-logger.h index 0015c0cf..8d8ee871 100644 --- a/src/libply/ply-logger.h +++ b/src/libply/ply-logger.h @@ -81,6 +81,7 @@ ply_logger_t *ply_logger_get_error_default (void); #ifdef PLY_ENABLE_TRACING void ply_logger_toggle_tracing (ply_logger_t *logger); bool ply_logger_is_tracing_enabled (ply_logger_t *logger); +bool ply_logger_is_tracing_to_terminal (ply_logger_t *logger); #define ply_logger_trace(logger, format, args ...) \ do \ @@ -113,6 +114,7 @@ bool ply_logger_is_tracing_enabled (ply_logger_t *logger); #define ply_logger_trace(logger, format, args ...) #define ply_logger_toggle_tracing(logger) #define ply_logger_is_tracing_enabled(logger) (false) +#define ply_logger_is_tracing_to_terminal(logger) (false) #endif /* PLY_ENABLE_TRACING */ /* convenience macros @@ -140,6 +142,8 @@ bool ply_logger_is_tracing_enabled (ply_logger_t *logger); ply_logger_toggle_tracing (ply_logger_get_error_default ()) #define ply_is_tracing() \ ply_logger_is_tracing_enabled (ply_logger_get_error_default ()) +#define ply_is_tracing_to_terminal() \ + ply_logger_is_tracing_to_terminal (ply_logger_get_error_default ()) #define ply_trace(format, args ...) \ ply_logger_trace (ply_logger_get_error_default (), format, ## args) From 8291d668aeab257ed6b74c81128b011715157c27 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 13:20:29 +0100 Subject: [PATCH 2/6] main: Redirect stdio/stderr to null when tracing to a file When the user has chosen to enable tracing to a file, so that the terminal output stays the same as when not tracing, we should still redirect tdio/stderr to /dev/null as we do when not tracing. Signed-off-by: Hans de Goede --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 0ad34fc4..122cb734 100644 --- a/src/main.c +++ b/src/main.c @@ -1976,7 +1976,7 @@ initialize_environment (state_t *state) state->entry_buffer = ply_buffer_new (); state->messages = ply_list_new (); - if (!ply_is_tracing ()) + if (!ply_is_tracing_to_terminal ()) redirect_standard_io_to_dev_null (); ply_trace ("Making sure " PLYMOUTH_RUNTIME_DIR " exists"); From 9ef171f73303c78758b3f3b64133a38cd31decad Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 13:22:45 +0100 Subject: [PATCH 3/6] ply-text-display: Only skip clearing the screen when tracing to a terminal When the user has chosen to enable tracing to a file, so that the terminal output stays the same as when not tracing, ply_text_display_clear_screen () should still clear the screen, as it does when not tracing. Signed-off-by: Hans de Goede --- src/libply-splash-core/ply-text-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libply-splash-core/ply-text-display.c b/src/libply-splash-core/ply-text-display.c index 7bf6e06d..fc41645a 100644 --- a/src/libply-splash-core/ply-text-display.c +++ b/src/libply-splash-core/ply-text-display.c @@ -150,7 +150,7 @@ ply_text_display_set_cursor_position (ply_text_display_t *display, void ply_text_display_clear_screen (ply_text_display_t *display) { - if (ply_is_tracing ()) + if (ply_is_tracing_to_terminal ()) return; ply_terminal_write (display->terminal, From 9b9d7e1b3a13a544d4d55abfe88f316a8ede9377 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 16:13:26 +0100 Subject: [PATCH 4/6] ply-text-display: Fix bottom pixels of fbcon not getting cleared When fbcon is used for the console then there might be some unused rows of pixels at the bottom because the screen's height in pixel is not fully divideable by the font height. So the remaining few rows of pixels at the bottom are unused. The "text" splash changes the background color of the terminal and then does a ply_text_display_clear_screen () to clear the console to the new background color. ply_text_display_clear_screen () was using "ESC [ 2 J" as control-sequence to clear the screen. Which means "clear the entire screen" but fbcon seems to not always count the unused bottom rows part of the "entire screen", leaving them black. Also send an "ESC [ 3 J" control-sequence when clearing the screen, which means "clear the entire screen; and the scrollback-buffer". Using this does consistenly result in the unused bottom rows always being set to the background color. This new behavior is esp. important when hiding the splash (e.g. when quiting) because under some circumstances (1) the "ESC [ 2 J" would clear the unused bottom rows to plymouth's background color and then when hiding the splash it would not clear the unused rows, leaving the unused rows set to plymouth's background color after plymouth has quit. Note the "ESC [ 2 J" control sequences is also still send because older (serial) terminals may not support the "ESC [ 3 J" control sequence. 1) The exact circumstances when this happens are unclear Related: https://bugzilla.redhat.com/show_bug.cgi?id=1933378 Signed-off-by: Hans de Goede --- src/libply-splash-core/ply-text-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libply-splash-core/ply-text-display.c b/src/libply-splash-core/ply-text-display.c index fc41645a..6eaea421 100644 --- a/src/libply-splash-core/ply-text-display.c +++ b/src/libply-splash-core/ply-text-display.c @@ -43,7 +43,7 @@ #include "ply-utils.h" #ifndef CLEAR_SCREEN_SEQUENCE -#define CLEAR_SCREEN_SEQUENCE "\033[2J" +#define CLEAR_SCREEN_SEQUENCE "\033[2J\033[3J" #endif #ifndef CLEAR_LINE_SEQUENCE From c6a8cf9dad4a4e6d0d78ef8b09092f4af0c48d68 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 16:24:39 +0100 Subject: [PATCH 5/6] text/tribar: Fix ply_boot_splash_hide () not clearing the terminal In order to clear the console/terminal back to black again when hiding the splash, we must restore the original terminal palette, so that black actually is black before calling ply_text_display_clear_screen (). Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1933378 Signed-off-by: Hans de Goede --- src/plugins/splash/text/plugin.c | 3 +-- src/plugins/splash/tribar/plugin.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c index 7805b9e8..3fa01a77 100644 --- a/src/plugins/splash/text/plugin.c +++ b/src/plugins/splash/text/plugin.c @@ -233,11 +233,10 @@ view_hide (view_t *view) terminal = ply_text_display_get_terminal (view->display); + ply_terminal_reset_colors (terminal); ply_text_display_set_background_color (view->display, PLY_TERMINAL_COLOR_DEFAULT); ply_text_display_clear_screen (view->display); ply_text_display_show_cursor (view->display); - - ply_terminal_reset_colors (terminal); } } diff --git a/src/plugins/splash/tribar/plugin.c b/src/plugins/splash/tribar/plugin.c index 1778822a..7c33e184 100644 --- a/src/plugins/splash/tribar/plugin.c +++ b/src/plugins/splash/tribar/plugin.c @@ -239,11 +239,10 @@ view_hide (view_t *view) terminal = ply_text_display_get_terminal (view->display); + ply_terminal_reset_colors (terminal); ply_text_display_set_background_color (view->display, PLY_TERMINAL_COLOR_DEFAULT); ply_text_display_clear_screen (view->display); ply_text_display_show_cursor (view->display); - - ply_terminal_reset_colors (terminal); } } From 0e59dde83afa2521bc548c587eaccbce1550bcfd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 27 Mar 2021 16:34:28 +0100 Subject: [PATCH 6/6] details: Clear newly added text-display before replaying log messages When switching between the "text" splash and the "details" splash the "text" splash's hide function clears the console/terminal before the "details" splash replays the log messages. So on each switch the user sees all the log messages once. But when switching between a graphical/pixel splash and details, the console/terminal is not touched by the graphical splash's hide function; and the details splash's hide function deliberately does not clear the terminal on hide, so that when booting in detailed mode, the log messages stay on the console when plymouth exits. This means that when switching graphical-splash -> details -> graphical-splash -> details, the second time the details splash gets shown, the previous set of replayed log messages is still on the terminal and all messages are now shown twice. (and toggling back and forth a third time makes them all show 3 times, etc). Fix this by clearing the terminal on show, before replaying the log messages. Signed-off-by: Hans de Goede --- src/plugins/splash/details/plugin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/splash/details/plugin.c b/src/plugins/splash/details/plugin.c index f534450b..254f682b 100644 --- a/src/plugins/splash/details/plugin.c +++ b/src/plugins/splash/details/plugin.c @@ -237,8 +237,10 @@ add_text_display (ply_boot_splash_plugin_t *plugin, view = view_new (plugin, display); terminal = ply_text_display_get_terminal (view->display); - if (ply_terminal_open (terminal)) + if (ply_terminal_open (terminal)) { + ply_text_display_clear_screen (view->display); ply_terminal_activate_vt (terminal); + } ply_list_append_data (plugin->views, view);