diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c index e1e94bc9..09e3dcc4 100644 --- a/compositor/compositor-drm.c +++ b/compositor/compositor-drm.c @@ -779,7 +779,7 @@ static const char default_seat[] = "seat0"; static struct wlsc_compositor * drm_compositor_create(struct wl_display *display, - int connector, const char *seat) + int connector, const char *seat, int tty) { struct drm_compositor *ec; struct udev_enumerate *e; @@ -856,7 +856,7 @@ drm_compositor_create(struct wl_display *display, ec->drm_source = wl_event_loop_add_fd(loop, ec->drm.fd, WL_EVENT_READABLE, on_drm_input, ec); - ec->tty = tty_create(&ec->base, vt_func); + ec->tty = tty_create(&ec->base, vt_func, tty); ec->udev_monitor = udev_monitor_new_from_netlink(ec->udev, "udev"); if (ec->udev_monitor == NULL) { @@ -887,8 +887,9 @@ backend_init(struct wl_display *display, char *options) int connector = 0, i; const char *seat; char *p, *value; + int tty = 1; - static char * const tokens[] = { "connector", "seat", NULL }; + static char * const tokens[] = { "connector", "seat", "tty", NULL }; p = options; seat = default_seat; @@ -900,8 +901,11 @@ backend_init(struct wl_display *display, char *options) case 1: seat = value; break; + case 2: + tty = strtol(value, NULL, 0); + break; } } - return drm_compositor_create(display, connector, seat); + return drm_compositor_create(display, connector, seat, tty); } diff --git a/compositor/compositor-openwfd.c b/compositor/compositor-openwfd.c index 144e4abf..d275a60a 100644 --- a/compositor/compositor-openwfd.c +++ b/compositor/compositor-openwfd.c @@ -594,7 +594,7 @@ static const char default_seat[] = "seat0"; static struct wlsc_compositor * wfd_compositor_create(struct wl_display *display, - int connector, const char *seat) + int connector, const char *seat, int tty) { struct wfd_compositor *ec; struct wl_event_loop *loop; @@ -655,7 +655,7 @@ wfd_compositor_create(struct wl_display *display, wl_event_loop_add_fd(loop, wfdDeviceEventGetFD(ec->dev, ec->event), WL_EVENT_READABLE, on_wfd_event, ec); - ec->tty = tty_create(&ec->base, vt_func); + ec->tty = tty_create(&ec->base, vt_func, tty); return &ec->base; } @@ -669,8 +669,9 @@ backend_init(struct wl_display *display, char *options) int connector = 0, i; const char *seat; char *p, *value; + int tty = 1; - static char * const tokens[] = { "connector", "seat", NULL }; + static char * const tokens[] = { "connector", "seat", "tty", NULL }; p = options; seat = default_seat; @@ -682,8 +683,11 @@ backend_init(struct wl_display *display, char *options) case 1: seat = value; break; + case 2: + tty = value; + break; } } - return wfd_compositor_create(display, connector, seat); + return wfd_compositor_create(display, connector, seat, tty); } diff --git a/compositor/compositor.h b/compositor/compositor.h index 6df15da6..0efc873a 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -388,7 +388,8 @@ enum { typedef void (*tty_vt_func_t)(struct wlsc_compositor *compositor, int event); struct tty * -tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func); +tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func, + int tty_nr); void tty_destroy(struct tty *tty); diff --git a/compositor/tty.c b/compositor/tty.c index e74f0ebe..5ed921ca 100644 --- a/compositor/tty.c +++ b/compositor/tty.c @@ -89,22 +89,27 @@ on_tty_input(int fd, uint32_t mask, void *data) } struct tty * -tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func) +tty_create(struct wlsc_compositor *compositor, tty_vt_func_t vt_func, + int tty_nr) { struct termios raw_attributes; struct vt_mode mode = { 0 }; int ret; struct tty *tty; struct wl_event_loop *loop; + char filename[16]; tty = malloc(sizeof *tty); if (tty == NULL) return NULL; + snprintf(filename, sizeof filename, "/dev/tty%d", tty_nr); + fprintf(stderr, "compositor: using %s\n", filename); + memset(tty, 0, sizeof *tty); tty->compositor = compositor; tty->vt_func = vt_func; - tty->fd = open("/dev/tty", O_RDWR | O_NOCTTY); + tty->fd = open(filename, O_RDWR | O_NOCTTY); if (tty->fd <= 0) { fprintf(stderr, "failed to open active tty: %m\n"); return NULL;