mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-06 02:18:08 +02:00
two-step: Add a capslock indicator
Add support for showing a capslock indicator when capslock is pressed while entering a password. This is automatically enabled if a capslock.png file is present in the theme's image dir. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
ea1ef31926
commit
dcc5a947d1
1 changed files with 38 additions and 0 deletions
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "ply-boot-splash-plugin.h"
|
||||
#include "ply-buffer.h"
|
||||
#include "ply-capslock-icon.h"
|
||||
#include "ply-entry.h"
|
||||
#include "ply-event-loop.h"
|
||||
#include "ply-label.h"
|
||||
|
|
@ -97,6 +98,7 @@ typedef struct
|
|||
ply_boot_splash_plugin_t *plugin;
|
||||
ply_pixel_display_t *display;
|
||||
ply_entry_t *entry;
|
||||
ply_capslock_icon_t *capslock_icon;
|
||||
ply_animation_t *end_animation;
|
||||
ply_progress_animation_t *progress_animation;
|
||||
ply_progress_bar_t *progress_bar;
|
||||
|
|
@ -141,6 +143,9 @@ struct _ply_boot_splash_plugin
|
|||
double dialog_horizontal_alignment;
|
||||
double dialog_vertical_alignment;
|
||||
|
||||
double keyboard_indicator_horizontal_alignment;
|
||||
double keyboard_indicator_vertical_alignment;
|
||||
|
||||
double title_horizontal_alignment;
|
||||
double title_vertical_alignment;
|
||||
char *title_font;
|
||||
|
|
@ -198,6 +203,7 @@ view_new (ply_boot_splash_plugin_t *plugin,
|
|||
view->display = display;
|
||||
|
||||
view->entry = ply_entry_new (plugin->animation_dir);
|
||||
view->capslock_icon = ply_capslock_icon_new (plugin->animation_dir);
|
||||
view->progress_animation = ply_progress_animation_new (plugin->animation_dir,
|
||||
"progress-");
|
||||
view->progress_bar = ply_progress_bar_new ();
|
||||
|
|
@ -230,6 +236,7 @@ static void
|
|||
view_free (view_t *view)
|
||||
{
|
||||
ply_entry_free (view->entry);
|
||||
ply_capslock_icon_free (view->capslock_icon);
|
||||
ply_animation_free (view->end_animation);
|
||||
ply_progress_animation_free (view->progress_animation);
|
||||
ply_progress_bar_free (view->progress_bar);
|
||||
|
|
@ -592,6 +599,8 @@ view_load (view_t *view)
|
|||
if (!ply_entry_load (view->entry))
|
||||
return false;
|
||||
|
||||
ply_capslock_icon_load (view->capslock_icon);
|
||||
|
||||
view_load_end_animation (view);
|
||||
|
||||
if (view->progress_animation != NULL) {
|
||||
|
|
@ -857,6 +866,7 @@ view_show_prompt (view_t *view,
|
|||
{
|
||||
ply_boot_splash_plugin_t *plugin;
|
||||
unsigned long screen_width, screen_height, entry_width, entry_height;
|
||||
unsigned long capslock_width, capslock_height;
|
||||
int x, y;
|
||||
|
||||
assert (view != NULL);
|
||||
|
|
@ -899,6 +909,14 @@ view_show_prompt (view_t *view,
|
|||
(view->dialog_area.height - entry_height) / 2.0;
|
||||
|
||||
ply_entry_show (view->entry, plugin->loop, view->display, x, y);
|
||||
|
||||
capslock_width = ply_capslock_icon_get_width (view->capslock_icon);
|
||||
capslock_height = ply_capslock_icon_get_height (view->capslock_icon);
|
||||
|
||||
x = (screen_width - capslock_width) * plugin->keyboard_indicator_horizontal_alignment;
|
||||
y = (screen_height - capslock_height) * plugin->keyboard_indicator_vertical_alignment;
|
||||
|
||||
ply_capslock_icon_show (view->capslock_icon, plugin->loop, view->display, x, y);
|
||||
}
|
||||
|
||||
if (prompt != NULL) {
|
||||
|
|
@ -922,6 +940,7 @@ view_hide_prompt (view_t *view)
|
|||
assert (view != NULL);
|
||||
|
||||
ply_entry_hide (view->entry);
|
||||
ply_capslock_icon_hide (view->capslock_icon);
|
||||
ply_label_hide (view->label);
|
||||
}
|
||||
|
||||
|
|
@ -994,6 +1013,7 @@ create_plugin (ply_key_file_t *key_file)
|
|||
plugin->font = ply_key_file_get_value (key_file, "two-step", "Font");
|
||||
plugin->title_font = ply_key_file_get_value (key_file, "two-step", "TitleFont");
|
||||
|
||||
/* Throbber, progress- and end-animation alignment */
|
||||
plugin->animation_horizontal_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"HorizontalAlignment", 0.5);
|
||||
|
|
@ -1001,6 +1021,7 @@ create_plugin (ply_key_file_t *key_file)
|
|||
ply_key_file_get_double (key_file, "two-step",
|
||||
"VerticalAlignment", 0.5);
|
||||
|
||||
/* Watermark alignment */
|
||||
plugin->watermark_horizontal_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"WatermarkHorizontalAlignment", 1.0);
|
||||
|
|
@ -1008,6 +1029,7 @@ create_plugin (ply_key_file_t *key_file)
|
|||
ply_key_file_get_double (key_file, "two-step",
|
||||
"WatermarkVerticalAlignment", 0.5);
|
||||
|
||||
/* Password (or other) dialog alignment */
|
||||
plugin->dialog_horizontal_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"DialogHorizontalAlignment", 0.5);
|
||||
|
|
@ -1015,6 +1037,19 @@ create_plugin (ply_key_file_t *key_file)
|
|||
ply_key_file_get_double (key_file, "two-step",
|
||||
"DialogVerticalAlignment", 0.5);
|
||||
|
||||
/* Keyboard layout + capslock indicator alignment, this defaults
|
||||
* to halfway between the dialog and the bottom of the screen.
|
||||
*/
|
||||
plugin->keyboard_indicator_horizontal_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"KeyboardIndicatorHorizontalAlignment",
|
||||
plugin->dialog_horizontal_alignment);
|
||||
plugin->keyboard_indicator_vertical_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"KeyboardIndicatorVerticalAlignment",
|
||||
0.5 + 0.5 * plugin->dialog_vertical_alignment);
|
||||
|
||||
/* Title alignment */
|
||||
plugin->title_horizontal_alignment =
|
||||
ply_key_file_get_double (key_file, "two-step",
|
||||
"TitleHorizontalAlignment", 0.5);
|
||||
|
|
@ -1386,6 +1421,9 @@ on_draw (view_t *view,
|
|||
ply_entry_draw_area (view->entry,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
ply_capslock_icon_draw_area (view->capslock_icon,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
ply_label_draw_area (view->label,
|
||||
pixel_buffer,
|
||||
x, y, width, height);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue