[PATCH 04/21] [terminal] replace set_active_vt with activate_vt

Scott James Remnant scott at ubuntu.com
Wed Mar 17 20:59:18 PDT 2010


Since a terminal already knows which VT number it is, there's no
need to accept a VT number for switching to this VT.
---
 src/libply-splash-core/ply-terminal.c       |   23 ++++++++++++++++-------
 src/libply-splash-core/ply-terminal.h       |    3 +--
 src/main.c                                  |    3 +--
 src/plugins/renderers/drm/plugin.c          |    3 +--
 src/plugins/renderers/frame-buffer/plugin.c |    3 +--
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c
index ed08657..7725eb4 100644
--- a/src/libply-splash-core/ply-terminal.c
+++ b/src/libply-splash-core/ply-terminal.c
@@ -695,23 +695,32 @@ ply_terminal_get_active_vt (ply_terminal_t *terminal)
   return terminal->active_vt;
 }
 
+static bool
+set_active_vt (ply_terminal_t *terminal,
+               int             vt_number)
+{
+  if (ioctl (terminal->fd, VT_ACTIVATE, vt_number) < 0)
+    return false;
+
+  terminal->next_active_vt = vt_number;
+
+  return true;
+}
+
 bool
-ply_terminal_set_active_vt (ply_terminal_t *terminal,
-                            int             vt_number)
+ply_terminal_activate_vt (ply_terminal_t *terminal)
 {
   assert (terminal != NULL);
 
-  if (vt_number <= 0)
+  if (terminal->vt_number <= 0)
     return false;
 
-  if (vt_number == terminal->active_vt)
+  if (terminal->vt_number == terminal->active_vt)
     return true;
 
-  if (ioctl (terminal->fd, VT_ACTIVATE, vt_number) < 0)
+  if (!set_active_vt (terminal, terminal->vt_number))
     return false;
 
-  terminal->next_active_vt = vt_number;
-
   return true;
 }
 
diff --git a/src/libply-splash-core/ply-terminal.h b/src/libply-splash-core/ply-terminal.h
index 4b9ef5a..2c9c4f8 100644
--- a/src/libply-splash-core/ply-terminal.h
+++ b/src/libply-splash-core/ply-terminal.h
@@ -90,8 +90,7 @@ void ply_terminal_ignore_mode_changes (ply_terminal_t *terminal,
 
 int ply_terminal_get_vt_number (ply_terminal_t *terminal);
 int ply_terminal_get_active_vt (ply_terminal_t *terminal);
-bool ply_terminal_set_active_vt (ply_terminal_t *terminal,
-                                 int             vt_number);
+bool ply_terminal_activate_vt (ply_terminal_t *terminal);
 
 void ply_terminal_watch_for_active_vt_change (ply_terminal_t *terminal,
                                               ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
diff --git a/src/main.c b/src/main.c
index 76ba53a..35c287f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1021,8 +1021,7 @@ add_display_and_keyboard_for_terminal (state_t    *state,
 
   state->terminal = terminal;
 
-  ply_terminal_set_active_vt (state->terminal,
-                              ply_terminal_get_vt_number (state->terminal));
+  ply_terminal_activate_vt (state->terminal);
 
   keyboard = ply_keyboard_new_for_terminal (state->terminal);
   display = ply_text_display_new (state->terminal);
diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c
index 48e9ab0..549955d 100644
--- a/src/plugins/renderers/drm/plugin.c
+++ b/src/plugins/renderers/drm/plugin.c
@@ -806,8 +806,7 @@ map_to_device (ply_renderer_backend_t *backend)
       node = next_node;
     }
 
-  ply_terminal_set_active_vt (backend->terminal,
-                              ply_terminal_get_vt_number (backend->terminal));
+  ply_terminal_activate_vt (backend->terminal);
 
   return head_mapped;
 }
diff --git a/src/plugins/renderers/frame-buffer/plugin.c b/src/plugins/renderers/frame-buffer/plugin.c
index ff2d1dc..1c0e34b 100644
--- a/src/plugins/renderers/frame-buffer/plugin.c
+++ b/src/plugins/renderers/frame-buffer/plugin.c
@@ -512,8 +512,7 @@ map_to_device (ply_renderer_backend_t *backend)
   if (head->map_address == MAP_FAILED)
     return false;
 
-  ply_terminal_set_active_vt (backend->terminal,
-                              ply_terminal_get_vt_number (backend->terminal));
+  ply_terminal_activate_vt (backend->terminal);
 
   return true;
 }
-- 
1.7.0



More information about the plymouth mailing list