summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-03-11 17:12:54 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-03-11 17:25:40 -0400
commit394af336074045bcbbaac60991814ad8695a5c79 (patch)
treecdb4452e247ab565719646d6f248c6930f22dccc
parent7314cdac947e103a82a707a27ca3f676c0a4a823 (diff)
downloadmutter-394af336074045bcbbaac60991814ad8695a5c79.tar.gz
weston-launch: Allow activating our own VT by passing a negative value
This will be used to implement activate_session.
-rw-r--r--src/wayland/weston-launch.c15
-rw-r--r--src/wayland/weston-launch.h2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/wayland/weston-launch.c b/src/wayland/weston-launch.c
index 16baabc50..240cfef16 100644
--- a/src/wayland/weston-launch.c
+++ b/src/wayland/weston-launch.c
@@ -80,6 +80,7 @@ struct weston_launch {
struct termios terminal_attributes;
int kb_mode;
enum vt_state vt_state;
+ unsigned vt;
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_activate_vt *message;
+ unsigned vt;
reply.header.opcode = WESTON_LAUNCHER_ACTIVATE_VT;
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;
- 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)
reply.ret = -errno;
@@ -553,7 +561,6 @@ setup_tty(struct weston_launch *wl)
struct termios raw_attributes;
struct vt_mode mode = { 0 };
char *session;
- unsigned vt;
char path[PATH_MAX];
int ok;
@@ -561,11 +568,11 @@ setup_tty(struct weston_launch *wl)
if (ok < 0)
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)
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);
if (wl->tty < 0)
diff --git a/src/wayland/weston-launch.h b/src/wayland/weston-launch.h
index 74e6c3be6..968dd7416 100644
--- a/src/wayland/weston-launch.h
+++ b/src/wayland/weston-launch.h
@@ -53,7 +53,7 @@ struct weston_launcher_open {
struct weston_launcher_activate_vt {
struct weston_launcher_message header;
- int vt;
+ signed char vt;
};
struct weston_launcher_reply {