Add {add,remove}_window funcs to splash plugins

We'll be able to have more than one window for
serial consoles, etc.
This commit is contained in:
Ray Strode 2008-09-13 11:56:14 -04:00
parent 2097e19f31
commit a7bc5f28a7
6 changed files with 117 additions and 68 deletions

View file

@ -40,9 +40,13 @@ typedef struct
ply_boot_splash_plugin_t * (* create_plugin) (void);
void (* destroy_plugin) (ply_boot_splash_plugin_t *plugin);
void (* add_window) (ply_boot_splash_plugin_t *plugin,
ply_window_t *window);
void (* remove_window) (ply_boot_splash_plugin_t *plugin,
ply_window_t *window);
bool (* show_splash_screen) (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window,
ply_buffer_t *boot_buffer);
void (* update_status) (ply_boot_splash_plugin_t *plugin,
const char *status);
@ -51,8 +55,7 @@ typedef struct
size_t size);
void (* on_root_mounted) (ply_boot_splash_plugin_t *plugin);
void (* hide_splash_screen) (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window);
ply_event_loop_t *loop);
void (* ask_for_password) (ply_boot_splash_plugin_t *plugin,
const char *prompt,

View file

@ -132,37 +132,48 @@ on_enter (ply_boot_splash_plugin_t *plugin,
}
}
void
add_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = window;
}
void
remove_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = NULL;
}
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
size_t size;
assert (plugin != NULL);
if (window != NULL)
if (plugin->window != NULL)
{
ply_boot_splash_plugin_interface_t *interface;
ply_window_set_mode (window, PLY_WINDOW_MODE_TEXT);
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
ply_window_set_keyboard_input_handler (window,
ply_window_set_keyboard_input_handler (plugin->window,
(ply_window_keyboard_input_handler_t)
on_keyboard_input, plugin);
ply_window_set_backspace_handler (window,
ply_window_set_backspace_handler (plugin->window,
(ply_window_backspace_handler_t)
on_backspace, plugin);
ply_window_set_enter_handler (window,
ply_window_set_enter_handler (plugin->window,
(ply_window_enter_handler_t)
on_enter, plugin);
interface = ply_boot_splash_plugin_get_interface ();
interface->ask_for_password = ask_for_password;
plugin->window = window;
}
plugin->loop = loop;
@ -201,8 +212,7 @@ on_boot_output (ply_boot_splash_plugin_t *plugin,
void
hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window)
ply_event_loop_t *loop)
{
assert (plugin != NULL);
@ -215,16 +225,15 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->keyboard_input_is_hidden = false;
}
ply_window_set_keyboard_input_handler (window, NULL, NULL);
ply_window_set_backspace_handler (window, NULL, NULL);
ply_window_set_enter_handler (window, NULL, NULL);
ply_window_set_keyboard_input_handler (plugin->window, NULL, NULL);
ply_window_set_backspace_handler (plugin->window, NULL, NULL);
ply_window_set_enter_handler (plugin->window, NULL, NULL);
ply_event_loop_stop_watching_for_exit (plugin->loop,
(ply_event_loop_exit_handler_t)
detach_from_event_loop,
plugin);
detach_from_event_loop (plugin);
plugin->window = NULL;
}
void
@ -254,6 +263,8 @@ ply_boot_splash_plugin_get_interface (void)
{
.create_plugin = create_plugin,
.destroy_plugin = destroy_plugin,
.add_window = add_window,
.remove_window = remove_window,
.show_splash_screen = show_splash_screen,
.update_status = update_status,
.on_boot_output = on_boot_output,

View file

@ -426,30 +426,43 @@ on_erase (ply_boot_splash_plugin_t *plugin,
0x807c71, 0x3a362f);
}
void
add_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = window;
}
void
remove_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = NULL;
}
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);
assert (plugin->logo_image != NULL);
ply_window_set_keyboard_input_handler (window,
ply_window_set_keyboard_input_handler (plugin->window,
(ply_window_keyboard_input_handler_t)
on_keyboard_input, plugin);
ply_window_set_backspace_handler (window,
ply_window_set_backspace_handler (plugin->window,
(ply_window_backspace_handler_t)
on_backspace, plugin);
ply_window_set_enter_handler (window,
ply_window_set_enter_handler (plugin->window,
(ply_window_enter_handler_t)
on_enter, plugin);
ply_window_set_draw_handler (window,
ply_window_set_draw_handler (plugin->window,
(ply_window_draw_handler_t)
on_draw, plugin);
ply_window_set_erase_handler (window,
ply_window_set_erase_handler (plugin->window,
(ply_window_erase_handler_t)
on_erase, plugin);
@ -471,8 +484,6 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
if (!ply_entry_load (plugin->entry))
return false;
plugin->window = window;
ply_trace ("setting graphics mode");
if (!ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_GRAPHICS))
return false;
@ -573,8 +584,7 @@ update_status (ply_boot_splash_plugin_t *plugin,
void
hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window)
ply_event_loop_t *loop)
{
assert (plugin != NULL);
@ -584,9 +594,9 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->pending_password_answer = NULL;
}
ply_window_set_keyboard_input_handler (window, NULL, NULL);
ply_window_set_backspace_handler (window, NULL, NULL);
ply_window_set_enter_handler (window, NULL, NULL);
ply_window_set_keyboard_input_handler (plugin->window, NULL, NULL);
ply_window_set_backspace_handler (plugin->window, NULL, NULL);
ply_window_set_enter_handler (plugin->window, NULL, NULL);
if (plugin->loop != NULL)
{
@ -601,7 +611,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->frame_buffer = NULL;
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
plugin->window = NULL;
}
static void
@ -649,6 +658,8 @@ ply_boot_splash_plugin_get_interface (void)
{
.create_plugin = create_plugin,
.destroy_plugin = destroy_plugin,
.add_window = add_window,
.remove_window = remove_window,
.show_splash_screen = show_splash_screen,
.update_status = update_status,
.hide_splash_screen = hide_splash_screen,

View file

@ -112,6 +112,8 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
ply_entry_free (plugin->entry);
ply_throbber_free (plugin->throbber);
ply_label_free (plugin->label);
free (plugin);
}
@ -301,30 +303,43 @@ on_erase (ply_boot_splash_plugin_t *plugin,
PLYMOUTH_BACKGROUND_END_COLOR);
}
void
add_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = window;
}
void
remove_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = NULL;
}
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);
assert (plugin->logo_image != NULL);
ply_window_set_keyboard_input_handler (window,
ply_window_set_keyboard_input_handler (plugin->window,
(ply_window_keyboard_input_handler_t)
on_keyboard_input, plugin);
ply_window_set_backspace_handler (window,
ply_window_set_backspace_handler (plugin->window,
(ply_window_backspace_handler_t)
on_backspace, plugin);
ply_window_set_enter_handler (window,
ply_window_set_enter_handler (plugin->window,
(ply_window_enter_handler_t)
on_enter, plugin);
ply_window_set_draw_handler (window,
ply_window_set_draw_handler (plugin->window,
(ply_window_draw_handler_t)
on_draw, plugin);
ply_window_set_erase_handler (window,
ply_window_set_erase_handler (plugin->window,
(ply_window_erase_handler_t)
on_erase, plugin);
@ -350,8 +365,6 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
if (!ply_throbber_load (plugin->throbber))
return false;
plugin->window = window;
ply_trace ("setting graphics mode");
if (!ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_GRAPHICS))
return false;
@ -382,8 +395,7 @@ update_status (ply_boot_splash_plugin_t *plugin,
void
hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window)
ply_event_loop_t *loop)
{
assert (plugin != NULL);
@ -393,11 +405,11 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->pending_password_answer = NULL;
}
ply_window_set_keyboard_input_handler (window, NULL, NULL);
ply_window_set_backspace_handler (window, NULL, NULL);
ply_window_set_enter_handler (window, NULL, NULL);
ply_window_set_draw_handler (window, NULL, NULL);
ply_window_set_erase_handler (window, NULL, NULL);
ply_window_set_keyboard_input_handler (plugin->window, NULL, NULL);
ply_window_set_backspace_handler (plugin->window, NULL, NULL);
ply_window_set_enter_handler (plugin->window, NULL, NULL);
ply_window_set_draw_handler (plugin->window, NULL, NULL);
ply_window_set_erase_handler (plugin->window, NULL, NULL);
if (plugin->loop != NULL)
{
@ -410,8 +422,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
}
plugin->frame_buffer = NULL;
plugin->window = NULL;
}
static void
@ -506,6 +516,8 @@ ply_boot_splash_plugin_get_interface (void)
{
.create_plugin = create_plugin,
.destroy_plugin = destroy_plugin,
.add_window = add_window,
.remove_window = remove_window,
.show_splash_screen = show_splash_screen,
.update_status = update_status,
.hide_splash_screen = hide_splash_screen,

View file

@ -199,27 +199,40 @@ on_erase (ply_boot_splash_plugin_t *plugin,
ply_window_clear_screen (plugin->window);
}
void
add_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = window;
}
void
remove_window (ply_boot_splash_plugin_t *plugin,
ply_window_t *window)
{
plugin->window = NULL;
}
bool
show_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window,
ply_buffer_t *boot_buffer)
{
assert (plugin != NULL);
ply_window_set_keyboard_input_handler (window,
ply_window_set_keyboard_input_handler (plugin->window,
(ply_window_keyboard_input_handler_t)
on_keyboard_input, plugin);
ply_window_set_backspace_handler (window,
ply_window_set_backspace_handler (plugin->window,
(ply_window_backspace_handler_t)
on_backspace, plugin);
ply_window_set_enter_handler (window,
ply_window_set_enter_handler (plugin->window,
(ply_window_enter_handler_t)
on_enter, plugin);
ply_window_set_draw_handler (window,
ply_window_set_draw_handler (plugin->window,
(ply_window_draw_handler_t)
on_draw, plugin);
ply_window_set_erase_handler (window,
ply_window_set_erase_handler (plugin->window,
(ply_window_erase_handler_t)
on_erase, plugin);
@ -228,8 +241,6 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
detach_from_event_loop,
plugin);
plugin->window = window;
start_animation (plugin);
return true;
@ -246,8 +257,7 @@ update_status (ply_boot_splash_plugin_t *plugin,
void
hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop,
ply_window_t *window)
ply_event_loop_t *loop)
{
assert (plugin != NULL);
@ -259,11 +269,11 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->pending_password_answer = NULL;
}
ply_window_set_keyboard_input_handler (window, NULL, NULL);
ply_window_set_backspace_handler (window, NULL, NULL);
ply_window_set_enter_handler (window, NULL, NULL);
ply_window_set_draw_handler (window, NULL, NULL);
ply_window_set_erase_handler (window, NULL, NULL);
ply_window_set_keyboard_input_handler (plugin->window, NULL, NULL);
ply_window_set_backspace_handler (plugin->window, NULL, NULL);
ply_window_set_enter_handler (plugin->window, NULL, NULL);
ply_window_set_draw_handler (plugin->window, NULL, NULL);
ply_window_set_erase_handler (plugin->window, NULL, NULL);
if (plugin->loop != NULL)
{
@ -280,8 +290,6 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_window_clear_screen (plugin->window);
ply_window_show_text_cursor (plugin->window);
ply_window_reset_colors (plugin->window);
plugin->window = NULL;
}
void
@ -322,6 +330,8 @@ ply_boot_splash_plugin_get_interface (void)
{
.create_plugin = create_plugin,
.destroy_plugin = destroy_plugin,
.add_window = add_window,
.remove_window = remove_window,
.show_splash_screen = show_splash_screen,
.update_status = update_status,
.hide_splash_screen = hide_splash_screen,

View file

@ -170,10 +170,11 @@ ply_boot_splash_show (ply_boot_splash_t *splash)
assert (splash->plugin != NULL);
assert (splash->plugin_interface->show_splash_screen != NULL);
splash->plugin_interface->add_window (splash->plugin, splash->window);
ply_trace ("showing splash screen\n");
if (!splash->plugin_interface->show_splash_screen (splash->plugin,
splash->loop,
splash->window,
splash->boot_buffer))
{
@ -260,8 +261,9 @@ ply_boot_splash_hide (ply_boot_splash_t *splash)
assert (splash->plugin_interface->hide_splash_screen != NULL);
splash->plugin_interface->hide_splash_screen (splash->plugin,
splash->loop,
splash->window);
splash->loop);
splash->plugin_interface->remove_window (splash->plugin, splash->window);
splash->is_shown = false;