Internally, the UI subsystem already supports multiple video objects.
However, the public API didn't expose that, yet. This changes the API to
allow adding and removing video objects from the UI.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
}
}
- ret = kmscon_ui_new(&seat->ui, seat->app->eloop, seat->video,
+ ret = kmscon_ui_new(&seat->ui, seat->app->eloop,
seat->input);
if (ret) {
log_error("cannot create UI object");
goto err_video;
}
+ kmscon_ui_add_video(seat->ui, seat->video);
+
seat->vdev = dev;
log_debug("new graphics device on seat %s", seat->sname);
return;
log_debug("free graphics device on seat %s", seat->sname);
+ kmscon_ui_remove_video(seat->ui, seat->video);
kmscon_ui_free(seat->ui);
seat->ui = NULL;
seat->vdev = NULL;
int kmscon_ui_new(struct kmscon_ui **out,
struct ev_eloop *eloop,
- struct uterm_video *video,
struct uterm_input *input)
{
struct kmscon_ui *ui;
int ret;
- if (!out || !eloop || !video || !input)
+ if (!out || !eloop || !input)
return -EINVAL;
ui = malloc(sizeof(*ui));
if (ret)
goto err_free;
- video_new(ui, video);
-
ret = uterm_input_register_cb(ui->input, input_event, ui);
if (ret)
goto err_video;
ev_eloop_unref(ui->eloop);
free(ui);
}
+
+void kmscon_ui_add_video(struct kmscon_ui *ui, struct uterm_video *video)
+{
+ if (!ui || !video)
+ return;
+
+ video_new(ui, video);
+}
+
+void kmscon_ui_remove_video(struct kmscon_ui *ui, struct uterm_video *video)
+{
+ struct ui_video *vid;
+ struct kmscon_dlist *iter;
+
+ if (!ui || !video)
+ return;
+
+ kmscon_dlist_for_each(iter, &ui->video_list) {
+ vid = kmscon_dlist_entry(iter, struct ui_video, list);
+ if (vid->video == video) {
+ video_free(vid);
+ return;
+ }
+ }
+}
int kmscon_ui_new(struct kmscon_ui **out,
struct ev_eloop *eloop,
- struct uterm_video *video,
struct uterm_input *input);
void kmscon_ui_free(struct kmscon_ui *ui);
+void kmscon_ui_add_video(struct kmscon_ui *ui, struct uterm_video *video);
+void kmscon_ui_remove_video(struct kmscon_ui *ui, struct uterm_video *video);
#endif /* KMSCON_UI_H */