mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
ui/console: add console event notifier infrastructure
Add a NotifierList to DisplayState so display backends can be notified when consoles are added or removed at runtime. No events are fired yet, that follows in the next commits. Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260623-b4-ui-v4-23-4656aec3398d@redhat.com>
This commit is contained in:
23
ui/console.c
23
ui/console.c
@@ -70,6 +70,7 @@ struct DisplayState {
|
||||
bool refreshing;
|
||||
|
||||
QLIST_HEAD(, DisplayChangeListener) listeners;
|
||||
NotifierList console_notifiers;
|
||||
};
|
||||
|
||||
static DisplayState *display_state;
|
||||
@@ -84,6 +85,16 @@ static bool console_compatible_with(QemuConsole *con,
|
||||
static QemuConsole *qemu_graphic_console_lookup_unused(void);
|
||||
static void dpy_set_ui_info_timer(void *opaque);
|
||||
|
||||
void qemu_console_notify(QemuConsoleEventType type, QemuConsole *con)
|
||||
{
|
||||
DisplayState *ds = get_alloc_displaystate();
|
||||
QemuConsoleEvent event = {
|
||||
.type = type,
|
||||
.con = con,
|
||||
};
|
||||
notifier_list_notify(&ds->console_notifiers, &event);
|
||||
}
|
||||
|
||||
static void gui_update(void *opaque)
|
||||
{
|
||||
uint64_t interval = GUI_REFRESH_INTERVAL_IDLE;
|
||||
@@ -1056,10 +1067,22 @@ static DisplayState *get_alloc_displaystate(void)
|
||||
{
|
||||
if (!display_state) {
|
||||
display_state = g_new0(DisplayState, 1);
|
||||
notifier_list_init(&display_state->console_notifiers);
|
||||
}
|
||||
return display_state;
|
||||
}
|
||||
|
||||
void qemu_console_add_notifier(Notifier *notifier)
|
||||
{
|
||||
DisplayState *ds = get_alloc_displaystate();
|
||||
notifier_list_add(&ds->console_notifiers, notifier);
|
||||
}
|
||||
|
||||
void qemu_console_remove_notifier(Notifier *notifier)
|
||||
{
|
||||
notifier_remove(notifier);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by main(), after creating QemuConsoles
|
||||
* and before initializing ui (sdl/vnc/...).
|
||||
|
||||
Reference in New Issue
Block a user