mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-06 13:48:22 +02:00
Merge branch 'fixconsoleviewerrefresh' into 'main'
splash plugins: Better handling the redraw of the console viewer when visible,... See merge request plymouth/plymouth!257
This commit is contained in:
commit
e8251d4f03
8 changed files with 344 additions and 60 deletions
|
|
@ -41,6 +41,10 @@
|
|||
#include "ply-renderer.h"
|
||||
#include "ply-utils.h"
|
||||
|
||||
#ifndef FRAMES_PER_SECOND
|
||||
#define FRAMES_PER_SECOND 60
|
||||
#endif
|
||||
|
||||
struct _ply_pixel_display
|
||||
{
|
||||
ply_event_loop_t *loop;
|
||||
|
|
@ -58,6 +62,23 @@ struct _ply_pixel_display
|
|||
int pause_count;
|
||||
};
|
||||
|
||||
static void
|
||||
on_timeout (ply_pixel_display_t *display)
|
||||
{
|
||||
double sleep_time;
|
||||
|
||||
|
||||
sleep_time = 1.0 / FRAMES_PER_SECOND;
|
||||
|
||||
ply_pixel_display_unpause_updates (display);
|
||||
ply_pixel_display_pause_updates (display);
|
||||
|
||||
ply_event_loop_watch_for_timeout (display->loop,
|
||||
sleep_time,
|
||||
(ply_event_loop_timeout_handler_t)
|
||||
on_timeout, display);
|
||||
}
|
||||
|
||||
ply_pixel_display_t *
|
||||
ply_pixel_display_new (ply_renderer_t *renderer,
|
||||
ply_renderer_head_t *head)
|
||||
|
|
@ -182,9 +203,19 @@ ply_pixel_display_set_draw_handler (ply_pixel_display_t *display,
|
|||
ply_pixel_display_draw_handler_t draw_handler,
|
||||
void *user_data)
|
||||
{
|
||||
double sleep_time;
|
||||
|
||||
assert (display != NULL);
|
||||
|
||||
display->draw_handler = draw_handler;
|
||||
display->draw_handler_user_data = user_data;
|
||||
|
||||
sleep_time = 1.0 / FRAMES_PER_SECOND;
|
||||
|
||||
ply_event_loop_watch_for_timeout (display->loop,
|
||||
sleep_time,
|
||||
(ply_event_loop_timeout_handler_t)
|
||||
on_timeout, display);
|
||||
ply_pixel_display_pause_updates (display);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1123,13 +1123,6 @@ ply_terminal_emulator_parse_substring (ply_terminal_emulator_t *terminal_emulato
|
|||
|
||||
terminal_emulator->current_line = terminal_emulator_line;
|
||||
|
||||
/* avoid duplicate empty lines, the end of the line implies a newline */
|
||||
if (input_length == 1 && input[0] == '\n') {
|
||||
*unparsed_input = &input[1];
|
||||
*number_of_unparsed_bytes = number_of_bytes_to_parse - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
ply_rich_text_get_mutable_span (terminal_emulator->current_line, &span);
|
||||
maximum_characters = span.offset + span.range;
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ update_console_messages (ply_console_viewer_t *console_viewer)
|
|||
{
|
||||
ply_list_node_t *node;
|
||||
ply_label_t *console_message_label;
|
||||
size_t message_number;
|
||||
size_t message_number, number_of_messages, visible_line_count;
|
||||
ssize_t characters_left;
|
||||
ply_rich_text_span_t span;
|
||||
|
||||
|
|
@ -144,12 +144,20 @@ update_console_messages (ply_console_viewer_t *console_viewer)
|
|||
if (console_viewer->display == NULL)
|
||||
return;
|
||||
|
||||
message_number = ply_terminal_emulator_get_line_count (console_viewer->terminal_emulator) - 1;
|
||||
visible_line_count = ply_list_get_length (console_viewer->message_labels);
|
||||
|
||||
if (message_number < 0)
|
||||
number_of_messages = ply_terminal_emulator_get_line_count (console_viewer->terminal_emulator);
|
||||
|
||||
message_number = ply_terminal_emulator_get_line_count (console_viewer->terminal_emulator);
|
||||
if (message_number < visible_line_count) {
|
||||
message_number = 0;
|
||||
} else {
|
||||
message_number = number_of_messages - visible_line_count;
|
||||
}
|
||||
|
||||
if (number_of_messages < 0)
|
||||
return;
|
||||
|
||||
ply_pixel_display_pause_updates (console_viewer->display);
|
||||
node = ply_list_get_first_node (console_viewer->message_labels);
|
||||
while (node != NULL) {
|
||||
ply_rich_text_t *line = NULL;
|
||||
|
|
@ -193,16 +201,15 @@ update_console_messages (ply_console_viewer_t *console_viewer)
|
|||
if (line != NULL)
|
||||
ply_rich_text_drop_reference (line);
|
||||
|
||||
if (message_number <= 0)
|
||||
break;
|
||||
message_number++;
|
||||
|
||||
message_number--;
|
||||
if (message_number >= number_of_messages)
|
||||
break;
|
||||
}
|
||||
console_viewer->needs_redraw = true;
|
||||
ply_pixel_display_draw_area (console_viewer->display, 0, 0,
|
||||
ply_pixel_display_get_width (console_viewer->display),
|
||||
ply_pixel_display_get_height (console_viewer->display));
|
||||
ply_pixel_display_unpause_updates (console_viewer->display);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -226,7 +233,7 @@ ply_console_viewer_show (ply_console_viewer_t *console_viewer,
|
|||
console_message_label = ply_list_node_get_data (node);
|
||||
ply_label_show (console_message_label, console_viewer->display,
|
||||
console_viewer->font_width / 2,
|
||||
(ply_pixel_display_get_height (console_viewer->display) - (console_viewer->font_height * label_index) - console_viewer->font_height));
|
||||
console_viewer->font_height * label_index);
|
||||
ply_label_set_hex_color (console_message_label, label_color);
|
||||
label_index++;
|
||||
}
|
||||
|
|
@ -257,7 +264,7 @@ ply_console_viewer_draw_area (ply_console_viewer_t *console_viewer,
|
|||
console_message_label = ply_list_node_get_data (node);
|
||||
ply_label_draw_area (console_message_label, buffer,
|
||||
MAX (x, console_viewer->font_width / 2),
|
||||
MAX (y, (ply_pixel_display_get_height (console_viewer->display) - (console_viewer->font_height * label_index) - console_viewer->font_height)),
|
||||
MAX (y, console_viewer->font_height * label_index),
|
||||
MIN (ply_label_get_width (console_message_label), width),
|
||||
MIN (height, console_viewer->font_height));
|
||||
label_index++;
|
||||
|
|
@ -348,3 +355,9 @@ ply_console_viewer_print (ply_console_viewer_t *console_viewer,
|
|||
|
||||
free (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
ply_console_viewer_clear_line (ply_console_viewer_t *console_viewer)
|
||||
{
|
||||
ply_console_viewer_print (console_viewer, "\033[2K\033[0G");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ void ply_console_viewer_write (ply_console_viewer_t *console_viewer,
|
|||
void ply_console_viewer_print (ply_console_viewer_t *console_viewer,
|
||||
const char *text,
|
||||
...);
|
||||
void ply_console_viewer_clear_line (ply_console_viewer_t *console_viewer);
|
||||
#endif //PLY_HIDE_FUNCTION_DECLARATIONS
|
||||
|
||||
#endif //PLY_CONSOLE_VIEWER_H
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ ply_entry_load (ply_entry_t *entry)
|
|||
static void
|
||||
ply_entry_draw (ply_entry_t *entry)
|
||||
{
|
||||
if (entry->is_hidden)
|
||||
return;
|
||||
|
||||
ply_pixel_display_draw_area (entry->display,
|
||||
entry->area.x,
|
||||
entry->area.y,
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ struct _ply_boot_splash_plugin
|
|||
double start_time;
|
||||
double now;
|
||||
|
||||
uint32_t needs_redraw : 1;
|
||||
uint32_t is_animating : 1;
|
||||
uint32_t is_visible : 1;
|
||||
|
||||
|
|
@ -126,6 +127,32 @@ static void display_console_messages (ply_boot_splash_plugin_t *plugin);
|
|||
static void hide_console_messages (ply_boot_splash_plugin_t *plugin);
|
||||
static void unhide_console_messages (ply_boot_splash_plugin_t *plugin);
|
||||
|
||||
static void
|
||||
view_show_prompt_on_console_viewer (view_t *view,
|
||||
const char *prompt,
|
||||
const char *entry_text,
|
||||
int number_of_bullets)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin = view->plugin;
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, prompt);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, ": ");
|
||||
if (entry_text)
|
||||
ply_console_viewer_print (view->console_viewer, "%s", entry_text);
|
||||
|
||||
for (int i = 0; i < number_of_bullets; i++) {
|
||||
ply_console_viewer_print (view->console_viewer, " ");
|
||||
}
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "_");
|
||||
}
|
||||
|
||||
static void
|
||||
view_show_prompt (view_t *view,
|
||||
const char *prompt)
|
||||
|
|
@ -172,8 +199,21 @@ view_show_prompt (view_t *view,
|
|||
static void
|
||||
view_hide_prompt (view_t *view)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin;
|
||||
|
||||
assert (view != NULL);
|
||||
|
||||
plugin = view->plugin;
|
||||
|
||||
/* Obscure the password length in the scroll back */
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
if (ply_entry_is_hidden (view->entry))
|
||||
return;
|
||||
|
||||
ply_entry_hide (view->entry);
|
||||
ply_label_hide (view->label);
|
||||
}
|
||||
|
|
@ -218,6 +258,8 @@ create_plugin (ply_key_file_t *key_file)
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
|
||||
plugin->views = ply_list_new ();
|
||||
|
||||
plugin->needs_redraw = true;
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
|
@ -366,9 +408,18 @@ view_redraw (view_t *view)
|
|||
|
||||
static void
|
||||
redraw_views (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->needs_redraw = true;
|
||||
}
|
||||
|
||||
static void
|
||||
process_needed_redraws (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
ply_list_node_t *node;
|
||||
|
||||
if (!plugin->needs_redraw)
|
||||
return;
|
||||
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
ply_list_node_t *next_node;
|
||||
|
|
@ -381,6 +432,8 @@ redraw_views (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
node = next_node;
|
||||
}
|
||||
|
||||
plugin->needs_redraw = false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -667,6 +720,7 @@ draw_background (view_t *view,
|
|||
int width,
|
||||
int height)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin;
|
||||
ply_rectangle_t area;
|
||||
|
||||
area.x = x;
|
||||
|
|
@ -674,9 +728,15 @@ draw_background (view_t *view,
|
|||
area.width = width;
|
||||
area.height = height;
|
||||
|
||||
ply_pixel_buffer_fill_with_gradient (pixel_buffer, &area,
|
||||
PLYMOUTH_BACKGROUND_START_COLOR,
|
||||
PLYMOUTH_BACKGROUND_END_COLOR);
|
||||
plugin = view->plugin;
|
||||
|
||||
if (plugin->should_show_console_messages) {
|
||||
ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area, 0);
|
||||
} else {
|
||||
ply_pixel_buffer_fill_with_gradient (pixel_buffer, &area,
|
||||
PLYMOUTH_BACKGROUND_START_COLOR,
|
||||
PLYMOUTH_BACKGROUND_END_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -776,14 +836,16 @@ on_draw (view_t *view,
|
|||
|
||||
draw_background (view, pixel_buffer, x, y, width, height);
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
draw_normal_view (view, pixel_buffer, x, y, width, height);
|
||||
else
|
||||
draw_prompt_view (view, pixel_buffer, x, y, width, height);
|
||||
if (!plugin->should_show_console_messages) {
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
draw_normal_view (view, pixel_buffer, x, y, width, height);
|
||||
else
|
||||
draw_prompt_view (view, pixel_buffer, x, y, width, height);
|
||||
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
if (plugin->plugin_console_messages_updating == false && view->console_viewer) {
|
||||
ply_console_viewer_draw_area (view->console_viewer, pixel_buffer, x, y, width, height);
|
||||
|
|
@ -1014,6 +1076,9 @@ show_message (ply_boot_splash_plugin_t *plugin,
|
|||
ply_pixel_display_draw_area (view->display, 10, 10,
|
||||
ply_label_get_width (view->message_label),
|
||||
ply_label_get_height (view->message_label));
|
||||
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "\n%s\n", message);
|
||||
node = next_node;
|
||||
}
|
||||
}
|
||||
|
|
@ -1052,6 +1117,7 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
|
|||
view = ply_list_node_get_data (node);
|
||||
next_node = ply_list_get_next_node (plugin->views, node);
|
||||
|
||||
view_show_prompt_on_console_viewer (view, text, NULL, number_of_bullets);
|
||||
view_show_prompt (view, text);
|
||||
ply_entry_set_bullet_count (view->entry, number_of_bullets);
|
||||
|
||||
|
|
@ -1074,6 +1140,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
|
|||
view = ply_list_node_get_data (node);
|
||||
next_node = ply_list_get_next_node (plugin->views, node);
|
||||
|
||||
view_show_prompt_on_console_viewer (view, prompt, entry_text, -1);
|
||||
view_show_prompt (view, prompt);
|
||||
ply_entry_set_text (view->entry, entry_text);
|
||||
|
||||
|
|
@ -1108,13 +1175,15 @@ display_normal (ply_boot_splash_plugin_t *plugin)
|
|||
hide_prompt (plugin);
|
||||
|
||||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
|
||||
if (!plugin->should_show_console_messages) {
|
||||
if (!plugin->should_show_console_messages)
|
||||
start_animation (plugin);
|
||||
} else {
|
||||
unhide_console_messages (plugin);
|
||||
}
|
||||
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1130,6 +1199,11 @@ display_password (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
|
||||
show_password_prompt (plugin, prompt, bullets);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1145,6 +1219,11 @@ display_question (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY;
|
||||
show_prompt (plugin, prompt, entry_text);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1191,6 +1270,9 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
pause_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
stop_animation (plugin);
|
||||
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -1201,6 +1283,7 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1208,7 +1291,6 @@ static void
|
|||
unhide_console_messages (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->should_show_console_messages = true;
|
||||
stop_animation (plugin);
|
||||
display_console_messages (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1220,6 +1302,7 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
plugin->should_show_console_messages = false;
|
||||
|
||||
pause_views (plugin);
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -1230,6 +1313,10 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
start_animation (plugin);
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ struct _ply_boot_splash_plugin
|
|||
double progress_target;
|
||||
|
||||
uint32_t root_is_mounted : 1;
|
||||
uint32_t needs_redraw : 1;
|
||||
uint32_t is_visible : 1;
|
||||
uint32_t is_animating : 1;
|
||||
|
||||
|
|
@ -344,9 +345,18 @@ view_redraw (view_t *view)
|
|||
|
||||
static void
|
||||
redraw_views (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->needs_redraw = true;
|
||||
}
|
||||
|
||||
static void
|
||||
process_needed_redraws (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
ply_list_node_t *node;
|
||||
|
||||
if (!plugin->needs_redraw)
|
||||
return;
|
||||
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
ply_list_node_t *next_node;
|
||||
|
|
@ -359,6 +369,8 @@ redraw_views (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
node = next_node;
|
||||
}
|
||||
|
||||
plugin->needs_redraw = false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -442,6 +454,32 @@ view_start_animation (view_t *view)
|
|||
screen_width, screen_height);
|
||||
}
|
||||
|
||||
static void
|
||||
view_show_prompt_on_console_viewer (view_t *view,
|
||||
const char *prompt,
|
||||
const char *entry_text,
|
||||
int number_of_bullets)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin = view->plugin;
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, prompt);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, ": ");
|
||||
if (entry_text)
|
||||
ply_console_viewer_print (view->console_viewer, "%s", entry_text);
|
||||
|
||||
for (int i = 0; i < number_of_bullets; i++) {
|
||||
ply_console_viewer_print (view->console_viewer, " ");
|
||||
}
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "_");
|
||||
}
|
||||
|
||||
static void
|
||||
view_show_prompt (view_t *view,
|
||||
const char *prompt)
|
||||
|
|
@ -493,8 +531,18 @@ view_show_prompt (view_t *view,
|
|||
static void
|
||||
view_hide_prompt (view_t *view)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin;
|
||||
|
||||
assert (view != NULL);
|
||||
|
||||
plugin = view->plugin;
|
||||
|
||||
/* Obscure the password length in the scroll back */
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
ply_entry_hide (view->entry);
|
||||
ply_label_hide (view->label);
|
||||
}
|
||||
|
|
@ -594,6 +642,8 @@ create_plugin (ply_key_file_t *key_file)
|
|||
|
||||
plugin->views = ply_list_new ();
|
||||
|
||||
plugin->needs_redraw = true;
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
|
@ -1334,11 +1384,12 @@ on_draw (view_t *view,
|
|||
if (width == 1 && height == 1)
|
||||
single_pixel = true;
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
|
||||
plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) {
|
||||
uint32_t *box_data, *lock_data;
|
||||
draw_background (view, pixel_buffer, x, y, width, height);
|
||||
|
||||
draw_background (view, pixel_buffer, x, y, width, height);
|
||||
if ((plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
|
||||
plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) &&
|
||||
!plugin->should_show_console_messages) {
|
||||
uint32_t *box_data, *lock_data;
|
||||
|
||||
box_data = ply_image_get_data (plugin->box_image);
|
||||
ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
||||
|
|
@ -1350,10 +1401,9 @@ on_draw (view_t *view,
|
|||
ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
||||
&view->lock_area,
|
||||
lock_data);
|
||||
} else {
|
||||
} else if (!plugin->should_show_console_messages) {
|
||||
ply_list_node_t *node;
|
||||
|
||||
draw_background (view, pixel_buffer, x, y, width, height);
|
||||
|
||||
for (node = ply_list_get_first_node (view->sprites); node; node = ply_list_get_next_node (view->sprites, node)) {
|
||||
sprite_t *sprite = ply_list_node_get_data (node);
|
||||
|
|
@ -1391,9 +1441,11 @@ on_draw (view_t *view,
|
|||
}
|
||||
if (single_pixel)
|
||||
ply_pixel_buffer_fill_with_color (pixel_buffer, &clip_area, pixel_r, pixel_g, pixel_b, 1.0);
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
|
||||
if (!plugin->should_show_console_messages)
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
|
||||
if (plugin->plugin_console_messages_updating == false && view->console_viewer) {
|
||||
ply_console_viewer_draw_area (view->console_viewer, pixel_buffer, x, y, width, height);
|
||||
|
|
@ -1424,6 +1476,11 @@ draw_background (view_t *view,
|
|||
image_area.width = ply_image_get_width (view->scaled_background_image);
|
||||
image_area.height = ply_image_get_height (view->scaled_background_image);
|
||||
|
||||
if (plugin->should_show_console_messages) {
|
||||
ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
ply_pixel_buffer_fill_with_argb32_data_with_clip (pixel_buffer,
|
||||
&image_area, &area,
|
||||
ply_image_get_data (view->scaled_background_image));
|
||||
|
|
@ -1792,6 +1849,7 @@ show_password_prompt (ply_boot_splash_plugin_t *plugin,
|
|||
view = ply_list_node_get_data (node);
|
||||
next_node = ply_list_get_next_node (plugin->views, node);
|
||||
|
||||
view_show_prompt_on_console_viewer (view, text, NULL, number_of_bullets);
|
||||
view_show_prompt (view, text);
|
||||
ply_entry_set_bullet_count (view->entry, number_of_bullets);
|
||||
|
||||
|
|
@ -1814,6 +1872,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
|
|||
view = ply_list_node_get_data (node);
|
||||
next_node = ply_list_get_next_node (plugin->views, node);
|
||||
|
||||
view_show_prompt_on_console_viewer (view, prompt, entry_text, -1);
|
||||
view_show_prompt (view, prompt);
|
||||
ply_entry_set_text (view->entry, entry_text);
|
||||
|
||||
|
|
@ -1850,6 +1909,7 @@ show_message (ply_boot_splash_plugin_t *plugin,
|
|||
next_node = ply_list_get_next_node (plugin->views, node);
|
||||
ply_label_set_text (view->message_label, message);
|
||||
ply_label_show (view->message_label, view->display, 10, 10);
|
||||
ply_console_viewer_print (view->console_viewer, "\n%s\n", message);
|
||||
|
||||
ply_pixel_display_draw_area (view->display, 10, 10,
|
||||
ply_label_get_width (view->message_label),
|
||||
|
|
@ -1866,13 +1926,15 @@ display_normal (ply_boot_splash_plugin_t *plugin)
|
|||
hide_prompt (plugin);
|
||||
|
||||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
|
||||
if (!plugin->should_show_console_messages) {
|
||||
if (!plugin->should_show_console_messages)
|
||||
start_animation (plugin);
|
||||
} else {
|
||||
unhide_console_messages (plugin);
|
||||
}
|
||||
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1888,6 +1950,11 @@ display_password (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
|
||||
show_password_prompt (plugin, prompt, bullets);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1903,6 +1970,11 @@ display_question (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY;
|
||||
show_prompt (plugin, prompt, entry_text);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1948,6 +2020,9 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
pause_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
stop_animation (plugin);
|
||||
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -1958,6 +2033,7 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1965,7 +2041,6 @@ static void
|
|||
unhide_console_messages (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->should_show_console_messages = true;
|
||||
stop_animation (plugin);
|
||||
display_console_messages (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -1977,6 +2052,7 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
plugin->should_show_console_messages = false;
|
||||
|
||||
pause_views (plugin);
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -1987,6 +2063,10 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
start_animation (plugin);
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ struct _ply_boot_splash_plugin
|
|||
ply_trigger_t *stop_trigger;
|
||||
|
||||
uint32_t root_is_mounted : 1;
|
||||
uint32_t needs_redraw : 1;
|
||||
uint32_t is_visible : 1;
|
||||
uint32_t is_animating : 1;
|
||||
uint32_t is_idle : 1;
|
||||
|
|
@ -801,16 +802,27 @@ view_redraw (view_t *view)
|
|||
|
||||
static void
|
||||
redraw_views (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->needs_redraw = true;
|
||||
}
|
||||
|
||||
static void
|
||||
process_needed_redraws (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
ply_list_node_t *node;
|
||||
view_t *view;
|
||||
|
||||
if (!plugin->needs_redraw)
|
||||
return;
|
||||
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
view = ply_list_node_get_data (node);
|
||||
view_redraw (view);
|
||||
node = ply_list_get_next_node (plugin->views, node);
|
||||
}
|
||||
|
||||
plugin->needs_redraw = false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -947,6 +959,32 @@ view_start_progress_animation (view_t *view)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
view_show_prompt_on_console_viewer (view_t *view,
|
||||
const char *prompt,
|
||||
const char *entry_text,
|
||||
int number_of_bullets)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin = view->plugin;
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, prompt);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, ": ");
|
||||
if (entry_text)
|
||||
ply_console_viewer_print (view->console_viewer, "%s", entry_text);
|
||||
|
||||
for (int i = 0; i < number_of_bullets; i++) {
|
||||
ply_console_viewer_print (view->console_viewer, " ");
|
||||
}
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "_");
|
||||
}
|
||||
|
||||
static void
|
||||
view_show_prompt (view_t *view,
|
||||
const char *prompt,
|
||||
|
|
@ -1050,9 +1088,20 @@ view_show_prompt (view_t *view,
|
|||
static void
|
||||
view_hide_prompt (view_t *view)
|
||||
{
|
||||
ply_boot_splash_plugin_t *plugin;
|
||||
|
||||
assert (view != NULL);
|
||||
|
||||
plugin = view->plugin;
|
||||
|
||||
/* Obscure the password length in the scroll back */
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY)
|
||||
ply_console_viewer_clear_line (view->console_viewer);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "\n");
|
||||
|
||||
ply_entry_hide (view->entry);
|
||||
|
||||
ply_capslock_icon_hide (view->capslock_icon);
|
||||
ply_keymap_icon_hide (view->keymap_icon);
|
||||
ply_label_hide (view->label);
|
||||
|
|
@ -1314,6 +1363,8 @@ create_plugin (ply_key_file_t *key_file)
|
|||
|
||||
plugin->views = ply_list_new ();
|
||||
|
||||
plugin->needs_redraw = true;
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
|
@ -1561,8 +1612,9 @@ draw_background (view_t *view,
|
|||
using_fw_background && plugin->dialog_clears_firmware_background)
|
||||
use_black_background = true;
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
if (plugin->should_show_console_messages) {
|
||||
use_black_background = true;
|
||||
}
|
||||
|
||||
if (use_black_background)
|
||||
ply_pixel_buffer_fill_with_hex_color (pixel_buffer, &area, 0);
|
||||
|
|
@ -1612,8 +1664,9 @@ on_draw (view_t *view,
|
|||
|
||||
ply_pixel_buffer_get_size (pixel_buffer, &screen_area);
|
||||
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
|
||||
plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) {
|
||||
if ((plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
|
||||
plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) &&
|
||||
!plugin->should_show_console_messages) {
|
||||
uint32_t *box_data, *lock_data;
|
||||
|
||||
if (plugin->box_image) {
|
||||
|
|
@ -1640,7 +1693,7 @@ on_draw (view_t *view,
|
|||
ply_pixel_buffer_fill_with_argb32_data (pixel_buffer,
|
||||
&view->lock_area,
|
||||
lock_data);
|
||||
} else {
|
||||
} else if (!plugin->should_show_console_messages) {
|
||||
if (plugin->mode_settings[plugin->mode].use_progress_bar)
|
||||
ply_progress_bar_draw_area (view->progress_bar, pixel_buffer,
|
||||
x, y, width, height);
|
||||
|
|
@ -1698,13 +1751,13 @@ on_draw (view_t *view,
|
|||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
}
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
if (!plugin->should_show_console_messages)
|
||||
ply_label_draw_area (view->message_label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
|
||||
if (!plugin->plugin_console_messages_updating && view->console_viewer) {
|
||||
if (!plugin->plugin_console_messages_updating && view->console_viewer)
|
||||
ply_console_viewer_draw_area (view->console_viewer, pixel_buffer, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2009,6 +2062,7 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
|
|||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
view = ply_list_node_get_data (node);
|
||||
view_show_prompt_on_console_viewer (view, prompt, entry_text, number_of_bullets);
|
||||
view_show_prompt (view, prompt, entry_text, number_of_bullets);
|
||||
node = ply_list_get_next_node (plugin->views, node);
|
||||
}
|
||||
|
|
@ -2086,6 +2140,8 @@ view_show_message (view_t *view,
|
|||
|
||||
ply_label_show (view->message_label, view->display, x, y);
|
||||
ply_pixel_display_draw_area (view->display, x, y, width, height);
|
||||
|
||||
ply_console_viewer_print (view->console_viewer, "\n%s\n", message);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2130,13 +2186,15 @@ display_normal (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_NORMAL;
|
||||
|
||||
if (!plugin->should_show_console_messages) {
|
||||
if (!plugin->should_show_console_messages)
|
||||
start_progress_animation (plugin);
|
||||
} else {
|
||||
unhide_console_messages (plugin);
|
||||
}
|
||||
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -2152,6 +2210,11 @@ display_password (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY;
|
||||
show_prompt (plugin, prompt, NULL, bullets);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -2167,6 +2230,11 @@ display_question (ply_boot_splash_plugin_t *plugin,
|
|||
plugin->state = PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY;
|
||||
show_prompt (plugin, prompt, entry_text, -1);
|
||||
redraw_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
display_console_messages (plugin);
|
||||
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -2212,6 +2280,9 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
pause_views (plugin);
|
||||
|
||||
if (plugin->should_show_console_messages)
|
||||
stop_animation (plugin);
|
||||
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -2222,6 +2293,7 @@ display_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -2229,7 +2301,6 @@ static void
|
|||
unhide_console_messages (ply_boot_splash_plugin_t *plugin)
|
||||
{
|
||||
plugin->should_show_console_messages = true;
|
||||
stop_animation (plugin);
|
||||
display_console_messages (plugin);
|
||||
}
|
||||
|
||||
|
|
@ -2241,6 +2312,7 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
|
||||
plugin->should_show_console_messages = false;
|
||||
|
||||
pause_views (plugin);
|
||||
plugin->plugin_console_messages_updating = true;
|
||||
node = ply_list_get_first_node (plugin->views);
|
||||
while (node != NULL) {
|
||||
|
|
@ -2251,6 +2323,10 @@ hide_console_messages (ply_boot_splash_plugin_t *plugin)
|
|||
plugin->plugin_console_messages_updating = false;
|
||||
if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_NORMAL)
|
||||
start_progress_animation (plugin);
|
||||
|
||||
redraw_views (plugin);
|
||||
process_needed_redraws (plugin);
|
||||
unpause_views (plugin);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue