weston-launch: Allow activating our own VT by passing a negative value
This will be used to implement activate_session.
This commit is contained in:
parent
7314cdac94
commit
394af33607
@ -80,6 +80,7 @@ struct weston_launch {
|
|||||||
struct termios terminal_attributes;
|
struct termios terminal_attributes;
|
||||||
int kb_mode;
|
int kb_mode;
|
||||||
enum vt_state vt_state;
|
enum vt_state vt_state;
|
||||||
|
unsigned vt;
|
||||||
|
|
||||||
int drm_fd;
|
int drm_fd;
|
||||||
};
|
};
|
||||||
@ -274,6 +275,7 @@ handle_activate_vt(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
|
|||||||
{
|
{
|
||||||
struct weston_launcher_reply reply;
|
struct weston_launcher_reply reply;
|
||||||
struct weston_launcher_activate_vt *message;
|
struct weston_launcher_activate_vt *message;
|
||||||
|
unsigned vt;
|
||||||
|
|
||||||
reply.header.opcode = WESTON_LAUNCHER_ACTIVATE_VT;
|
reply.header.opcode = WESTON_LAUNCHER_ACTIVATE_VT;
|
||||||
reply.ret = -1;
|
reply.ret = -1;
|
||||||
@ -285,7 +287,13 @@ handle_activate_vt(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
|
|||||||
|
|
||||||
message = msg->msg_iov->iov_base;
|
message = msg->msg_iov->iov_base;
|
||||||
|
|
||||||
reply.ret = ioctl(wl->tty, VT_ACTIVATE, message->vt);
|
/* Negative values mean that we're activating our own VT */
|
||||||
|
if (message->vt > 0)
|
||||||
|
vt = message->vt;
|
||||||
|
else
|
||||||
|
vt = wl->vt;
|
||||||
|
|
||||||
|
reply.ret = ioctl(wl->tty, VT_ACTIVATE, vt);
|
||||||
if (reply.ret < 0)
|
if (reply.ret < 0)
|
||||||
reply.ret = -errno;
|
reply.ret = -errno;
|
||||||
|
|
||||||
@ -553,7 +561,6 @@ setup_tty(struct weston_launch *wl)
|
|||||||
struct termios raw_attributes;
|
struct termios raw_attributes;
|
||||||
struct vt_mode mode = { 0 };
|
struct vt_mode mode = { 0 };
|
||||||
char *session;
|
char *session;
|
||||||
unsigned vt;
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
@ -561,11 +568,11 @@ setup_tty(struct weston_launch *wl)
|
|||||||
if (ok < 0)
|
if (ok < 0)
|
||||||
error(1, -ok, "could not determine current session");
|
error(1, -ok, "could not determine current session");
|
||||||
|
|
||||||
ok = sd_session_get_vt(session, &vt);
|
ok = sd_session_get_vt(session, &wl->vt);
|
||||||
if (ok < 0)
|
if (ok < 0)
|
||||||
error(1, -ok, "could not determine current TTY");
|
error(1, -ok, "could not determine current TTY");
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "/dev/tty%u", vt);
|
snprintf(path, PATH_MAX, "/dev/tty%u", wl->vt);
|
||||||
wl->tty = open(path, O_RDWR | O_NOCTTY | O_CLOEXEC);
|
wl->tty = open(path, O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||||
|
|
||||||
if (wl->tty < 0)
|
if (wl->tty < 0)
|
||||||
|
@ -53,7 +53,7 @@ struct weston_launcher_open {
|
|||||||
|
|
||||||
struct weston_launcher_activate_vt {
|
struct weston_launcher_activate_vt {
|
||||||
struct weston_launcher_message header;
|
struct weston_launcher_message header;
|
||||||
int vt;
|
signed char vt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct weston_launcher_reply {
|
struct weston_launcher_reply {
|
||||||
|
Loading…
Reference in New Issue
Block a user