]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
boot-splash: add support for seat objects
authorRay Strode <rstrode@redhat.com>
Fri, 29 Nov 2013 16:28:52 +0000 (11:28 -0500)
committerRay Strode <rstrode@redhat.com>
Tue, 10 Dec 2013 05:15:59 +0000 (00:15 -0500)
ply_boot_splash_t currently gets notified about displays and keyboard
objects to pass along to the splash plugins.

Now that we have a ply_seat_t object that can encapsulate display
and keyboard objects, we should add support to ply_boot_splash_t for
using it.

This commit does that. For now, it does it without changing the plugin
interface (which is still in terms of displays and keyboards).

Note, this commit only adds support for seat objects to
ply_boot_splash_t. It doesn't actually change any of the calling code
to use that support. That will come in a subsequent commit.

src/libply-splash-core/ply-boot-splash.c
src/libply-splash-core/ply-boot-splash.h
src/libply-splash-core/ply-seat.c
src/libply-splash-core/ply-seat.h

index cf0529156dbc5525ce730295460c2f46af27dfc0..867083749fcd5afa2b5bf049a34f4f6f164f992a 100644 (file)
@@ -58,6 +58,7 @@ struct _ply_boot_splash
   ply_keyboard_t *keyboard;
   ply_buffer_t *boot_buffer;
   ply_trigger_t *idle_trigger;
+  ply_list_t *seats;
   ply_list_t *pixel_displays;
   ply_list_t *text_displays;
 
@@ -98,6 +99,7 @@ ply_boot_splash_new (const char     *theme_path,
   splash->boot_buffer = boot_buffer;
   splash->pixel_displays = ply_list_new ();
   splash->text_displays = ply_list_new ();
+  splash->seats = ply_list_new ();
 
   return splash;
 }
@@ -117,6 +119,9 @@ ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
 void
 ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash)
 {
+  if (splash->keyboard == NULL)
+    return;
+
   if (splash->plugin_interface->set_keyboard == NULL)
     return;
 
@@ -171,6 +176,165 @@ ply_boot_splash_remove_text_display (ply_boot_splash_t   *splash,
   splash->plugin_interface->remove_text_display (splash->plugin, display);
 }
 
+static void
+detach_from_seat (ply_boot_splash_t *splash,
+                  ply_seat_t        *seat)
+{
+  ply_keyboard_t *keyboard;
+  ply_list_t *displays;
+  ply_list_node_t *node, *next_node;
+
+  ply_trace ("removing keyboard");
+  if (splash->plugin_interface->unset_keyboard != NULL)
+    {
+      keyboard = ply_seat_get_keyboard (seat);
+      splash->plugin_interface->unset_keyboard (splash->plugin, keyboard);
+    }
+
+  ply_trace ("removing pixel displays");
+  displays = ply_seat_get_pixel_displays (seat);
+
+  node = ply_list_get_first_node (displays);
+  while (node != NULL)
+    {
+      ply_pixel_display_t *display;
+      ply_list_node_t *next_node;
+      unsigned long width, height;
+
+      display = ply_list_node_get_data (node);
+      next_node = ply_list_get_next_node (displays, node);
+
+      width = ply_pixel_display_get_width (display);
+      height = ply_pixel_display_get_height (display);
+
+      ply_trace ("Removing %lux%lu pixel display", width, height);
+
+      if (splash->plugin_interface->remove_pixel_display != NULL)
+        splash->plugin_interface->remove_pixel_display (splash->plugin, display);
+
+      node = next_node;
+    }
+
+  ply_trace ("removing text displays");
+  displays = ply_seat_get_text_displays (seat);
+
+  node = ply_list_get_first_node (displays);
+  while (node != NULL)
+    {
+      ply_text_display_t *display;
+      int number_of_columns, number_of_rows;
+
+      display = ply_list_node_get_data (node);
+      next_node = ply_list_get_next_node (displays, node);
+
+      number_of_columns = ply_text_display_get_number_of_columns (display);
+      number_of_rows = ply_text_display_get_number_of_rows (display);
+
+      ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
+
+      if (splash->plugin_interface->remove_text_display != NULL)
+        splash->plugin_interface->remove_text_display (splash->plugin, display);
+
+      node = next_node;
+    }
+}
+
+static void
+attach_to_seat (ply_boot_splash_t *splash,
+                ply_seat_t        *seat)
+{
+  ply_keyboard_t *keyboard;
+  ply_list_t *displays;
+  ply_list_node_t *node, *next_node;
+
+  if (splash->plugin_interface->set_keyboard != NULL)
+    {
+      keyboard = ply_seat_get_keyboard (seat);
+      splash->plugin_interface->set_keyboard (splash->plugin, keyboard);
+    }
+
+  if (splash->plugin_interface->add_pixel_display != NULL)
+    {
+      displays = ply_seat_get_pixel_displays (seat);
+
+      ply_trace ("adding pixel displays");
+      node = ply_list_get_first_node (displays);
+      while (node != NULL)
+        {
+          ply_pixel_display_t *display;
+          ply_list_node_t *next_node;
+          unsigned long width, height;
+
+          display = ply_list_node_get_data (node);
+          next_node = ply_list_get_next_node (displays, node);
+
+          width = ply_pixel_display_get_width (display);
+          height = ply_pixel_display_get_height (display);
+
+          ply_trace ("Adding %lux%lu pixel display", width, height);
+
+          splash->plugin_interface->add_pixel_display (splash->plugin, display);
+
+          node = next_node;
+        }
+    }
+
+  if (splash->plugin_interface->add_text_display != NULL)
+    {
+      displays = ply_seat_get_text_displays (seat);
+
+      ply_trace ("adding text displays");
+      node = ply_list_get_first_node (displays);
+      while (node != NULL)
+        {
+          ply_text_display_t *display;
+          int number_of_columns, number_of_rows;
+
+          display = ply_list_node_get_data (node);
+          next_node = ply_list_get_next_node (displays, node);
+
+          number_of_columns = ply_text_display_get_number_of_columns (display);
+          number_of_rows = ply_text_display_get_number_of_rows (display);
+
+          ply_trace ("Adding %dx%d text display", number_of_columns, number_of_rows);
+
+          splash->plugin_interface->add_text_display (splash->plugin, display);
+
+          node = next_node;
+        }
+    }
+}
+
+void
+ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash,
+                                ply_seat_t        *seat)
+{
+  ply_list_node_t *node;
+
+  node = ply_list_find_node (splash->seats, seat);
+
+  if (node != NULL)
+    return;
+
+  ply_list_append_data (splash->seats, seat);
+  attach_to_seat (splash, seat);
+}
+
+void
+ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash,
+                                  ply_seat_t        *seat)
+{
+  ply_list_node_t *node;
+
+  node = ply_list_find_node (splash->seats, seat);
+
+  if (node == NULL)
+    return;
+
+  ply_list_remove_data (splash->seats, seat);
+  detach_from_seat (splash, seat);
+}
+
 bool
 ply_boot_splash_load (ply_boot_splash_t *splash)
 {
@@ -359,6 +523,30 @@ remove_displays (ply_boot_splash_t *splash)
     }
 }
 
+static void
+detach_from_seats (ply_boot_splash_t *splash)
+{
+  ply_list_node_t *node;
+
+  ply_trace ("detaching from seats");
+
+  node = ply_list_get_first_node (splash->seats);
+  while (node != NULL)
+    {
+      ply_seat_t *seat;
+      ply_list_node_t *next_node;
+
+      seat = ply_list_node_get_data (node);
+      next_node = ply_list_get_next_node (splash->seats, node);
+
+      detach_from_seat (splash, seat);
+
+      ply_list_remove_node (splash->seats, node);
+
+      node = next_node;
+    }
+}
+
 void
 ply_boot_splash_free (ply_boot_splash_t *splash)
 {
@@ -384,6 +572,9 @@ ply_boot_splash_free (ply_boot_splash_t *splash)
   ply_list_free (splash->pixel_displays);
   ply_list_free (splash->text_displays);
 
+  detach_from_seats (splash);
+  ply_list_free (splash->seats);
+
   if (splash->module_handle != NULL)
     ply_boot_splash_unload (splash);
 
index a79e9396eed9f00c7de536b3fb1648c7abecb190..3f66b70d4da3b6142f7161699c50c1ee1efa2db5 100644 (file)
 #include "ply-pixel-display.h"
 #include "ply-text-display.h"
 #include "ply-progress.h"
+#include "ply-seat.h"
 
 #include "ply-boot-splash-plugin.h"
 
 typedef struct _ply_boot_splash ply_boot_splash_t;
+typedef struct _ply_seat ply_seat_t;
 
 typedef void (* ply_boot_splash_on_idle_handler_t) (void *user_data);
 
@@ -48,6 +50,10 @@ ply_boot_splash_t *ply_boot_splash_new (const char   *  theme_path,
 bool ply_boot_splash_load (ply_boot_splash_t *splash);
 bool ply_boot_splash_load_built_in (ply_boot_splash_t *splash);
 void ply_boot_splash_unload (ply_boot_splash_t *splash);
+void ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash,
+                                     ply_seat_t        *seat);
+void ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash,
+                                       ply_seat_t        *seat);
 void ply_boot_splash_set_keyboard (ply_boot_splash_t *splash,
                                    ply_keyboard_t    *keyboard);
 void ply_boot_splash_unset_keyboard (ply_boot_splash_t *splash);
index 82bbb894c43734085eeb4931ede43418c00d0ca6..d1493a71472f32555075519abb20ab3b7f869509 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "ply-boot-splash.h"
 #include "ply-event-loop.h"
 #include "ply-keyboard.h"
 #include "ply-pixel-display.h"
@@ -41,6 +42,7 @@ struct _ply_seat
 {
   ply_event_loop_t *loop;
 
+  ply_boot_splash_t *splash;
   ply_terminal_t *terminal;
   ply_renderer_t *renderer;
   ply_keyboard_t *keyboard;
@@ -263,6 +265,22 @@ ply_seat_close (ply_seat_t *seat)
   seat->renderer = NULL;
 }
 
+void
+ply_seat_set_splash (ply_seat_t        *seat,
+                     ply_boot_splash_t *splash)
+{
+  if (seat->splash == splash)
+    return;
+
+  if (seat->splash != NULL)
+    ply_boot_splash_detach_from_seat (splash, seat);
+
+  if (splash != NULL)
+    ply_boot_splash_attach_to_seat (splash, seat);
+
+  seat->splash = splash;
+}
+
 static void
 free_pixel_displays (ply_seat_t *seat)
 {
index 73927789058859b5c87649cc9ce4245b8281803b..d5d339781cfadfd58a87aede2b525542f5699f9c 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdint.h>
 #include <unistd.h>
 
+#include "ply-boot-splash.h"
 #include "ply-buffer.h"
 #include "ply-event-loop.h"
 #include "ply-keyboard.h"
@@ -35,6 +36,7 @@
 #include "ply-terminal.h"
 #include "ply-text-display.h"
 
+typedef struct _ply_boot_splash ply_boot_splash_t;
 typedef struct _ply_seat ply_seat_t;
 
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
@@ -51,6 +53,9 @@ void ply_seat_deactivate_renderer (ply_seat_t *seat);
 void ply_seat_activate_renderer (ply_seat_t *seat);
 void ply_seat_refresh_displays (ply_seat_t *seat);
 void ply_seat_close (ply_seat_t *seat);
+void ply_seat_set_splash (ply_seat_t        *seat,
+                          ply_boot_splash_t *splash);
+
 ply_list_t *ply_seat_get_pixel_displays (ply_seat_t *seat);
 ply_list_t *ply_seat_get_text_displays (ply_seat_t *seat);
 ply_keyboard_t *ply_seat_get_keyboard (ply_seat_t *seat);