summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2008-05-18 23:34:25 -0400
committerRay Strode <rstrode@redhat.com>2008-05-19 00:05:46 -0400
commitfa8d0c2adb324081e9b8696d7833f04c32c575df (patch)
treedcd855fb2f27cea9ca1afd11174824544ea59add /src
parentea56f6e68cfc42ca165d1964e4410739b519879b (diff)
Intercept escape key before passing keyboard input to splash plugin
We want to pass escape to the layer that created the boot splash, so that it can tear down the curren splash plugin and put up the details view
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/ply-boot-splash.c45
-rw-r--r--src/ply-boot-splash.h7
3 files changed, 48 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 0acfc6b..f6c0285 100644
--- a/src/main.c
+++ b/src/main.c
@@ -150,7 +150,7 @@ start_boot_splash (state_t *state,
ply_trace ("Loading boot splash plugin '%s'",
module_path);
- splash = ply_boot_splash_new (module_path);
+ splash = ply_boot_splash_new (module_path, NULL, NULL);
ply_trace ("attaching plugin to event loop");
ply_boot_splash_attach_to_event_loop (splash, state->loop);
diff --git a/src/ply-boot-splash.c b/src/ply-boot-splash.c
index e17f204..51e7888 100644
--- a/src/ply-boot-splash.c
+++ b/src/ply-boot-splash.c
@@ -30,6 +30,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
+#include <wchar.h>
#include "ply-boot-splash-plugin.h"
#include "ply-event-loop.h"
@@ -37,6 +38,8 @@
#include "ply-logger.h"
#include "ply-utils.h"
+#define KEY_ESCAPE '\033'
+
struct _ply_boot_splash
{
ply_event_loop_t *loop;
@@ -45,6 +48,9 @@ struct _ply_boot_splash
ply_boot_splash_plugin_t *plugin;
ply_window_t *window;
+ ply_boot_splash_escape_handler_t escape_handler;
+ void *escape_handler_user_data;
+
char *module_name;
char *status;
@@ -55,7 +61,9 @@ typedef const ply_boot_splash_plugin_interface_t *
(* get_plugin_interface_function_t) (void);
ply_boot_splash_t *
-ply_boot_splash_new (const char *module_name)
+ply_boot_splash_new (const char *module_name,
+ ply_boot_splash_escape_handler_t escape_handler,
+ void *user_data)
{
ply_boot_splash_t *splash;
@@ -67,6 +75,9 @@ ply_boot_splash_new (const char *module_name)
splash->module_handle = NULL;
splash->is_shown = false;
+ splash->escape_handler = escape_handler;
+ splash->escape_handler_user_data = user_data;
+
return splash;
}
@@ -143,12 +154,36 @@ ply_boot_splash_unload_plugin (ply_boot_splash_t *splash)
splash->module_handle = NULL;
}
+static bool
+ply_boot_splash_process_keyboard_input (ply_boot_splash_t *splash,
+ const char *keyboard_input)
+{
+ wchar_t key;
+
+ if (mbrtowc (&key, keyboard_input, 1, NULL) > 0)
+ {
+ if (key == KEY_ESCAPE)
+ {
+ if (splash->escape_handler != NULL)
+ splash->escape_handler (splash->escape_handler_user_data);
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void
on_keyboard_input (ply_boot_splash_t *splash,
- const char *key)
+ const char *keyboard_input)
{
+
+ if (ply_boot_splash_process_keyboard_input (splash, keyboard_input))
+ return;
+
if (splash->plugin_interface->on_keyboard_input != NULL)
- splash->plugin_interface->on_keyboard_input (splash->plugin, key);
+ splash->plugin_interface->on_keyboard_input (splash->plugin, keyboard_input);
}
static bool
@@ -158,6 +193,8 @@ ply_boot_splash_create_window (ply_boot_splash_t *splash)
(ply_window_keyboard_input_handler_t)
on_keyboard_input, splash);
+ ply_window_attach_to_event_loop (splash->window, splash->loop);
+
if (!ply_window_open (splash->window))
{
ply_save_errno ();
@@ -313,7 +350,7 @@ main (int argc,
else
module_name = "../splash-plugins/fedora-fade-in/.libs/fedora-fade-in.so";
- splash = ply_boot_splash_new (module_name);
+ splash = ply_boot_splash_new (module_name, NULL, NULL);
ply_boot_splash_attach_to_event_loop (splash, loop);
if (!ply_boot_splash_show (splash))
diff --git a/src/ply-boot-splash.h b/src/ply-boot-splash.h
index 79b09b0..c89636d 100644
--- a/src/ply-boot-splash.h
+++ b/src/ply-boot-splash.h
@@ -30,8 +30,13 @@
typedef struct _ply_boot_splash ply_boot_splash_t;
+typedef void (* ply_boot_splash_escape_handler_t) (void *user_data);
+
+
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
-ply_boot_splash_t *ply_boot_splash_new (const char *module_name);
+ply_boot_splash_t *ply_boot_splash_new (const char *module_name,
+ ply_boot_splash_escape_handler_t escape_handler,
+ void *user_data);
void ply_boot_splash_free (ply_boot_splash_t *splash);
bool ply_boot_splash_show (ply_boot_splash_t *splash);
void ply_boot_splash_update_status (ply_boot_splash_t *splash,