compositor: choose tty from command line

This is a backend option, so you should use something like '-otty='.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
dev
Tiago Vignatti 13 years ago committed by Kristian Høgsberg
parent bbc2e03b2a
commit faee80196f
  1. 12
      compositor/compositor-drm.c
  2. 12
      compositor/compositor-openwfd.c
  3. 3
      compositor/compositor.h
  4. 9
      compositor/tty.c

@ -779,7 +779,7 @@ static const char default_seat[] = "seat0";
static struct wlsc_compositor * static struct wlsc_compositor *
drm_compositor_create(struct wl_display *display, drm_compositor_create(struct wl_display *display,
int connector, const char *seat) int connector, const char *seat, int tty)
{ {
struct drm_compositor *ec; struct drm_compositor *ec;
struct udev_enumerate *e; struct udev_enumerate *e;
@ -856,7 +856,7 @@ drm_compositor_create(struct wl_display *display,
ec->drm_source = ec->drm_source =
wl_event_loop_add_fd(loop, ec->drm.fd, wl_event_loop_add_fd(loop, ec->drm.fd,
WL_EVENT_READABLE, on_drm_input, ec); 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"); ec->udev_monitor = udev_monitor_new_from_netlink(ec->udev, "udev");
if (ec->udev_monitor == NULL) { if (ec->udev_monitor == NULL) {
@ -887,8 +887,9 @@ backend_init(struct wl_display *display, char *options)
int connector = 0, i; int connector = 0, i;
const char *seat; const char *seat;
char *p, *value; char *p, *value;
int tty = 1;
static char * const tokens[] = { "connector", "seat", NULL }; static char * const tokens[] = { "connector", "seat", "tty", NULL };
p = options; p = options;
seat = default_seat; seat = default_seat;
@ -900,8 +901,11 @@ backend_init(struct wl_display *display, char *options)
case 1: case 1:
seat = value; seat = value;
break; break;
case 2:
tty = strtol(value, NULL, 0);
break;
} }
} }
return drm_compositor_create(display, connector, seat); return drm_compositor_create(display, connector, seat, tty);
} }

@ -594,7 +594,7 @@ static const char default_seat[] = "seat0";
static struct wlsc_compositor * static struct wlsc_compositor *
wfd_compositor_create(struct wl_display *display, wfd_compositor_create(struct wl_display *display,
int connector, const char *seat) int connector, const char *seat, int tty)
{ {
struct wfd_compositor *ec; struct wfd_compositor *ec;
struct wl_event_loop *loop; struct wl_event_loop *loop;
@ -655,7 +655,7 @@ wfd_compositor_create(struct wl_display *display,
wl_event_loop_add_fd(loop, wl_event_loop_add_fd(loop,
wfdDeviceEventGetFD(ec->dev, ec->event), wfdDeviceEventGetFD(ec->dev, ec->event),
WL_EVENT_READABLE, on_wfd_event, ec); 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; return &ec->base;
} }
@ -669,8 +669,9 @@ backend_init(struct wl_display *display, char *options)
int connector = 0, i; int connector = 0, i;
const char *seat; const char *seat;
char *p, *value; char *p, *value;
int tty = 1;
static char * const tokens[] = { "connector", "seat", NULL }; static char * const tokens[] = { "connector", "seat", "tty", NULL };
p = options; p = options;
seat = default_seat; seat = default_seat;
@ -682,8 +683,11 @@ backend_init(struct wl_display *display, char *options)
case 1: case 1:
seat = value; seat = value;
break; break;
case 2:
tty = value;
break;
} }
} }
return wfd_compositor_create(display, connector, seat); return wfd_compositor_create(display, connector, seat, tty);
} }

@ -388,7 +388,8 @@ enum {
typedef void (*tty_vt_func_t)(struct wlsc_compositor *compositor, int event); typedef void (*tty_vt_func_t)(struct wlsc_compositor *compositor, int event);
struct tty * 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 void
tty_destroy(struct tty *tty); tty_destroy(struct tty *tty);

@ -89,22 +89,27 @@ on_tty_input(int fd, uint32_t mask, void *data)
} }
struct tty * 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 termios raw_attributes;
struct vt_mode mode = { 0 }; struct vt_mode mode = { 0 };
int ret; int ret;
struct tty *tty; struct tty *tty;
struct wl_event_loop *loop; struct wl_event_loop *loop;
char filename[16];
tty = malloc(sizeof *tty); tty = malloc(sizeof *tty);
if (tty == NULL) if (tty == NULL)
return NULL; return NULL;
snprintf(filename, sizeof filename, "/dev/tty%d", tty_nr);
fprintf(stderr, "compositor: using %s\n", filename);
memset(tty, 0, sizeof *tty); memset(tty, 0, sizeof *tty);
tty->compositor = compositor; tty->compositor = compositor;
tty->vt_func = vt_func; 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) { if (tty->fd <= 0) {
fprintf(stderr, "failed to open active tty: %m\n"); fprintf(stderr, "failed to open active tty: %m\n");
return NULL; return NULL;

Loading…
Cancel
Save