Bind the console at vte creation instead of dynamically during runtime.
There is no need to rebind a console so remove this complexity.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
if (ret)
goto err_free;
- ret = kmscon_vte_new(&term->vte);
+ ret = kmscon_vte_new(&term->vte, term->console);
if (ret)
goto err_con;
- kmscon_vte_bind(term->vte, term->console);
ret = kmscon_pty_new(&term->pty, term->eloop, pty_input, term);
if (ret)
int csi_argv[CSI_ARG_MAX];
};
-int kmscon_vte_new(struct kmscon_vte **out)
+int kmscon_vte_new(struct kmscon_vte **out, struct kmscon_console *con)
{
struct kmscon_vte *vte;
int ret;
- if (!out)
+ if (!out || !con)
return -EINVAL;
vte = malloc(sizeof(*vte));
memset(vte, 0, sizeof(*vte));
vte->ref = 1;
vte->state = STATE_GROUND;
+ vte->con = con;
ret = kmscon_utf8_mach_new(&vte->mach);
if (ret)
goto err_free;
log_debug("new vte object");
+ kmscon_console_ref(vte->con);
*out = vte;
return 0;
free(vte);
}
-void kmscon_vte_bind(struct kmscon_vte *vte, struct kmscon_console *con)
-{
- if (!vte)
- return;
-
- kmscon_console_unref(vte->con);
- vte->con = con;
- kmscon_console_ref(vte->con);
-}
-
/* execute control character (C0 or C1) */
static void do_execute(struct kmscon_vte *vte, uint32_t ctrl)
{
KMSCON_VTE_SEND,
};
-int kmscon_vte_new(struct kmscon_vte **out);
+int kmscon_vte_new(struct kmscon_vte **out, struct kmscon_console *con);
void kmscon_vte_ref(struct kmscon_vte *vte);
void kmscon_vte_unref(struct kmscon_vte *vte);
-void kmscon_vte_bind(struct kmscon_vte *vte, struct kmscon_console *con);
void kmscon_vte_input(struct kmscon_vte *vte, const char *u8, size_t len);
int kmscon_vte_handle_keyboard(struct kmscon_vte *vte,
const struct uterm_input_event *ev, const char **u8, size_t *len);