From: Ray Strode Date: Fri, 29 Nov 2013 16:28:52 +0000 (-0500) Subject: boot-splash: add support for seat objects X-Git-Tag: 0.9.0~65^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24a21ee0f3aaeb6f648dab429c5df6b910f89002;p=thirdparty%2Fplymouth.git boot-splash: add support for seat objects ply_boot_splash_t currently gets notified about displays and keyboard objects to pass along to the splash plugins. Now that we have a ply_seat_t object that can encapsulate display and keyboard objects, we should add support to ply_boot_splash_t for using it. This commit does that. For now, it does it without changing the plugin interface (which is still in terms of displays and keyboards). Note, this commit only adds support for seat objects to ply_boot_splash_t. It doesn't actually change any of the calling code to use that support. That will come in a subsequent commit. --- diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c index cf052915..86708374 100644 --- a/src/libply-splash-core/ply-boot-splash.c +++ b/src/libply-splash-core/ply-boot-splash.c @@ -58,6 +58,7 @@ struct _ply_boot_splash ply_keyboard_t *keyboard; ply_buffer_t *boot_buffer; ply_trigger_t *idle_trigger; + ply_list_t *seats; ply_list_t *pixel_displays; ply_list_t *text_displays; @@ -98,6 +99,7 @@ ply_boot_splash_new (const char *theme_path, splash->boot_buffer = boot_buffer; splash->pixel_displays = ply_list_new (); splash->text_displays = ply_list_new (); + splash->seats = ply_list_new (); return splash; } @@ -117,6 +119,9 @@ ply_boot_splash_set_keyboard (ply_boot_splash_t *splash, void ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash) { + if (splash->keyboard == NULL) + return; + if (splash->plugin_interface->set_keyboard == NULL) return; @@ -171,6 +176,165 @@ ply_boot_splash_remove_text_display (ply_boot_splash_t *splash, splash->plugin_interface->remove_text_display (splash->plugin, display); } +static void +detach_from_seat (ply_boot_splash_t *splash, + ply_seat_t *seat) +{ + ply_keyboard_t *keyboard; + ply_list_t *displays; + ply_list_node_t *node, *next_node; + + ply_trace ("removing keyboard"); + if (splash->plugin_interface->unset_keyboard != NULL) + { + keyboard = ply_seat_get_keyboard (seat); + splash->plugin_interface->unset_keyboard (splash->plugin, keyboard); + } + + ply_trace ("removing pixel displays"); + displays = ply_seat_get_pixel_displays (seat); + + node = ply_list_get_first_node (displays); + while (node != NULL) + { + ply_pixel_display_t *display; + ply_list_node_t *next_node; + unsigned long width, height; + + display = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (displays, node); + + width = ply_pixel_display_get_width (display); + height = ply_pixel_display_get_height (display); + + ply_trace ("Removing %lux%lu pixel display", width, height); + + if (splash->plugin_interface->remove_pixel_display != NULL) + splash->plugin_interface->remove_pixel_display (splash->plugin, display); + + node = next_node; + } + + ply_trace ("removing text displays"); + displays = ply_seat_get_text_displays (seat); + + node = ply_list_get_first_node (displays); + while (node != NULL) + { + ply_text_display_t *display; + int number_of_columns, number_of_rows; + + display = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (displays, node); + + number_of_columns = ply_text_display_get_number_of_columns (display); + number_of_rows = ply_text_display_get_number_of_rows (display); + + ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows); + + if (splash->plugin_interface->remove_text_display != NULL) + splash->plugin_interface->remove_text_display (splash->plugin, display); + + node = next_node; + } +} + +static void +attach_to_seat (ply_boot_splash_t *splash, + ply_seat_t *seat) +{ + ply_keyboard_t *keyboard; + ply_list_t *displays; + ply_list_node_t *node, *next_node; + + if (splash->plugin_interface->set_keyboard != NULL) + { + keyboard = ply_seat_get_keyboard (seat); + splash->plugin_interface->set_keyboard (splash->plugin, keyboard); + } + + if (splash->plugin_interface->add_pixel_display != NULL) + { + displays = ply_seat_get_pixel_displays (seat); + + ply_trace ("adding pixel displays"); + node = ply_list_get_first_node (displays); + while (node != NULL) + { + ply_pixel_display_t *display; + ply_list_node_t *next_node; + unsigned long width, height; + + display = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (displays, node); + + width = ply_pixel_display_get_width (display); + height = ply_pixel_display_get_height (display); + + ply_trace ("Adding %lux%lu pixel display", width, height); + + splash->plugin_interface->add_pixel_display (splash->plugin, display); + + node = next_node; + } + } + + if (splash->plugin_interface->add_text_display != NULL) + { + displays = ply_seat_get_text_displays (seat); + + ply_trace ("adding text displays"); + node = ply_list_get_first_node (displays); + while (node != NULL) + { + ply_text_display_t *display; + int number_of_columns, number_of_rows; + + display = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (displays, node); + + number_of_columns = ply_text_display_get_number_of_columns (display); + number_of_rows = ply_text_display_get_number_of_rows (display); + + ply_trace ("Adding %dx%d text display", number_of_columns, number_of_rows); + + splash->plugin_interface->add_text_display (splash->plugin, display); + + node = next_node; + } + } +} + +void +ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash, + ply_seat_t *seat) +{ + ply_list_node_t *node; + + node = ply_list_find_node (splash->seats, seat); + + if (node != NULL) + return; + + ply_list_append_data (splash->seats, seat); + attach_to_seat (splash, seat); +} + +void +ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash, + ply_seat_t *seat) +{ + ply_list_node_t *node; + + node = ply_list_find_node (splash->seats, seat); + + if (node == NULL) + return; + + ply_list_remove_data (splash->seats, seat); + detach_from_seat (splash, seat); +} + bool ply_boot_splash_load (ply_boot_splash_t *splash) { @@ -359,6 +523,30 @@ remove_displays (ply_boot_splash_t *splash) } } +static void +detach_from_seats (ply_boot_splash_t *splash) +{ + ply_list_node_t *node; + + ply_trace ("detaching from seats"); + + node = ply_list_get_first_node (splash->seats); + while (node != NULL) + { + ply_seat_t *seat; + ply_list_node_t *next_node; + + seat = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (splash->seats, node); + + detach_from_seat (splash, seat); + + ply_list_remove_node (splash->seats, node); + + node = next_node; + } +} + void ply_boot_splash_free (ply_boot_splash_t *splash) { @@ -384,6 +572,9 @@ ply_boot_splash_free (ply_boot_splash_t *splash) ply_list_free (splash->pixel_displays); ply_list_free (splash->text_displays); + detach_from_seats (splash); + ply_list_free (splash->seats); + if (splash->module_handle != NULL) ply_boot_splash_unload (splash); diff --git a/src/libply-splash-core/ply-boot-splash.h b/src/libply-splash-core/ply-boot-splash.h index a79e9396..3f66b70d 100644 --- a/src/libply-splash-core/ply-boot-splash.h +++ b/src/libply-splash-core/ply-boot-splash.h @@ -33,10 +33,12 @@ #include "ply-pixel-display.h" #include "ply-text-display.h" #include "ply-progress.h" +#include "ply-seat.h" #include "ply-boot-splash-plugin.h" typedef struct _ply_boot_splash ply_boot_splash_t; +typedef struct _ply_seat ply_seat_t; typedef void (* ply_boot_splash_on_idle_handler_t) (void *user_data); @@ -48,6 +50,10 @@ ply_boot_splash_t *ply_boot_splash_new (const char * theme_path, bool ply_boot_splash_load (ply_boot_splash_t *splash); bool ply_boot_splash_load_built_in (ply_boot_splash_t *splash); void ply_boot_splash_unload (ply_boot_splash_t *splash); +void ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash, + ply_seat_t *seat); +void ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash, + ply_seat_t *seat); void ply_boot_splash_set_keyboard (ply_boot_splash_t *splash, ply_keyboard_t *keyboard); void ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash); diff --git a/src/libply-splash-core/ply-seat.c b/src/libply-splash-core/ply-seat.c index 82bbb894..d1493a71 100644 --- a/src/libply-splash-core/ply-seat.c +++ b/src/libply-splash-core/ply-seat.c @@ -29,6 +29,7 @@ #include #include +#include "ply-boot-splash.h" #include "ply-event-loop.h" #include "ply-keyboard.h" #include "ply-pixel-display.h" @@ -41,6 +42,7 @@ struct _ply_seat { ply_event_loop_t *loop; + ply_boot_splash_t *splash; ply_terminal_t *terminal; ply_renderer_t *renderer; ply_keyboard_t *keyboard; @@ -263,6 +265,22 @@ ply_seat_close (ply_seat_t *seat) seat->renderer = NULL; } +void +ply_seat_set_splash (ply_seat_t *seat, + ply_boot_splash_t *splash) +{ + if (seat->splash == splash) + return; + + if (seat->splash != NULL) + ply_boot_splash_detach_from_seat (splash, seat); + + if (splash != NULL) + ply_boot_splash_attach_to_seat (splash, seat); + + seat->splash = splash; +} + static void free_pixel_displays (ply_seat_t *seat) { diff --git a/src/libply-splash-core/ply-seat.h b/src/libply-splash-core/ply-seat.h index 73927789..d5d33978 100644 --- a/src/libply-splash-core/ply-seat.h +++ b/src/libply-splash-core/ply-seat.h @@ -27,6 +27,7 @@ #include #include +#include "ply-boot-splash.h" #include "ply-buffer.h" #include "ply-event-loop.h" #include "ply-keyboard.h" @@ -35,6 +36,7 @@ #include "ply-terminal.h" #include "ply-text-display.h" +typedef struct _ply_boot_splash ply_boot_splash_t; typedef struct _ply_seat ply_seat_t; #ifndef PLY_HIDE_FUNCTION_DECLARATIONS @@ -51,6 +53,9 @@ void ply_seat_deactivate_renderer (ply_seat_t *seat); void ply_seat_activate_renderer (ply_seat_t *seat); void ply_seat_refresh_displays (ply_seat_t *seat); void ply_seat_close (ply_seat_t *seat); +void ply_seat_set_splash (ply_seat_t *seat, + ply_boot_splash_t *splash); + ply_list_t *ply_seat_get_pixel_displays (ply_seat_t *seat); ply_list_t *ply_seat_get_text_displays (ply_seat_t *seat); ply_keyboard_t *ply_seat_get_keyboard (ply_seat_t *seat);