From bf1879901555579b119097c4dfd2dc6f9f4ab48f Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 29 Sep 2012 11:49:54 +0200 Subject: [PATCH] kmscon: add --vt= option to select VT for seat0 VTs are only available on seat0 so this option does not affect other seats. On seat0 it selects the VT that we run on. We do _not_ fall back to another seat if it fails but disable this seat instead. Reported-by: Matthew Monaco Signed-off-by: David Herrmann --- src/main.c | 4 +++- src/main.h | 2 ++ src/uterm.h | 4 +++- src/uterm_vt.c | 7 ++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 6669509..eef6454 100644 --- a/src/main.c +++ b/src/main.c @@ -157,7 +157,7 @@ static void seat_new(struct kmscon_app *app, goto err_name; ret = uterm_vt_allocate(app->vtm, &seat->vt, seat->sname, - seat->input, vt_event, seat); + seat->input, kmscon_conf.vt, vt_event, seat); if (ret) goto err_input; @@ -426,6 +426,7 @@ static void print_help() "\t --debug [off] Enable debug mode\n" "\t --silent [off] Suppress notices and warnings\n" "\t-s, --switchvt [off] Automatically switch to VT\n" + "\t --vt [auto] Select which VT to run on on seat0\n" "\t --seats [seat0] Select seats or pass 'all' to make\n" "\t kmscon run on all seats\n" "\n" @@ -678,6 +679,7 @@ struct conf_option options[] = { CONF_OPTION_UINT(0, "fps", NULL, &kmscon_conf.fps, 50), CONF_OPTION_STRING(0, "render-engine", NULL, &kmscon_conf.render_engine, NULL), CONF_OPTION_BOOL(0, "render-timing", NULL, &kmscon_conf.render_timing, false), + CONF_OPTION_INT(0, "vt", NULL, &kmscon_conf.vt, UTERM_VT_DEFAULT), CONF_OPTION_BOOL('s', "switchvt", NULL, &kmscon_conf.switchvt, false), CONF_OPTION_BOOL('l', "login", aftercheck_login, &kmscon_conf.login, false), CONF_OPTION_STRING('t', "term", NULL, &kmscon_conf.term, "xterm-256color"), diff --git a/src/main.h b/src/main.h index a41be99..c192226 100644 --- a/src/main.h +++ b/src/main.h @@ -46,6 +46,8 @@ struct kmscon_conf_t { bool verbose; /* disable notices and warnings */ bool silent; + /* VT number to run on on seat0 */ + int vt; /* enter new VT directly */ bool switchvt; /* use framebuffers instead of DRM */ diff --git a/src/uterm.h b/src/uterm.h index dcaf84a..3359c39 100644 --- a/src/uterm.h +++ b/src/uterm.h @@ -334,6 +334,8 @@ enum uterm_vt_mode { UTERM_VT_DEAD, }; +#define UTERM_VT_DEFAULT (-1) + typedef int (*uterm_vt_cb) (struct uterm_vt *vt, unsigned int action, void *data); @@ -344,7 +346,7 @@ void uterm_vt_master_unref(struct uterm_vt_master *vtm); int uterm_vt_allocate(struct uterm_vt_master *vt, struct uterm_vt **out, const char *seat, struct uterm_input *input, - uterm_vt_cb cb, void *data); + int vt_for_seat0, uterm_vt_cb cb, void *data); void uterm_vt_deallocate(struct uterm_vt *vt); void uterm_vt_ref(struct uterm_vt *vt); void uterm_vt_unref(struct uterm_vt *vt); diff --git a/src/uterm_vt.c b/src/uterm_vt.c index 6708e39..d7e11a7 100644 --- a/src/uterm_vt.c +++ b/src/uterm_vt.c @@ -203,7 +203,7 @@ static int open_tty(int id, int *tty_fd, int *tty_num) return 0; } -static int real_open(struct uterm_vt *vt) +static int real_open(struct uterm_vt *vt, int vt_for_seat0) { struct termios raw_attribs; struct vt_mode mode; @@ -213,7 +213,7 @@ static int real_open(struct uterm_vt *vt) log_debug("open vt %p", vt); - ret = open_tty(-1, &vt->real_fd, &vt->real_num); + ret = open_tty(vt_for_seat0, &vt->real_fd, &vt->real_num); if (ret) return ret; @@ -455,6 +455,7 @@ int uterm_vt_allocate(struct uterm_vt_master *vtm, struct uterm_vt **out, const char *seat, struct uterm_input *input, + int vt_for_seat0, uterm_vt_cb cb, void *data) { @@ -489,7 +490,7 @@ int uterm_vt_allocate(struct uterm_vt_master *vtm, if (!strcmp(seat, "seat0") && vtm->vt_support) { vt->mode = UTERM_VT_REAL; - ret = real_open(vt); + ret = real_open(vt, vt_for_seat0); if (ret) goto err_sig2; } else {