From: Ray Strode Date: Sat, 28 Nov 2009 04:29:30 +0000 (-0500) Subject: [daemon] deactivate daemon for X transition X-Git-Tag: 0.8.0~104^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45967baeb0249f1f3fd1b18db9a4a1cdd5e1fa83;p=thirdparty%2Fplymouth.git [daemon] deactivate daemon for X transition In order for plymouth to be able to stay around until after X is started, we need to put the daemon into a "deactivated" state where it makes the splash becomes idle and relinquishes control of the scan out hardware and keyboard for X to seize. This commit listens for deactivation requests in the daemon and performs the deactivation. A future commit will implement the client bits needed. --- diff --git a/src/main.c b/src/main.c index 197c8e61..95dc9fe3 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,7 @@ typedef struct ply_renderer_t *renderer; ply_terminal_t *terminal; + ply_trigger_t *deactivate_trigger; ply_trigger_t *quit_trigger; char kernel_command_line[PLY_MAX_COMMAND_LINE_SIZE]; @@ -106,6 +107,7 @@ typedef struct uint32_t is_attached : 1; uint32_t should_be_attached : 1; uint32_t should_retain_splash : 1; + uint32_t is_inactive : 1; char *kernel_console_tty; char *override_splash_path; @@ -693,7 +695,24 @@ quit_program (state_t *state) static void on_boot_splash_idle (state_t *state) { + ply_trace ("boot splash idle"); + + if (state->deactivate_trigger != NULL) + { + ply_trace ("deactivating renderer"); + ply_renderer_deactivate (state->renderer); + + ply_trace ("quitting splash"); + quit_splash (state); + + ply_trigger_pull (state->deactivate_trigger, NULL); + state->deactivate_trigger = NULL; + state->is_inactive = true; + + return; + } + if (!state->should_retain_splash) { ply_trace ("hiding splash"); @@ -707,6 +726,27 @@ on_boot_splash_idle (state_t *state) quit_program (state); } + +static void +on_deactivate (state_t *state, + ply_trigger_t *deactivate_trigger) +{ + ply_trace ("deactivating"); + if (state->boot_splash != NULL) + { + state->deactivate_trigger = deactivate_trigger; + ply_boot_splash_become_idle (state->boot_splash, + (ply_boot_splash_on_idle_handler_t) + on_boot_splash_idle, + state); + } + else + { + ply_trigger_pull (state->deactivate_trigger, NULL); + state->deactivate_trigger = NULL; + } +} + static void on_quit (state_t *state, bool retain_splash, @@ -728,6 +768,10 @@ on_quit (state_t *state, on_boot_splash_idle, state); } + else if (state->is_inactive && !retain_splash) + /* We've been deactivated and X failed to start + */ + dump_details_and_quit_splash (state); else quit_program (state); } @@ -750,6 +794,7 @@ start_boot_server (state_t *state) (ply_boot_server_newroot_handler_t) on_newroot, (ply_boot_server_system_initialized_handler_t) on_system_initialized, (ply_boot_server_error_handler_t) on_error, + (ply_boot_server_deactivate_handler_t) on_deactivate, (ply_boot_server_quit_handler_t) on_quit, state); diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h index 419d4810..6be72186 100644 --- a/src/ply-boot-protocol.h +++ b/src/ply-boot-protocol.h @@ -26,6 +26,7 @@ #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING "P" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_UPDATE "U" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_INITIALIZED "S" +#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_DEACTIVATE "D" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT "Q" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD "*" #define PLY_BOOT_PROTOCOL_REQUEST_TYPE_CACHED_PASSWORD "c" diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c index 9a1ed8e4..4cc579f6 100644 --- a/src/ply-boot-server.c +++ b/src/ply-boot-server.c @@ -65,6 +65,7 @@ struct _ply_boot_server ply_boot_server_ignore_keystroke_handler_t ignore_keystroke_handler; ply_boot_server_progress_pause_handler_t progress_pause_handler; ply_boot_server_progress_unpause_handler_t progress_unpause_handler; + ply_boot_server_deactivate_handler_t deactivate_handler; ply_boot_server_quit_handler_t quit_handler; void *user_data; @@ -85,6 +86,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t update_handler, ply_boot_server_newroot_handler_t newroot_handler, ply_boot_server_system_initialized_handler_t initialized_handler, ply_boot_server_error_handler_t error_handler, + ply_boot_server_deactivate_handler_t deactivate_handler, ply_boot_server_quit_handler_t quit_handler, void *user_data) { @@ -108,6 +110,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t update_handler, server->system_initialized_handler = initialized_handler; server->show_splash_handler = show_splash_handler; server->hide_splash_handler = hide_splash_handler; + server->deactivate_handler = deactivate_handler; server->quit_handler = quit_handler; server->user_data = user_data; @@ -271,6 +274,17 @@ ply_boot_connection_on_password_answer (ply_boot_connection_t *connection, } +static void +ply_boot_connection_on_deactivated (ply_boot_connection_t *connection) +{ + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK))) + { + ply_error ("could not write bytes: %m"); + } +} + static void ply_boot_connection_on_quit_complete (ply_boot_connection_t *connection) { @@ -353,6 +367,24 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) if (server->hide_splash_handler != NULL) server->hide_splash_handler (server->user_data, server); } + else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_DEACTIVATE) == 0) + { + ply_trigger_t *deactivate_trigger; + + deactivate_trigger = ply_trigger_new (NULL); + + ply_trigger_add_handler (deactivate_trigger, + (ply_trigger_handler_t) + ply_boot_connection_on_deactivated, + connection); + + if (server->deactivate_handler != NULL) + server->deactivate_handler (server->user_data, deactivate_trigger, server); + + free (argument); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT) == 0) { bool retain_splash; @@ -662,6 +694,12 @@ on_hide_splash (ply_event_loop_t *loop) printf ("got hide splash request\n"); } +static void +on_deactivate (ply_event_loop_t *loop) +{ + printf ("got deactivate request\n"); +} + static void on_quit (ply_event_loop_t *loop) { @@ -754,6 +792,7 @@ main (int argc, (ply_boot_server_newroot_handler_t) on_newroot, (ply_boot_server_system_initialized_handler_t) on_system_initialized, (ply_boot_server_error_handler_t) on_error, + (ply_boot_server_deactivate_handler_t) on_deactivate, (ply_boot_server_quit_handler_t) on_quit, loop); diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h index ad145ca2..f2f815ae 100644 --- a/src/ply-boot-server.h +++ b/src/ply-boot-server.h @@ -80,6 +80,9 @@ typedef void (* ply_boot_server_system_initialized_handler_t) (void typedef void (* ply_boot_server_error_handler_t) (void *user_data, ply_boot_server_t *server); +typedef void (* ply_boot_server_deactivate_handler_t) (void *user_data, + ply_trigger_t *deactivate_trigger, + ply_boot_server_t *server); typedef void (* ply_boot_server_quit_handler_t) (void *user_data, bool retain_splash, ply_trigger_t *quit_trigger, @@ -99,6 +102,7 @@ ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_ ply_boot_server_newroot_handler_t newroot_handler, ply_boot_server_system_initialized_handler_t initialized_handler, ply_boot_server_error_handler_t error_handler, + ply_boot_server_deactivate_handler_t deactivate_handler, ply_boot_server_quit_handler_t quit_handler, void *user_data);