#include "ply-buffer.h"
#include "ply-event-loop.h"
+#include "ply-frame-buffer.h"
#include "ply-logger.h"
#include "ply-utils.h"
ply_buffer_t *keyboard_input_buffer;
ply_buffer_t *line_buffer;
+ ply_frame_buffer_t *frame_buffer;
+
char *tty_name;
int tty_fd;
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;
(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;
}
{
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);
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;
ply_buffer_free (window->keyboard_input_buffer);
ply_buffer_free (window->line_buffer);
+ ply_frame_buffer_free (window->frame_buffer);
+
free (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>
#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;
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
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");
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);
}
{
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)
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);
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)
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");
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);
}
{
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)
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);
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)