vte: remove kmscon_vte_bind()
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 27 May 2012 12:47:11 +0000 (14:47 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 27 May 2012 12:47:11 +0000 (14:47 +0200)
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>
src/terminal.c
src/vte.c
src/vte.h

index c596a58..68d196f 100644 (file)
@@ -284,10 +284,9 @@ int kmscon_terminal_new(struct kmscon_terminal **out,
        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)
index a2f38b8..1b86da0 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -115,12 +115,12 @@ struct kmscon_vte {
        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));
@@ -130,12 +130,14 @@ int kmscon_vte_new(struct kmscon_vte **out)
        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;
 
@@ -167,16 +169,6 @@ void kmscon_vte_unref(struct kmscon_vte *vte)
        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)
 {
index a781dfe..6d3425d 100644 (file)
--- a/src/vte.h
+++ b/src/vte.h
@@ -44,11 +44,10 @@ enum kmscon_vte_keyboard_action {
        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);