[PATCH 11/21] [terminal] move terminal opening into renderers/plugins

Scott James Remnant scott at ubuntu.com
Wed Mar 17 21:45:01 PDT 2010


Move the responsibility to actually open the terminal to the renderers
and text/details plugin, this allows the X11 renderer to not actually
open the terminal - and thus not crash the X server.
---
 src/main.c                                  |   19 +------------------
 src/plugins/renderers/drm/plugin.c          |    6 ++++++
 src/plugins/renderers/frame-buffer/plugin.c |    6 ++++++
 src/plugins/splash/details/plugin.c         |    4 ++++
 src/plugins/splash/text/plugin.c            |    4 ++++
 5 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/main.c b/src/main.c
index 35c287f..7c67c76 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1004,22 +1004,12 @@ static void
 add_display_and_keyboard_for_terminal (state_t    *state,
                                        const char *tty_name)
 {
-  ply_terminal_t *terminal;
   ply_text_display_t *display;
   ply_keyboard_t *keyboard;
 
   ply_trace ("adding display and keyboard for %s", tty_name);
 
-  terminal = ply_terminal_new (tty_name);
-
-  if (!ply_terminal_open (terminal))
-    {
-      ply_trace ("could not open terminal '%s': %m", tty_name);
-      ply_terminal_free (terminal);
-      return;
-    }
-
-  state->terminal = terminal;
+  state->terminal = ply_terminal_new (tty_name);
 
   ply_terminal_activate_vt (state->terminal);
 
@@ -1071,13 +1061,6 @@ add_default_displays_and_keyboard (state_t *state)
 
   terminal = ply_terminal_new (state->default_tty);
 
-  if (!ply_terminal_open (terminal))
-    {
-      ply_trace ("could not open terminal '%s': %m", state->default_tty);
-      ply_terminal_free (terminal);
-      return;
-    }
-
   renderer = ply_renderer_new (NULL, terminal);
 
   if (!ply_renderer_open (renderer))
diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c
index 21d727d..f4e3dde 100644
--- a/src/plugins/renderers/drm/plugin.c
+++ b/src/plugins/renderers/drm/plugin.c
@@ -496,6 +496,12 @@ open_device (ply_renderer_backend_t *backend)
   if (!load_driver (backend))
     return false;
 
+  if (!ply_terminal_open (backend->terminal))
+    {
+      ply_trace ("could not open terminal: %m");
+      return false;
+    }
+
   ply_terminal_watch_for_active_vt_change (backend->terminal,
                                            (ply_terminal_active_vt_changed_handler_t)
                                            on_active_vt_changed,
diff --git a/src/plugins/renderers/frame-buffer/plugin.c b/src/plugins/renderers/frame-buffer/plugin.c
index 3152bf7..62ce3da 100644
--- a/src/plugins/renderers/frame-buffer/plugin.c
+++ b/src/plugins/renderers/frame-buffer/plugin.c
@@ -343,6 +343,12 @@ open_device (ply_renderer_backend_t *backend)
       return false;
     }
 
+  if (!ply_terminal_open (backend->terminal))
+    {
+      ply_trace ("could not open terminal: %m");
+      return false;
+    }
+
   ply_terminal_watch_for_active_vt_change (backend->terminal,
                                            (ply_terminal_active_vt_changed_handler_t)
                                            on_active_vt_changed,
diff --git a/src/plugins/splash/details/plugin.c b/src/plugins/splash/details/plugin.c
index 47dbbad..d6980cf 100644
--- a/src/plugins/splash/details/plugin.c
+++ b/src/plugins/splash/details/plugin.c
@@ -197,9 +197,13 @@ add_text_display (ply_boot_splash_plugin_t *plugin,
                   ply_text_display_t       *display)
 {
   view_t *view;
+  ply_terminal_t *terminal;
 
   view = view_new (plugin, display);
 
+  terminal = ply_text_display_get_terminal (view->display);
+  ply_terminal_open (terminal);
+
   ply_list_append_data (plugin->views, view);
 }
 
diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c
index 61dafa9..228e271 100644
--- a/src/plugins/splash/text/plugin.c
+++ b/src/plugins/splash/text/plugin.c
@@ -479,9 +479,13 @@ add_text_display (ply_boot_splash_plugin_t *plugin,
                   ply_text_display_t       *display)
 {
   view_t *view;
+  ply_terminal_t *terminal;
 
   view = view_new (plugin, display);
 
+  terminal = ply_text_display_get_terminal (view->display);
+  ply_terminal_open (terminal);
+
   ply_text_display_set_draw_handler (view->display,
                                      (ply_text_display_draw_handler_t)
                                      on_draw, view);
-- 
1.7.0



More information about the plymouth mailing list