]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
two-step: Change keyboard-indicator positioning to fixed offset below dialog
authorHans de Goede <hdegoede@redhat.com>
Tue, 15 Oct 2019 10:15:10 +0000 (12:15 +0200)
committerHans de Goede <hdegoede@redhat.com>
Thu, 17 Oct 2019 11:22:14 +0000 (13:22 +0200)
The keyboard-indicators should be located close to the dialog/entry to
make clear that they belong to each other. Using relative positioning
does not work well for this.

Drop the KeyboardIndicator[Vertic|Horizont]alAlignment options (we have
never done a release with these) and put the keyboard indicators at
a fixed offset (half their height) from the bottom of the dialog instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/plugins/splash/two-step/plugin.c

index e666cfb5116876334b173d58f85679d538ee7fbf..950f755e1f08ebfbe2ea76a347c0f71e1180cb1e 100644 (file)
@@ -146,9 +146,6 @@ 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;
@@ -879,6 +876,8 @@ view_show_prompt (view_t     *view,
         ply_boot_splash_plugin_t *plugin;
         unsigned long screen_width, screen_height, entry_width, entry_height;
         unsigned long keyboard_indicator_width, keyboard_indicator_height;
+        bool show_keyboard_indicators = false;
+        long dialog_bottom;
         int x, y;
 
         assert (view != NULL);
@@ -922,21 +921,7 @@ view_show_prompt (view_t     *view,
 
                 ply_entry_show (view->entry, plugin->loop, view->display, x, y);
 
-                keyboard_indicator_width =
-                        ply_keymap_icon_get_width (view->keymap_icon);
-                keyboard_indicator_height = MAX(
-                        ply_capslock_icon_get_height (view->capslock_icon),
-                        ply_keymap_icon_get_height (view->keymap_icon));
-
-                x = (screen_width - keyboard_indicator_width) * plugin->keyboard_indicator_horizontal_alignment;
-                y = (screen_height - keyboard_indicator_height) * plugin->keyboard_indicator_vertical_alignment +
-                    (keyboard_indicator_height - ply_keymap_icon_get_height (view->keymap_icon)) / 2.0;
-                ply_keymap_icon_show (view->keymap_icon, x, y);
-
-                x += ply_keymap_icon_get_width (view->keymap_icon);
-                y = (screen_height - keyboard_indicator_height) * plugin->keyboard_indicator_vertical_alignment +
-                    (keyboard_indicator_height - ply_capslock_icon_get_height (view->capslock_icon)) / 2.0;
-                ply_capslock_icon_show (view->capslock_icon, plugin->loop, view->display, x, y);
+                show_keyboard_indicators = true;
         }
 
         if (entry_text != NULL)
@@ -945,6 +930,8 @@ view_show_prompt (view_t     *view,
         if (number_of_bullets != -1)
                 ply_entry_set_bullet_count (view->entry, number_of_bullets);
 
+        dialog_bottom = view->dialog_area.y + view->dialog_area.height;
+
         if (prompt != NULL) {
                 ply_label_set_text (view->label, prompt);
 
@@ -954,9 +941,29 @@ view_show_prompt (view_t     *view,
                 ply_label_set_width (view->label, label_width);
 
                 x = (screen_width - label_width) / 2;
-                y = view->dialog_area.y + view->dialog_area.height;
+                y = dialog_bottom;
 
                 ply_label_show (view->label, view->display, x, y);
+
+                dialog_bottom += ply_label_get_height (view->label);
+        }
+
+        if (show_keyboard_indicators) {
+                keyboard_indicator_width =
+                        ply_keymap_icon_get_width (view->keymap_icon);
+                keyboard_indicator_height = MAX(
+                        ply_capslock_icon_get_height (view->capslock_icon),
+                        ply_keymap_icon_get_height (view->keymap_icon));
+
+                x = (screen_width - keyboard_indicator_width) * plugin->dialog_horizontal_alignment;
+                y = dialog_bottom + keyboard_indicator_height / 2 +
+                    (keyboard_indicator_height - ply_keymap_icon_get_height (view->keymap_icon)) / 2.0;
+                ply_keymap_icon_show (view->keymap_icon, x, y);
+
+                x += ply_keymap_icon_get_width (view->keymap_icon);
+                y = dialog_bottom + keyboard_indicator_height / 2 +
+                    (keyboard_indicator_height - ply_capslock_icon_get_height (view->capslock_icon)) / 2.0;
+                ply_capslock_icon_show (view->capslock_icon, plugin->loop, view->display, x, y);
         }
 }
 
@@ -1083,18 +1090,6 @@ 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",