[PATCH 19/20] [daemon] add "has active vt?" request
Scott James Remnant
scott at ubuntu.com
Thu Mar 18 14:05:32 PDT 2010
One problem with the current deactivate/quit transition into X is that
the display manager will, if Plymouth was running, re-use the currently
active VT.
That only works if Plymouth was actually displaying a splash screen on
that VT. If --show-splash hasn't been called yet because we booted too
fast, we'll be on the wrong VT.
Add a request to ask whether the Plymouth VT is active; I've done it
this way so the answer defaults to "yes" for Fedora who use VT1.
The pseudo-code for transition is thus:
if plymouth is running (ping):
plymouth deactivate
if plymouth has active vt:
start X on current VT with -nr
if X starts ok:
plymouth quit --retain-splash
else if X fails:
plymouth quit
else if plymouth doesn't have active vt:
plymouth quit
start X as normal
else if plymouth isn't running:
start X as normal
---
src/main.c | 10 ++++++++++
src/ply-boot-protocol.h | 1 +
src/ply-boot-server.c | 32 +++++++++++++++++++++++++++++++-
src/ply-boot-server.h | 3 +++
4 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/src/main.c b/src/main.c
index 378bdaa..a995edb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -890,6 +890,15 @@ on_quit (state_t *state,
quit_program (state);
}
+static bool
+on_has_active_vt (state_t *state)
+{
+ if (state->terminal != NULL)
+ return ply_terminal_is_active (state->terminal);
+ else
+ return false;
+}
+
static ply_boot_server_t *
start_boot_server (state_t *state)
{
@@ -911,6 +920,7 @@ start_boot_server (state_t *state)
(ply_boot_server_deactivate_handler_t) on_deactivate,
(ply_boot_server_reactivate_handler_t) on_reactivate,
(ply_boot_server_quit_handler_t) on_quit,
+ (ply_boot_server_has_active_vt_handler_t) on_has_active_vt,
state);
if (!ply_boot_server_listen (server))
diff --git a/src/ply-boot-protocol.h b/src/ply-boot-protocol.h
index 594c25c..aeaa3d0 100644
--- a/src/ply-boot-protocol.h
+++ b/src/ply-boot-protocol.h
@@ -40,6 +40,7 @@
#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_SPLASH "$"
#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_SPLASH "H"
#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT "R"
+#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT "V"
#define PLY_BOOT_PROTOCOL_REQUEST_TYPE_ERROR "!"
#define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK "\x6"
diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c
index bd24836..42c10f7 100644
--- a/src/ply-boot-server.c
+++ b/src/ply-boot-server.c
@@ -68,6 +68,7 @@ struct _ply_boot_server
ply_boot_server_deactivate_handler_t deactivate_handler;
ply_boot_server_reactivate_handler_t reactivate_handler;
ply_boot_server_quit_handler_t quit_handler;
+ ply_boot_server_has_active_vt_handler_t has_active_vt_handler;
void *user_data;
uint32_t is_listening : 1;
@@ -89,7 +90,8 @@ ply_boot_server_new (ply_boot_server_update_handler_t update_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,
+ ply_boot_server_quit_handler_t quit_handler,
+ ply_boot_server_has_active_vt_handler_t has_active_vt_handler,
void *user_data)
{
ply_boot_server_t *server;
@@ -115,6 +117,7 @@ ply_boot_server_new (ply_boot_server_update_handler_t update_handler,
server->deactivate_handler = deactivate_handler;
server->reactivate_handler = reactivate_handler;
server->quit_handler = quit_handler;
+ server->has_active_vt_handler = has_active_vt_handler;
server->user_data = user_data;
return server;
@@ -582,6 +585,25 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection)
if (server->newroot_handler != NULL)
server->newroot_handler(server->user_data, argument, server);
}
+ else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT) == 0)
+ {
+ bool answer = false;
+
+ ply_trace ("got has_active vt? request");
+ if (server->has_active_vt_handler != NULL)
+ answer = server->has_active_vt_handler(server->user_data, server);
+
+ if (!answer)
+ {
+ if (!ply_write (connection->fd,
+ PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK,
+ strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK)))
+ ply_error ("could not write bytes: %m");
+
+ free(command);
+ return;
+ }
+ }
else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING) != 0)
{
ply_error ("received unknown command '%s' from client", command);
@@ -803,6 +825,13 @@ on_ignore_keystroke (ply_event_loop_t *loop)
return;
}
+static bool
+on_has_active_vt (ply_event_loop_t *loop)
+{
+ printf ("got has_active vt? request\n");
+ return true;
+}
+
int
main (int argc,
char **argv)
@@ -831,6 +860,7 @@ main (int argc,
(ply_boot_server_deactivate_handler_t) on_deactivate,
(ply_boot_server_reactivate_handler_t) on_reactivate,
(ply_boot_server_quit_handler_t) on_quit,
+ (ply_boot_server_has_active_vt_handler_t) on_has_active_vt,
loop);
if (!ply_boot_server_listen (server))
diff --git a/src/ply-boot-server.h b/src/ply-boot-server.h
index 7ea8fc6..4c229f4 100644
--- a/src/ply-boot-server.h
+++ b/src/ply-boot-server.h
@@ -89,6 +89,8 @@ typedef void (* ply_boot_server_quit_handler_t) (void *user_data,
bool retain_splash,
ply_trigger_t *quit_trigger,
ply_boot_server_t *server);
+typedef bool (* ply_boot_server_has_active_vt_handler_t) (void *user_data,
+ ply_boot_server_t *server);
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_handler,
@@ -107,6 +109,7 @@ ply_boot_server_t *ply_boot_server_new (ply_boot_server_update_handler_t update_
ply_boot_server_deactivate_handler_t deactivate_handler,
ply_boot_server_reactivate_handler_t reactivate_handler,
ply_boot_server_quit_handler_t quit_handler,
+ ply_boot_server_has_active_vt_handler_t has_active_vt_handler,
void *user_data);
void ply_boot_server_free (ply_boot_server_t *server);
--
1.7.0
More information about the plymouth
mailing list