summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2015-03-28 01:08:03 -0400
committerRay Strode <rstrode@redhat.com>2015-03-28 01:08:03 -0400
commitfed69e9fff99dcaff1b2c88ad6b986a4a4d3df78 (patch)
treebae9dcd54aefb7578aaa0f554e627ec0776437e1
parentbffb97fe859ddde86be2d99cfc77b595fb416498 (diff)
device-manager: drop seat abstraction in public interfacewip/deseatify
The seat abstraction turns out to be pretty wrong headed. It forces us to make a decision on which output devices to couple the input device to, which doesn't really make sense in the face of multiple video cards. This commit drops the seat object from the device manager api, and changes the users of the api to work on the underlying device objects directly. Under the hood the device manager code still uses ply_seat_t. That will get mopped up in a future commit.
-rw-r--r--src/libply-splash-core/ply-boot-splash.c263
-rw-r--r--src/libply-splash-core/ply-boot-splash.h18
-rw-r--r--src/libply-splash-core/ply-device-manager.c164
-rw-r--r--src/libply-splash-core/ply-device-manager.h41
-rw-r--r--src/main.c151
5 files changed, 458 insertions, 179 deletions
diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c
index 310d4d5a..c7256757 100644
--- a/src/libply-splash-core/ply-boot-splash.c
+++ b/src/libply-splash-core/ply-boot-splash.c
@@ -57,7 +57,9 @@ struct _ply_boot_splash
ply_boot_splash_mode_t mode;
ply_buffer_t *boot_buffer;
ply_trigger_t *idle_trigger;
- ply_list_t *seats;
+ ply_list_t *pixel_displays;
+ ply_list_t *text_displays;
+ ply_list_t *keyboards;
char *theme_path;
char *plugin_dir;
@@ -94,160 +96,183 @@ ply_boot_splash_new (const char *theme_path,
splash->mode = PLY_BOOT_SPLASH_MODE_INVALID;
splash->boot_buffer = boot_buffer;
- splash->seats = ply_list_new ();
+ splash->pixel_displays = ply_list_new ();
+ splash->text_displays = ply_list_new ();
+ splash->keyboards = ply_list_new ();
return splash;
}
static void
-detach_from_seat (ply_boot_splash_t *splash,
- ply_seat_t *seat)
+add_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display)
{
- ply_keyboard_t *keyboard;
- ply_list_t *displays;
- ply_list_node_t *node, *next_node;
+ if (splash->plugin_interface->add_pixel_display != NULL) {
+ unsigned long width, height;
+
+ width = ply_pixel_display_get_width (pixel_display);
+ height = ply_pixel_display_get_height (pixel_display);
+
+ ply_trace ("Adding %lux%lu pixel display", width, height);
+
+ splash->plugin_interface->add_pixel_display (splash->plugin, pixel_display);
- 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);
+void
+ply_boot_splash_add_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display)
+{
+ ply_list_node_t *node;
- 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;
+ node = ply_list_find_node (splash->pixel_displays, pixel_display);
- display = ply_list_node_get_data (node);
- next_node = ply_list_get_next_node (displays, node);
+ if (node != NULL)
+ return;
- width = ply_pixel_display_get_width (display);
- height = ply_pixel_display_get_height (display);
+ ply_list_append_data (splash->pixel_displays, pixel_display);
- ply_trace ("Removing %lux%lu pixel display", width, height);
+ add_pixel_display (splash, pixel_display);
+}
- if (splash->plugin_interface->remove_pixel_display != NULL)
- splash->plugin_interface->remove_pixel_display (splash->plugin, display);
+static void
+remove_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display)
+{
+ if (splash->plugin_interface->remove_pixel_display != NULL) {
+ unsigned long width, height;
- node = next_node;
- }
+ width = ply_pixel_display_get_width (pixel_display);
+ height = ply_pixel_display_get_height (pixel_display);
+
+ ply_trace ("Removing %lux%lu pixel display", width, height);
- ply_trace ("removing text displays");
- displays = ply_seat_get_text_displays (seat);
+ splash->plugin_interface->remove_pixel_display (splash->plugin, pixel_display);
- 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);
+void
+ply_boot_splash_remove_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display)
+{
+ ply_list_node_t *node;
- number_of_columns = ply_text_display_get_number_of_columns (display);
- number_of_rows = ply_text_display_get_number_of_rows (display);
+ node = ply_list_find_node (splash->pixel_displays, pixel_display);
- ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
+ if (node == NULL)
+ return;
- if (splash->plugin_interface->remove_text_display != NULL)
- splash->plugin_interface->remove_text_display (splash->plugin, display);
+ remove_pixel_display (splash, pixel_display);
- node = next_node;
- }
+ ply_list_remove_node (splash->pixel_displays, node);
}
static void
-attach_to_seat (ply_boot_splash_t *splash,
- ply_seat_t *seat)
+add_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display)
{
- 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_text_display != NULL) {
+ int number_of_columns, number_of_rows;
+
+ number_of_columns = ply_text_display_get_number_of_columns (text_display);
+ number_of_rows = ply_text_display_get_number_of_rows (text_display);
+
+ ply_trace ("Adding %dx%d text display", number_of_columns, number_of_rows);
+
+ splash->plugin_interface->add_text_display (splash->plugin, text_display);
}
+}
- if (splash->plugin_interface->add_pixel_display != NULL) {
- displays = ply_seat_get_pixel_displays (seat);
+void
+ply_boot_splash_add_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display)
+{
+ ply_list_node_t *node;
+
+ node = ply_list_find_node (splash->text_displays, text_display);
- 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;
+ if (node != NULL)
+ return;
- display = ply_list_node_get_data (node);
- next_node = ply_list_get_next_node (displays, node);
+ ply_list_append_data (splash->text_displays, text_display);
+ add_text_display (splash, text_display);
+}
- width = ply_pixel_display_get_width (display);
- height = ply_pixel_display_get_height (display);
+static void
+remove_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display)
+{
+ if (splash->plugin_interface->remove_text_display != NULL) {
+ int number_of_columns, number_of_rows;
- ply_trace ("Adding %lux%lu pixel display", width, height);
+ number_of_columns = ply_text_display_get_number_of_columns (text_display);
+ number_of_rows = ply_text_display_get_number_of_rows (text_display);
- splash->plugin_interface->add_pixel_display (splash->plugin, display);
+ ply_trace ("Removing %dx%d text display", number_of_columns, number_of_rows);
- node = next_node;
- }
+ splash->plugin_interface->remove_text_display (splash->plugin, text_display);
}
- 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);
+void
+ply_boot_splash_remove_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display)
+{
+ ply_list_node_t *node;
- number_of_columns = ply_text_display_get_number_of_columns (display);
- number_of_rows = ply_text_display_get_number_of_rows (display);
+ node = ply_list_find_node (splash->text_displays, text_display);
- ply_trace ("Adding %dx%d text display", number_of_columns, number_of_rows);
+ if (node == NULL)
+ return;
- splash->plugin_interface->add_text_display (splash->plugin, display);
+ remove_text_display (splash, text_display);
- node = next_node;
- }
- }
+ ply_list_remove_node (splash->text_displays, node);
}
void
-ply_boot_splash_attach_to_seat (ply_boot_splash_t *splash,
- ply_seat_t *seat)
+ply_boot_splash_add_keyboard (ply_boot_splash_t *splash,
+ ply_keyboard_t *keyboard)
{
ply_list_node_t *node;
- node = ply_list_find_node (splash->seats, seat);
+ node = ply_list_find_node (splash->keyboards, keyboard);
if (node != NULL)
return;
- ply_list_append_data (splash->seats, seat);
- attach_to_seat (splash, seat);
+ ply_list_append_data (splash->keyboards, keyboard);
+
+ if (splash->plugin_interface->set_keyboard != NULL)
+ splash->plugin_interface->set_keyboard (splash->plugin, keyboard);
+}
+
+static void
+remove_keyboard (ply_boot_splash_t *splash,
+ ply_keyboard_t *keyboard)
+{
+ if (splash->plugin_interface->unset_keyboard != NULL)
+ splash->plugin_interface->unset_keyboard (splash->plugin, keyboard);
}
void
-ply_boot_splash_detach_from_seat (ply_boot_splash_t *splash,
- ply_seat_t *seat)
+ply_boot_splash_remove_keyboard (ply_boot_splash_t *splash,
+ ply_keyboard_t *keyboard)
{
ply_list_node_t *node;
- node = ply_list_find_node (splash->seats, seat);
+ node = ply_list_find_node (splash->keyboards, keyboard);
if (node == NULL)
return;
- ply_list_remove_data (splash->seats, seat);
- detach_from_seat (splash, seat);
+ remove_keyboard (splash, keyboard);
+
+ ply_list_remove_node (splash->keyboards, node);
}
bool
@@ -378,23 +403,53 @@ ply_boot_splash_unload (ply_boot_splash_t *splash)
}
static void
-detach_from_seats (ply_boot_splash_t *splash)
+remove_devices (ply_boot_splash_t *splash)
{
ply_list_node_t *node;
- ply_trace ("detaching from seats");
+ ply_trace ("detaching from devices");
+
+ node = ply_list_get_first_node (splash->keyboards);
+ while (node != NULL) {
+ ply_keyboard_t *keyboard;
+ ply_list_node_t *next_node;
+
+ keyboard = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (splash->keyboards, node);
+
+ remove_keyboard (splash, keyboard);
+
+ ply_list_remove_node (splash->keyboards, node);
+
+ node = next_node;
+ }
+
+ node = ply_list_get_first_node (splash->text_displays);
+ while (node != NULL) {
+ ply_text_display_t *text_display;
+ ply_list_node_t *next_node;
+
+ text_display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (splash->text_displays, node);
+
+ remove_text_display (splash, text_display);
+
+ ply_list_remove_node (splash->text_displays, node);
+
+ node = next_node;
+ }
- node = ply_list_get_first_node (splash->seats);
+ node = ply_list_get_first_node (splash->pixel_displays);
while (node != NULL) {
- ply_seat_t *seat;
+ ply_pixel_display_t *pixel_display;
ply_list_node_t *next_node;
- seat = ply_list_node_get_data (node);
- next_node = ply_list_get_next_node (splash->seats, node);
+ pixel_display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (splash->pixel_displays, node);
- detach_from_seat (splash, seat);
+ remove_pixel_display (splash, pixel_display);
- ply_list_remove_node (splash->seats, node);
+ ply_list_remove_node (splash->pixel_displays, node);
node = next_node;
}
@@ -419,8 +474,10 @@ ply_boot_splash_free (ply_boot_splash_t *splash)
splash);
}
- detach_from_seats (splash);
- ply_list_free (splash->seats);
+ remove_devices (splash);
+ ply_list_free (splash->keyboards);
+ ply_list_free (splash->text_displays);
+ ply_list_free (splash->pixel_displays);
if (splash->module_handle != NULL)
ply_boot_splash_unload (splash);
diff --git a/src/libply-splash-core/ply-boot-splash.h b/src/libply-splash-core/ply-boot-splash.h
index 0ad6f22b..d7b9141e 100644
--- a/src/libply-splash-core/ply-boot-splash.h
+++ b/src/libply-splash-core/ply-boot-splash.h
@@ -33,12 +33,10 @@
#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);
@@ -50,10 +48,18 @@ 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_add_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display);
+void ply_boot_splash_remove_pixel_display (ply_boot_splash_t *splash,
+ ply_pixel_display_t *pixel_display);
+void ply_boot_splash_add_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display);
+void ply_boot_splash_remove_text_display (ply_boot_splash_t *splash,
+ ply_text_display_t *text_display);
+void ply_boot_splash_add_keyboard (ply_boot_splash_t *splash,
+ ply_keyboard_t *keyboard);
+void ply_boot_splash_remove_keyboard (ply_boot_splash_t *splash,
+ ply_keyboard_t *keyboard);
void ply_boot_splash_free (ply_boot_splash_t *splash);
bool ply_boot_splash_show (ply_boot_splash_t *splash,
ply_boot_splash_mode_t mode);
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
index 67eba323..710a2a1f 100644
--- a/src/libply-splash-core/ply-device-manager.c
+++ b/src/libply-splash-core/ply-device-manager.c
@@ -36,6 +36,7 @@
#include "ply-event-loop.h"
#include "ply-hashtable.h"
#include "ply-list.h"
+#include "ply-seat.h"
#include "ply-utils.h"
#define SUBSYSTEM_DRM "drm"
@@ -53,15 +54,23 @@ struct _ply_device_manager
ply_terminal_t *local_console_terminal;
ply_seat_t *local_console_seat;
ply_list_t *seats;
+ ply_list_t *pixel_displays;
+ ply_list_t *text_displays;
+ ply_list_t *keyboards;
struct udev *udev_context;
struct udev_queue *udev_queue;
int udev_queue_fd;
ply_fd_watch_t *udev_queue_fd_watch;
struct udev_monitor *udev_monitor;
- ply_seat_added_handler_t seat_added_handler;
- ply_seat_removed_handler_t seat_removed_handler;
- void *seat_event_handler_data;
+ void *device_event_handler_data;
+
+ ply_pixel_display_added_handler_t pixel_display_added_handler;
+ ply_pixel_display_removed_handler_t pixel_display_removed_handler;
+ ply_text_display_added_handler_t text_display_added_handler;
+ ply_text_display_removed_handler_t text_display_removed_handler;
+ ply_keyboard_added_handler_t keyboard_added_handler;
+ ply_keyboard_removed_handler_t keyboard_removed_handler;
};
static void
@@ -240,6 +249,54 @@ create_seat_for_udev_device (ply_device_manager_t *manager,
}
static void
+remove_devices (ply_device_manager_t *manager,
+ ply_seat_t *seat)
+{
+ ply_list_t *displays;
+ ply_list_node_t *node;
+ ply_keyboard_t *keyboard;
+
+ keyboard = ply_seat_get_keyboard (seat);
+
+ if (keyboard != NULL && manager->keyboard_added_handler != NULL)
+ manager->keyboard_added_handler (manager->device_event_handler_data, keyboard);
+
+ displays = ply_seat_get_text_displays (seat);
+ node = ply_list_get_first_node (displays);
+ while (node != NULL) {
+ ply_text_display_t *display;
+ ply_list_node_t *next_node;
+
+ display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (displays, node);
+
+ ply_list_remove_data (manager->text_displays, display);
+
+ if (manager->text_display_removed_handler != NULL)
+ manager->text_display_removed_handler (manager->device_event_handler_data, display);
+
+ node = next_node;
+ }
+
+ 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;
+
+ display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (displays, node);
+
+ ply_list_remove_data (manager->pixel_displays, display);
+
+ if (manager->pixel_display_removed_handler != NULL)
+ manager->pixel_display_removed_handler (manager->device_event_handler_data, display);
+
+ node = next_node;
+ }
+}
+
+static void
free_seat_from_device_path (ply_device_manager_t *manager,
const char *device_path)
{
@@ -263,8 +320,7 @@ free_seat_from_device_path (ply_device_manager_t *manager,
if (strcmp (device_path, renderer_device_path) == 0) {
ply_trace ("removing seat associated with %s", device_path);
- if (manager->seat_removed_handler != NULL)
- manager->seat_removed_handler (manager->seat_event_handler_data, seat);
+ remove_devices (manager, seat);
ply_seat_free (seat);
ply_list_remove_node (manager->seats, node);
@@ -428,8 +484,7 @@ free_seats (ply_device_manager_t *manager)
seat = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (manager->seats, node);
- if (manager->seat_removed_handler != NULL)
- manager->seat_removed_handler (manager->seat_event_handler_data, seat);
+ remove_devices (manager, seat);
ply_seat_free (seat);
ply_list_remove_node (manager->seats, node);
@@ -505,6 +560,8 @@ ply_device_manager_new (const char *default_tty,
(void *) ply_terminal_get_name (manager->local_console_terminal),
manager->local_console_terminal);
manager->seats = ply_list_new ();
+ manager->pixel_displays = ply_list_new ();
+ manager->text_displays = ply_list_new ();
manager->flags = flags;
if (!(flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV))
@@ -529,6 +586,9 @@ ply_device_manager_free (ply_device_manager_t *manager)
manager);
free_seats (manager);
ply_list_free (manager->seats);
+ ply_list_free (manager->pixel_displays);
+ ply_list_free (manager->text_displays);
+ ply_list_free (manager->keyboards);
free_terminals (manager);
ply_hashtable_free (manager->terminals);
@@ -615,6 +675,53 @@ add_consoles_from_file (ply_device_manager_t *manager,
}
static void
+add_devices (ply_device_manager_t *manager,
+ ply_seat_t *seat)
+{
+ ply_list_t *displays;
+ ply_list_node_t *node;
+ ply_keyboard_t *keyboard;
+
+ 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;
+
+ display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (displays, node);
+
+ ply_list_append_data (manager->pixel_displays, display);
+ if (manager->pixel_display_added_handler != NULL)
+ manager->pixel_display_added_handler (manager->device_event_handler_data, display);
+
+ node = next_node;
+ }
+
+ displays = ply_seat_get_text_displays (seat);
+ node = ply_list_get_first_node (displays);
+ while (node != NULL) {
+ ply_text_display_t *display;
+ ply_list_node_t *next_node;
+
+ display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (displays, node);
+
+ ply_list_append_data (manager->text_displays, display);
+
+ if (manager->text_display_added_handler != NULL)
+ manager->text_display_added_handler (manager->device_event_handler_data, display);
+
+ node = next_node;
+ }
+
+ keyboard = ply_seat_get_keyboard (seat);
+
+ if (keyboard != NULL && manager->keyboard_added_handler != NULL)
+ manager->keyboard_added_handler (manager->device_event_handler_data, keyboard);
+}
+
+static void
create_seat_for_terminal_and_renderer_type (ply_device_manager_t *manager,
const char *device_path,
ply_terminal_t *terminal,
@@ -646,8 +753,7 @@ create_seat_for_terminal_and_renderer_type (ply_device_manager_t *manager,
if (is_local_terminal)
manager->local_console_seat = seat;
- if (manager->seat_added_handler != NULL)
- manager->seat_added_handler (manager->seat_event_handler_data, seat);
+ add_devices (manager, seat);
}
static void
@@ -771,16 +877,24 @@ watch_for_coldplug_completion (ply_device_manager_t *manager)
}
void
-ply_device_manager_watch_seats (ply_device_manager_t *manager,
- ply_seat_added_handler_t seat_added_handler,
- ply_seat_removed_handler_t seat_removed_handler,
- void *data)
+ply_device_manager_watch_devices (ply_device_manager_t *manager,
+ ply_pixel_display_added_handler_t pixel_display_added_handler,
+ ply_pixel_display_removed_handler_t pixel_display_removed_handler,
+ ply_text_display_added_handler_t text_display_added_handler,
+ ply_text_display_removed_handler_t text_display_removed_handler,
+ ply_keyboard_added_handler_t keyboard_added_handler,
+ ply_keyboard_removed_handler_t keyboard_removed_handler,
+ void *data)
{
bool done_with_initial_seat_setup;
- manager->seat_added_handler = seat_added_handler;
- manager->seat_removed_handler = seat_removed_handler;
- manager->seat_event_handler_data = data;
+ manager->pixel_display_added_handler = pixel_display_added_handler;
+ manager->pixel_display_removed_handler = pixel_display_removed_handler;
+ manager->text_display_added_handler = text_display_added_handler;
+ manager->text_display_removed_handler = text_display_removed_handler;
+ manager->keyboard_added_handler = keyboard_added_handler;
+ manager->keyboard_removed_handler = keyboard_removed_handler;
+ manager->device_event_handler_data = data;
/* Try to create seats for each serial device right away, if possible
*/
@@ -800,7 +914,7 @@ ply_device_manager_watch_seats (ply_device_manager_t *manager,
}
bool
-ply_device_manager_has_open_seats (ply_device_manager_t *manager)
+ply_device_manager_has_open_displays (ply_device_manager_t *manager)
{
ply_list_node_t *node;
@@ -822,9 +936,21 @@ ply_device_manager_has_open_seats (ply_device_manager_t *manager)
}
ply_list_t *
-ply_device_manager_get_seats (ply_device_manager_t *manager)
+ply_device_manager_get_pixel_displays (ply_device_manager_t *manager)
+{
+ return manager->pixel_displays;
+}
+
+ply_list_t *
+ply_device_manager_get_text_displays (ply_device_manager_t *manager)
+{
+ return manager->text_displays;
+}
+
+ply_list_t *
+ply_device_manager_get_keyboards (ply_device_manager_t *manager)
{
- return manager->seats;
+ return manager->keyboards;
}
ply_terminal_t *
diff --git a/src/libply-splash-core/ply-device-manager.h b/src/libply-splash-core/ply-device-manager.h
index c3e6487b..6b821515 100644
--- a/src/libply-splash-core/ply-device-manager.h
+++ b/src/libply-splash-core/ply-device-manager.h
@@ -21,7 +21,9 @@
#define PLY_DEVICE_MANAGER_H
#include <stdbool.h>
-#include "ply-seat.h"
+#include "ply-text-display.h"
+#include "ply-pixel-display.h"
+#include "ply-keyboard.h"
typedef enum
{
@@ -31,20 +33,37 @@ typedef enum
} ply_device_manager_flags_t;
typedef struct _ply_device_manager ply_device_manager_t;
-typedef void (*ply_seat_added_handler_t) (void *,
- ply_seat_t *);
-typedef void (*ply_seat_removed_handler_t) (void *,
- ply_seat_t *);
+
+typedef void (*ply_pixel_display_added_handler_t) (void *,
+ ply_pixel_display_t *);
+typedef void (*ply_pixel_display_removed_handler_t) (void *,
+ ply_pixel_display_t *);
+
+typedef void (*ply_text_display_added_handler_t) (void *,
+ ply_text_display_t *);
+typedef void (*ply_text_display_removed_handler_t) (void *,
+ ply_text_display_t *);
+
+typedef void (*ply_keyboard_added_handler_t) (void *,
+ ply_keyboard_t *);
+typedef void (*ply_keyboard_removed_handler_t) (void *,
+ ply_keyboard_t *);
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_device_manager_t *ply_device_manager_new (const char *default_tty,
ply_device_manager_flags_t flags);
-void ply_device_manager_watch_seats (ply_device_manager_t *manager,
- ply_seat_added_handler_t seat_added_handler,
- ply_seat_removed_handler_t seat_removed_handler,
- void *data);
-bool ply_device_manager_has_open_seats (ply_device_manager_t *manager);
-ply_list_t *ply_device_manager_get_seats (ply_device_manager_t *manager);
+void ply_device_manager_watch_devices (ply_device_manager_t *manager,
+ ply_pixel_display_added_handler_t pixel_display_added_handler,
+ ply_pixel_display_removed_handler_t pixel_display_removed_handler,
+ ply_text_display_added_handler_t text_display_added_handler,
+ ply_text_display_removed_handler_t text_display_removed_handler,
+ ply_keyboard_added_handler_t keyboard_added_handler,
+ ply_keyboard_removed_handler_t keyboard_removed_handler,
+ void *data);
+bool ply_device_manager_has_open_displays (ply_device_manager_t *manager);
+ply_list_t *ply_device_manager_get_pixel_displays (ply_device_manager_t *manager);
+ply_list_t *ply_device_manager_get_text_displays (ply_device_manager_t *manager);
+ply_list_t *ply_device_manager_get_keyboards (ply_device_manager_t *manager);
void ply_device_manager_free (ply_device_manager_t *manager);
void ply_device_manager_activate_keyboards (ply_device_manager_t *manager);
void ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager);
diff --git a/src/main.c b/src/main.c
index da6e95d6..38441a98 100644
--- a/src/main.c
+++ b/src/main.c
@@ -136,8 +136,8 @@ static ply_boot_splash_t *load_theme (state_t *state,
static ply_boot_splash_t *show_theme (state_t *state,
const char *theme_path);
-static void attach_splash_to_seats (state_t *state,
- ply_boot_splash_t *splash);
+static void attach_splash_to_devices (state_t *state,
+ ply_boot_splash_t *splash);
static bool attach_to_running_session (state_t *state);
static void detach_from_running_session (state_t *state);
static void on_escape_pressed (state_t *state);
@@ -520,14 +520,14 @@ on_ask_for_password (state_t *state,
* arrive shortly so just sit tight
*/
if (state->is_shown) {
- bool has_open_seats;
+ bool has_open_displays;
cancel_pending_delayed_show (state);
- has_open_seats = ply_device_manager_has_open_seats (state->device_manager);
+ has_open_displays = ply_device_manager_has_open_displays (state->device_manager);
- if (has_open_seats) {
- ply_trace ("seats open now, showing splash immediately");
+ if (has_open_displays) {
+ ply_trace ("displays open now, showing splash immediately");
show_splash (state);
} else {
ply_trace ("splash still coming up, waiting a bit");
@@ -891,7 +891,7 @@ plymouth_should_show_default_splash (state_t *state)
static void
on_show_splash (state_t *state)
{
- bool has_open_seats;
+ bool has_open_displays;
if (state->is_shown) {
ply_trace ("show splash called while already shown");
@@ -910,27 +910,39 @@ on_show_splash (state_t *state)
}
state->is_shown = true;
- has_open_seats = ply_device_manager_has_open_seats (state->device_manager);
+ has_open_displays = ply_device_manager_has_open_displays (state->device_manager);
- if (!state->is_attached && state->should_be_attached && has_open_seats)
+ if (!state->is_attached && state->should_be_attached && has_open_displays)
attach_to_running_session (state);
- if (has_open_seats) {
- ply_trace ("at least one seat already open, so loading splash");
+ if (has_open_displays) {
+ ply_trace ("at least one displays already open, so loading splash");
show_splash (state);
} else {
- ply_trace ("no seats available to show splash on, waiting...");
+ ply_trace ("no displays available to show splash on, waiting...");
}
}
static void
-on_seat_removed (state_t *state,
- ply_seat_t *seat)
+on_pixel_display_removed (state_t *state,
+ ply_pixel_display_t *pixel_display)
{
- ply_keyboard_t *keyboard;
+ if (state->boot_splash != NULL)
+ ply_boot_splash_remove_pixel_display (state->boot_splash, pixel_display);
+}
- keyboard = ply_seat_get_keyboard (seat);
+static void
+on_text_display_removed (state_t *state,
+ ply_text_display_t *text_display)
+{
+ if (state->boot_splash != NULL)
+ ply_boot_splash_remove_text_display (state->boot_splash, text_display);
+}
+static void
+on_keyboard_removed (state_t *state,
+ ply_keyboard_t *keyboard)
+{
ply_trace ("no longer listening for keystrokes");
ply_keyboard_remove_input_handler (keyboard,
(ply_keyboard_input_handler_t)
@@ -949,7 +961,7 @@ on_seat_removed (state_t *state,
on_enter);
if (state->boot_splash != NULL)
- ply_boot_splash_detach_from_seat (state->boot_splash, seat);
+ ply_boot_splash_remove_keyboard (state->boot_splash, keyboard);
}
static void
@@ -991,22 +1003,45 @@ show_splash (state_t *state)
}
static void
-on_seat_added (state_t *state,
- ply_seat_t *seat)
+on_pixel_display_added (state_t *state,
+ ply_pixel_display_t *pixel_display)
{
- ply_keyboard_t *keyboard;
+ if (state->is_shown && !state->is_inactive) {
+ if (state->boot_splash == NULL) {
+ ply_trace ("pixel display added before splash loaded, so loading splash now");
+ show_splash (state);
+ } else {
+ ply_trace ("pixel display added after splash loaded, so attaching to splash");
+ ply_boot_splash_add_pixel_display (state->boot_splash, pixel_display);
+ }
+ }
+}
+static void
+on_text_display_added (state_t *state,
+ ply_text_display_t *text_display)
+{
if (state->is_shown && !state->is_inactive) {
if (state->boot_splash == NULL) {
- ply_trace ("seat added before splash loaded, so loading splash now");
+ ply_trace ("text display added before splash loaded, so loading splash now");
show_splash (state);
} else {
- ply_trace ("seat added after splash loaded, so attaching to splash");
- ply_boot_splash_attach_to_seat (state->boot_splash, seat);
+ ply_trace ("text display added after splash loaded, so attaching to splash");
+ ply_boot_splash_add_text_display (state->boot_splash, text_display);
}
}
+}
- keyboard = ply_seat_get_keyboard (seat);
+static void
+on_keyboard_added (state_t *state,
+ ply_keyboard_t *keyboard)
+{
+ if (state->is_shown && !state->is_inactive) {
+ if (state->boot_splash != NULL) {
+ ply_trace ("keyboard added after splash loaded, so attaching to splash");
+ ply_boot_splash_add_keyboard (state->boot_splash, keyboard);
+ }
+ }
ply_trace ("listening for keystrokes");
ply_keyboard_add_input_handler (keyboard,
@@ -1033,12 +1068,20 @@ load_devices (state_t *state,
state->device_manager = ply_device_manager_new (state->default_tty, flags);
state->local_console_terminal = ply_device_manager_get_default_terminal (state->device_manager);
- ply_device_manager_watch_seats (state->device_manager,
- (ply_seat_added_handler_t)
- on_seat_added,
- (ply_seat_removed_handler_t)
- on_seat_removed,
- state);
+ ply_device_manager_watch_devices (state->device_manager,
+ (ply_pixel_display_added_handler_t)
+ on_pixel_display_added,
+ (ply_pixel_display_removed_handler_t)
+ on_pixel_display_removed,
+ (ply_text_display_added_handler_t)
+ on_text_display_added,
+ (ply_text_display_removed_handler_t)
+ on_text_display_removed,
+ (ply_keyboard_added_handler_t)
+ on_keyboard_added,
+ (ply_keyboard_removed_handler_t)
+ on_keyboard_removed,
+ state);
}
static void
@@ -1507,22 +1550,50 @@ on_enter (state_t *state,
}
static void
-attach_splash_to_seats (state_t *state,
- ply_boot_splash_t *splash)
+attach_splash_to_devices (state_t *state,
+ ply_boot_splash_t *splash)
{
- ply_list_t *seats;
+ ply_list_t *pixel_displays, *text_displays, *keyboards;
ply_list_node_t *node;
- seats = ply_device_manager_get_seats (state->device_manager);
- node = ply_list_get_first_node (seats);
+ pixel_displays = ply_device_manager_get_pixel_displays (state->device_manager);
+ node = ply_list_get_first_node (pixel_displays);
+ while (node != NULL) {
+ ply_pixel_display_t *pixel_display;
+ ply_list_node_t *next_node;
+
+ pixel_display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (pixel_displays, node);
+
+ ply_boot_splash_add_pixel_display (splash, pixel_display);
+
+ node = next_node;
+ }
+
+ text_displays = ply_device_manager_get_text_displays (state->device_manager);
+ node = ply_list_get_first_node (text_displays);
+ while (node != NULL) {
+ ply_text_display_t *text_display;
+ ply_list_node_t *next_node;
+
+ text_display = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (text_displays, node);
+
+ ply_boot_splash_add_text_display (splash, text_display);
+
+ node = next_node;
+ }
+
+ keyboards = ply_device_manager_get_keyboards (state->device_manager);
+ node = ply_list_get_first_node (keyboards);
while (node != NULL) {
- ply_seat_t *seat;
+ ply_keyboard_t *keyboard;
ply_list_node_t *next_node;
- seat = ply_list_node_get_data (node);
- next_node = ply_list_get_next_node (seats, node);
+ keyboard = ply_list_node_get_data (node);
+ next_node = ply_list_get_next_node (keyboards, node);
- ply_boot_splash_attach_to_seat (splash, seat);
+ ply_boot_splash_add_keyboard (splash, keyboard);
node = next_node;
}
@@ -1623,7 +1694,7 @@ show_theme (state_t *state,
if (splash == NULL)
return NULL;
- attach_splash_to_seats (state, splash);
+ attach_splash_to_devices (state, splash);
ply_device_manager_activate_renderers (state->device_manager);
splash_mode = get_splash_mode_from_mode (state->mode);