gtk: overwrite the console.c char driver
Instead of registering a vc handler to allocate the Gtk VC Chardev, overwrite the console.c char driver. A later patch, when switching to QOM, will register a default console vc QOM class if none has been registered before. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
776a32a075
commit
6f974c843c
@ -507,9 +507,7 @@ void register_char_driver(const CharDriver *driver);
|
|||||||
|
|
||||||
extern int term_escape_char;
|
extern int term_escape_char;
|
||||||
|
|
||||||
|
|
||||||
/* console.c */
|
/* console.c */
|
||||||
typedef Chardev *(VcHandler)(ChardevVC *vc, Error **errp);
|
void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp);
|
||||||
void register_vc_handler(VcHandler *handler);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
24
ui/console.c
24
ui/console.c
@ -2058,8 +2058,12 @@ static void text_console_do_init(Chardev *chr, DisplayState *ds)
|
|||||||
|
|
||||||
static const CharDriver vc_driver;
|
static const CharDriver vc_driver;
|
||||||
|
|
||||||
static Chardev *text_console_init(ChardevVC *vc, Error **errp)
|
static Chardev *vc_init(const CharDriver *driver,
|
||||||
|
const char *id, ChardevBackend *backend,
|
||||||
|
ChardevReturn *ret, bool *be_opened,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
ChardevVC *vc = backend->u.vc.data;
|
||||||
ChardevCommon *common = qapi_ChardevVC_base(vc);
|
ChardevCommon *common = qapi_ChardevVC_base(vc);
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
VCChardev *drv;
|
VCChardev *drv;
|
||||||
@ -2105,26 +2109,13 @@ static Chardev *text_console_init(ChardevVC *vc, Error **errp)
|
|||||||
if (display_state) {
|
if (display_state) {
|
||||||
text_console_do_init(chr, display_state);
|
text_console_do_init(chr, display_state);
|
||||||
}
|
}
|
||||||
return chr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VcHandler *vc_handler = text_console_init;
|
|
||||||
|
|
||||||
static Chardev *vc_init(const CharDriver *driver,
|
|
||||||
const char *id, ChardevBackend *backend,
|
|
||||||
ChardevReturn *ret, bool *be_opened,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
/* console/chardev init sometimes completes elsewhere in a 2nd
|
/* console/chardev init sometimes completes elsewhere in a 2nd
|
||||||
* stage, so defer OPENED events until they are fully initialized
|
* stage, so defer OPENED events until they are fully initialized
|
||||||
*/
|
*/
|
||||||
*be_opened = false;
|
*be_opened = false;
|
||||||
return vc_handler(backend->u.vc.data, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_vc_handler(VcHandler *handler)
|
return chr;
|
||||||
{
|
|
||||||
vc_handler = handler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_console_resize(QemuConsole *s, int width, int height)
|
void qemu_console_resize(QemuConsole *s, int width, int height)
|
||||||
@ -2162,8 +2153,7 @@ PixelFormat qemu_default_pixelformat(int bpp)
|
|||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend,
|
void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp)
|
||||||
Error **errp)
|
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
ChardevVC *vc;
|
ChardevVC *vc;
|
||||||
|
30
ui/gtk.c
30
ui/gtk.c
@ -1712,16 +1712,14 @@ static void gd_vc_chr_set_echo(Chardev *chr, bool echo)
|
|||||||
|
|
||||||
static int nb_vcs;
|
static int nb_vcs;
|
||||||
static Chardev *vcs[MAX_VCS];
|
static Chardev *vcs[MAX_VCS];
|
||||||
|
static const CharDriver gd_vc_driver;
|
||||||
|
|
||||||
static Chardev *gd_vc_handler(ChardevVC *vc, Error **errp)
|
static Chardev *vc_init(const CharDriver *driver,
|
||||||
|
const char *id, ChardevBackend *backend,
|
||||||
|
ChardevReturn *ret, bool *be_opened,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
static const CharDriver gd_vc_driver = {
|
ChardevVC *vc = backend->u.vc.data;
|
||||||
.instance_size = sizeof(VCChardev),
|
|
||||||
.kind = CHARDEV_BACKEND_KIND_VC,
|
|
||||||
.chr_write = gd_vc_chr_write,
|
|
||||||
.chr_set_echo = gd_vc_chr_set_echo,
|
|
||||||
};
|
|
||||||
|
|
||||||
ChardevCommon *common = qapi_ChardevVC_base(vc);
|
ChardevCommon *common = qapi_ChardevVC_base(vc);
|
||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
|
|
||||||
@ -1737,9 +1735,22 @@ static Chardev *gd_vc_handler(ChardevVC *vc, Error **errp)
|
|||||||
|
|
||||||
vcs[nb_vcs++] = chr;
|
vcs[nb_vcs++] = chr;
|
||||||
|
|
||||||
|
/* console/chardev init sometimes completes elsewhere in a 2nd
|
||||||
|
* stage, so defer OPENED events until they are fully initialized
|
||||||
|
*/
|
||||||
|
*be_opened = false;
|
||||||
|
|
||||||
return chr;
|
return chr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const CharDriver gd_vc_driver = {
|
||||||
|
.instance_size = sizeof(VCChardev),
|
||||||
|
.kind = CHARDEV_BACKEND_KIND_VC,
|
||||||
|
.parse = qemu_chr_parse_vc, .create = vc_init,
|
||||||
|
.chr_write = gd_vc_chr_write,
|
||||||
|
.chr_set_echo = gd_vc_chr_set_echo,
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
|
static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -2336,6 +2347,7 @@ void early_gtk_display_init(int opengl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_VTE)
|
#if defined(CONFIG_VTE)
|
||||||
register_vc_handler(gd_vc_handler);
|
/* overwrite the console.c vc driver */
|
||||||
|
register_char_driver(&gd_vc_driver);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user