mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-07 18:58:01 +02:00
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
This commit is contained in:
parent
ea56f6e68c
commit
fa8d0c2adb
3 changed files with 48 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue