]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[daemon] deactivate daemon for X transition
authorRay Strode <rstrode@redhat.com>
Sat, 28 Nov 2009 04:29:30 +0000 (23:29 -0500)
committerRay Strode <rstrode@redhat.com>
Sat, 28 Nov 2009 05:24:59 +0000 (00:24 -0500)
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.

src/main.c
src/ply-boot-protocol.h
src/ply-boot-server.c
src/ply-boot-server.h

index 197c8e61068a7d5f80db569374cc58ea219a1542..95dc9fe354a32aa1b0414c8c2fa09d9fb28a8c8e 100644 (file)
@@ -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);
 
index 419d48100b638b62c8f54ce729e0d1e2f233f361..6be72186fc3c1dd3f4fdbf11cd60411ca99b09a3 100644 (file)
@@ -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"
index 9a1ed8e45dac457ec5e238af167d9fe8b1bbe135..4cc579f6efe44d2f75661005e8257365c442ed8b 100644 (file)
@@ -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);
 
index ad145ca20a627574ffbc6cb2485a781bf6cf7a9f..f2f815ae0ef1ef5582400346e605860aa7bdafbe 100644 (file)
@@ -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);