[PATCH 12/20] [daemon] add reactivate command

Scott James Remnant scott at ubuntu.com
Thu Mar 18 13:53:39 PDT 2010


More for debugging and completeness than anything else, add a
"reactivate" command to the daemon that undoes the effects of
deactivate and continues the splash screen on its way.

Another possible use for this could be (for example) providing a
seamless shutdown experience.

A future commit will implement the client bits needed.
---
 src/main.c              |   35 +++++++++++++++++++++++++++++++++++
 src/ply-boot-protocol.h |    1 +
 src/ply-boot-server.c   |   20 ++++++++++++++++++--
 src/ply-boot-server.h   |    3 +++
 4 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 29408d3..6e95c4c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -818,6 +818,40 @@ on_deactivate (state_t       *state,
 }
 
 static void
+on_reactivate (state_t *state)
+{
+  if (!state->is_inactive)
+    return;
+
+  if (state->terminal != NULL)
+    {
+      ply_terminal_watch_for_vt_changes (state->terminal);
+      ply_terminal_set_unbuffered_input (state->terminal);
+      ply_terminal_ignore_mode_changes (state->terminal, false);
+    }
+
+  if ((state->session != NULL) && state->should_be_attached)
+    {
+      ply_trace ("reactivating terminal session");
+      attach_to_running_session (state);
+    }
+
+  if (state->keyboard != NULL)
+    {
+      ply_trace ("activating keyboard");
+      ply_keyboard_watch_for_input (state->keyboard);
+    }
+
+  if (state->renderer != NULL)
+    {
+      ply_trace ("activating renderer");
+      ply_renderer_activate (state->renderer);
+    }
+
+  state->is_inactive = false;
+}
+
+static void
 on_quit (state_t       *state,
          bool           retain_splash,
          ply_trigger_t *quit_trigger)
@@ -873,6 +907,7 @@ start_boot_server (state_t *state)
                                 (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_reactivate_handler_t) on_reactivate,
                                 (ply_boot_server_quit_handler_t) on_quit,
                                 state);
 
diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h
index 6be7218..594c25c 100644
--- a/src/ply-boot-protocol.h
+++ b/src/ply-boot-protocol.h
@@ -27,6 +27,7 @@
 #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_REACTIVATE "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 6cab887..bd24836 100644
--- a/src/ply-boot-server.c
+++ b/src/ply-boot-server.c
@@ -66,6 +66,7 @@ struct _ply_boot_server
   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_reactivate_handler_t reactivate_handler;
   ply_boot_server_quit_handler_t quit_handler;
   void *user_data;
 
@@ -85,8 +86,9 @@ ply_boot_server_new (ply_boot_server_update_handler_t  update_handler,
                      ply_boot_server_hide_splash_handler_t hide_splash_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_error_handler_t error_handler,
+                     ply_boot_server_deactivate_handler_t deactivate_handler,
+                     ply_boot_server_reactivate_handler_t reactivate_handler,
                      ply_boot_server_quit_handler_t    quit_handler,
                      void                             *user_data)
 {
@@ -111,6 +113,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t  update_handler,
   server->show_splash_handler = show_splash_handler;
   server->hide_splash_handler = hide_splash_handler;
   server->deactivate_handler = deactivate_handler;
+  server->reactivate_handler = reactivate_handler;
   server->quit_handler = quit_handler;
   server->user_data = user_data;
 
@@ -388,6 +391,12 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection)
       free (command);
       return;
     }
+  else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_REACTIVATE) == 0)
+    {
+      ply_trace ("got reactivate request");
+      if (server->reactivate_handler != NULL)
+        server->reactivate_handler (server->user_data, server);
+    }
   else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT) == 0)
     {
       bool retain_splash;
@@ -722,6 +731,12 @@ on_deactivate (ply_event_loop_t *loop)
 }
 
 static void
+on_reactivate (ply_event_loop_t *loop)
+{
+  printf ("got reactivate request\n");
+}
+
+static void
 on_quit (ply_event_loop_t *loop)
 {
   printf ("got quit request, quiting...\n");
@@ -814,6 +829,7 @@ main (int    argc,
                                 (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_reactivate_handler_t) on_reactivate,
                                 (ply_boot_server_quit_handler_t) on_quit,
                                 loop);
 
diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h
index f2f815a..7ea8fc6 100644
--- a/src/ply-boot-server.h
+++ b/src/ply-boot-server.h
@@ -83,6 +83,8 @@ typedef void (* ply_boot_server_error_handler_t) (void              *user_data,
 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_reactivate_handler_t) (void              *user_data,
+                                                       ply_boot_server_t *server);
 typedef void (* ply_boot_server_quit_handler_t) (void              *user_data,
                                                  bool               retain_splash,
                                                  ply_trigger_t     *quit_trigger,
@@ -103,6 +105,7 @@ ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_
                                         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_reactivate_handler_t reactivate_handler,
                                         ply_boot_server_quit_handler_t quit_handler,
                                         void                        *user_data);
 
-- 
1.7.0



More information about the plymouth mailing list