Skip to content

Commit

Permalink
kmscon: add --vt=<num> option to select VT for seat0
Browse files Browse the repository at this point in the history
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 <dh.herrmann@googlemail.com>
  • Loading branch information
David Herrmann committed Sep 29, 2012
1 parent a6165a0 commit bf18799
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 <vt-number> [auto] Select which VT to run on on seat0\n"
"\t --seats <list,of,seats> [seat0] Select seats or pass 'all' to make\n"
"\t kmscon run on all seats\n"
"\n"
Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 3 additions & 1 deletion src/uterm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/uterm_vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bf18799

Please sign in to comment.