]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Have window manage frame buffer instead of plugins
authorRay Strode <rstrode@redhat.com>
Thu, 29 May 2008 04:46:02 +0000 (00:46 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 29 May 2008 04:46:02 +0000 (00:46 -0400)
This is a first step toward making the window provide
an draw handler interface, so we can hide the details
of pause/unpause, resetting raw mode, and graphics mode,
etc from the individual plugins.

src/ply-window.c
src/ply-window.h
src/splash-plugins/fade-in/plugin.c
src/splash-plugins/spinfinity/plugin.c

index a3dc8891d883114a6662ca316d0b48559be507df..d128fa627859f04084d835516e32e8177a01b9f1 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "ply-buffer.h"
 #include "ply-event-loop.h"
+#include "ply-frame-buffer.h"
 #include "ply-logger.h"
 #include "ply-utils.h"
 
@@ -57,6 +58,8 @@ struct _ply_window
   ply_buffer_t     *keyboard_input_buffer;
   ply_buffer_t     *line_buffer;
 
+  ply_frame_buffer_t *frame_buffer;
+
   char *tty_name;
   int   tty_fd;
 
@@ -88,6 +91,7 @@ ply_window_new (const char *tty_name)
   window = calloc (1, sizeof (ply_window_t));
   window->keyboard_input_buffer = ply_buffer_new ();
   window->line_buffer = ply_buffer_new ();
+  window->frame_buffer = ply_frame_buffer_new (NULL);
   window->loop = NULL;
   window->tty_name = strdup (tty_name);
   window->tty_fd = -1;
@@ -272,6 +276,11 @@ ply_window_open (ply_window_t *window)
                                                     (ply_event_handler_t) on_key_event,
                                                     NULL, window);
 
+  /* We try to open the frame buffer, but it may fail. splash plugins can check
+   * to see if it's open and react accordingly
+   */
+  ply_frame_buffer_open (window->frame_buffer);
+
   return true;
 }
 
@@ -280,6 +289,8 @@ ply_window_close (ply_window_t *window)
 {
   ply_window_set_mode (window, PLY_WINDOW_MODE_TEXT);
 
+  ply_frame_buffer_close (window->frame_buffer);
+
   if (window->tty_fd_watch != NULL)
     {
       ply_event_loop_stop_watching_fd (window->loop, window->tty_fd_watch);
@@ -305,6 +316,9 @@ ply_window_set_mode (ply_window_t      *window,
         break;
 
       case PLY_WINDOW_MODE_GRAPHICS:
+        if (!ply_frame_buffer_device_is_open (window->frame_buffer))
+          return false;
+
         if (ioctl (window->tty_fd, KDSETMODE,
                    window->should_force_text_mode? KD_TEXT : KD_GRAPHICS) < 0)
           return false;
@@ -342,6 +356,8 @@ ply_window_free (ply_window_t *window)
   ply_buffer_free (window->keyboard_input_buffer);
   ply_buffer_free (window->line_buffer);
 
+  ply_frame_buffer_free (window->frame_buffer);
+
   free (window);
 }
 
@@ -410,6 +426,12 @@ ply_window_attach_to_event_loop (ply_window_t     *window,
                                  window);
 }
 
+ply_frame_buffer_t *
+ply_window_get_frame_buffer (ply_window_t *window)
+{
+  return window->frame_buffer;
+}
+
 #ifdef PLY_WINDOW_ENABLE_TEST
 
 #include <stdio.h>
index f5dbcb59b0aac72723287d77e285b524c539701d..25c82ea4d5547f0eb3650474907be1ca1ecad4af 100644 (file)
@@ -26,8 +26,9 @@
 #include <stdint.h>
 #include <unistd.h>
 
-#include "ply-event-loop.h"
 #include "ply-buffer.h"
+#include "ply-event-loop.h"
+#include "ply-frame-buffer.h"
 
 typedef struct _ply_window ply_window_t;
 
@@ -71,6 +72,7 @@ bool ply_window_set_mode (ply_window_t      *window,
 
 void ply_window_attach_to_event_loop (ply_window_t     *window,
                                       ply_event_loop_t *loop);
+ply_frame_buffer_t *ply_window_get_frame_buffer (ply_window_t *window);
 
 #endif
 
index 1056fd4044adaf10dadc04781deb39c3f3995863..9d7789f89ba14c225feca2385cf88c1b56afde02 100644 (file)
@@ -100,7 +100,6 @@ create_plugin (void)
   plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
   plugin->start_time = 0.0;
 
-  plugin->frame_buffer = ply_frame_buffer_new (NULL);
   plugin->logo_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fedora-fade-in/fedora-logo.png");
   plugin->star_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fedora-fade-in/star.png");
   plugin->lock_image = ply_image_new (PLYMOUTH_IMAGE_DIR "fedora-fade-in/lock.png");
@@ -192,7 +191,6 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
   ply_image_free (plugin->bullet_image);
   ply_image_free (plugin->entry_image);
   ply_image_free (plugin->lock_image);
-  ply_frame_buffer_free (plugin->frame_buffer);
   free (plugin);
 }
 
@@ -410,7 +408,6 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
   assert (plugin->logo_image != NULL);
-  assert (plugin->frame_buffer != NULL);
 
   ply_window_set_keyboard_input_handler (window,
                                          (ply_window_keyboard_input_handler_t)
@@ -444,15 +441,14 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   if (!ply_image_load (plugin->entry_image))
     return false;
 
-  ply_trace ("opening frame buffer");
-  if (!ply_frame_buffer_open (plugin->frame_buffer))
-    return false;
-
   plugin->window = window;
 
+  ply_trace ("setting graphics mode");
   if (!ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_GRAPHICS))
     return false;
 
+  plugin->frame_buffer = ply_window_get_frame_buffer (plugin->window);
+
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
                                  plugin);
@@ -566,8 +562,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
       detach_from_event_loop (plugin);
     }
 
-  ply_frame_buffer_close (plugin->frame_buffer);
+  plugin->frame_buffer = NULL;
+
   ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
+  plugin->window = NULL;
 }
 static void
 draw_password_entry (ply_boot_splash_plugin_t *plugin)
index 84dfa50fc70c0faf9af657ce616639d495848f0a..1022292fd2ff1621a2c7bbe8b4ee0b7f056dabe2 100644 (file)
@@ -93,7 +93,6 @@ create_plugin (void)
   srand ((int) ply_get_timestamp ());
   plugin = calloc (1, sizeof (ply_boot_splash_plugin_t));
 
-  plugin->frame_buffer = ply_frame_buffer_new (NULL);
   plugin->logo_image = ply_image_new (PLYMOUTH_IMAGE_DIR "spinfinity/fedora-logo.png");
   plugin->lock_image = ply_image_new (PLYMOUTH_IMAGE_DIR "spinfinity/lock.png");
   plugin->bullet_image = ply_image_new (PLYMOUTH_IMAGE_DIR "spinfinity/bullet.png");
@@ -141,7 +140,6 @@ destroy_plugin (ply_boot_splash_plugin_t *plugin)
   ply_image_free (plugin->entry_image);
   ply_image_free (plugin->box_image);
   ply_image_free (plugin->lock_image);
-  ply_frame_buffer_free (plugin->frame_buffer);
   throbber_free (plugin->throbber);
   free (plugin);
 }
@@ -288,7 +286,6 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
 {
   assert (plugin != NULL);
   assert (plugin->logo_image != NULL);
-  assert (plugin->frame_buffer != NULL);
 
   ply_window_set_keyboard_input_handler (window,
                                          (ply_window_keyboard_input_handler_t)
@@ -322,15 +319,14 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
   if (!ply_image_load (plugin->box_image))
     return false;
 
-  ply_trace ("opening frame buffer");
-  if (!ply_frame_buffer_open (plugin->frame_buffer))
-    return false;
-
   plugin->window = window;
 
+  ply_trace ("setting graphics mode");
   if (!ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_GRAPHICS))
     return false;
 
+  plugin->frame_buffer = ply_window_get_frame_buffer (plugin->window);
+
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t)
                                  detach_from_event_loop,
                                  plugin);
@@ -374,8 +370,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
       detach_from_event_loop (plugin);
     }
 
-  ply_frame_buffer_close (plugin->frame_buffer);
+  plugin->frame_buffer = NULL;
+
   ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
+  plugin->window = NULL;
 }
 static void
 draw_password_entry (ply_boot_splash_plugin_t *plugin)