From: Ray Strode Date: Sat, 13 Sep 2008 15:56:14 +0000 (-0400) Subject: Add {add,remove}_window funcs to splash plugins X-Git-Tag: 0.6.0~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7bc5f28a733d2dd1e1c8359e18fae4ae73c433d;p=thirdparty%2Fplymouth.git Add {add,remove}_window funcs to splash plugins We'll be able to have more than one window for serial consoles, etc. --- diff --git a/src/libplybootsplash/ply-boot-splash-plugin.h b/src/libplybootsplash/ply-boot-splash-plugin.h index 25b3fe68..8e3d2fac 100644 --- a/src/libplybootsplash/ply-boot-splash-plugin.h +++ b/src/libplybootsplash/ply-boot-splash-plugin.h @@ -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, diff --git a/src/plugins/splash/details/plugin.c b/src/plugins/splash/details/plugin.c index 34fa5d86..4e3292ba 100644 --- a/src/plugins/splash/details/plugin.c +++ b/src/plugins/splash/details/plugin.c @@ -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, diff --git a/src/plugins/splash/fade-in/plugin.c b/src/plugins/splash/fade-in/plugin.c index 604c1814..dd1cb362 100644 --- a/src/plugins/splash/fade-in/plugin.c +++ b/src/plugins/splash/fade-in/plugin.c @@ -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, diff --git a/src/plugins/splash/spinfinity/plugin.c b/src/plugins/splash/spinfinity/plugin.c index cd9a85b0..2759ad25 100644 --- a/src/plugins/splash/spinfinity/plugin.c +++ b/src/plugins/splash/spinfinity/plugin.c @@ -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, diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c index 465d7634..63ff2f60 100644 --- a/src/plugins/splash/text/plugin.c +++ b/src/plugins/splash/text/plugin.c @@ -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, diff --git a/src/ply-boot-splash.c b/src/ply-boot-splash.c index ca2d3cfd..a9baa3ee 100644 --- a/src/ply-boot-splash.c +++ b/src/ply-boot-splash.c @@ -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;