diff options
| author | Ray Strode <rstrode@redhat.com> | 2008-05-29 00:46:02 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2008-05-29 00:46:02 -0400 |
| commit | cae6ca26f3b31ff88694a3ec72acc194b4b2d6ec (patch) | |
| tree | 5f2eae069fccdb3fd27f85a89283c1ea9b713eac /src | |
| parent | 93ac9f7b1c1d605e313f91cc2eb9324a7b71ba1f (diff) | |
| download | plymouth-cae6ca26f3b31ff88694a3ec72acc194b4b2d6ec.tar.gz plymouth-cae6ca26f3b31ff88694a3ec72acc194b4b2d6ec.tar.xz plymouth-cae6ca26f3b31ff88694a3ec72acc194b4b2d6ec.zip | |
Have window manage frame buffer instead of plugins
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ply-window.c | 22 | ||||
| -rw-r--r-- | src/ply-window.h | 4 | ||||
| -rw-r--r-- | src/splash-plugins/fade-in/plugin.c | 14 | ||||
| -rw-r--r-- | src/splash-plugins/spinfinity/plugin.c | 14 |
4 files changed, 37 insertions, 17 deletions
diff --git a/src/ply-window.c b/src/ply-window.c index a3dc889..d128fa6 100644 --- a/src/ply-window.c +++ b/src/ply-window.c @@ -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> diff --git a/src/ply-window.h b/src/ply-window.h index f5dbcb5..25c82ea 100644 --- a/src/ply-window.h +++ b/src/ply-window.h @@ -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 diff --git a/src/splash-plugins/fade-in/plugin.c b/src/splash-plugins/fade-in/plugin.c index 1056fd4..9d7789f 100644 --- a/src/splash-plugins/fade-in/plugin.c +++ b/src/splash-plugins/fade-in/plugin.c @@ -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) diff --git a/src/splash-plugins/spinfinity/plugin.c b/src/splash-plugins/spinfinity/plugin.c index 84dfa50..1022292 100644 --- a/src/splash-plugins/spinfinity/plugin.c +++ b/src/splash-plugins/spinfinity/plugin.c @@ -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) |
