diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-09-18 23:00:17 -0700 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-09-18 23:00:17 -0700 |
commit | 3f4958755df4507c28a3b638e4ca1f1d5267d693 (patch) | |
tree | aaf9c2bf5b7f5c24909a21094470df0eadc65c3f /src/weston-launch.c | |
parent | 6a7c8492cc5160ab392a82ba6c106b1fada9136d (diff) | |
download | weston-3f4958755df4507c28a3b638e4ca1f1d5267d693.tar.gz |
launcher: Move rest of tty object into struct weston_launcher
The struct weston_launcher object will now either handle tty and vt switching
details in-process (when running weston directly as root) or talk to
the weston-launch process.
Diffstat (limited to 'src/weston-launch.c')
-rw-r--r-- | src/weston-launch.c | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/src/weston-launch.c b/src/weston-launch.c index 05f15c1d..525c61c0 100644 --- a/src/weston-launch.c +++ b/src/weston-launch.c @@ -28,7 +28,6 @@ #include <assert.h> #include <poll.h> #include <errno.h> -#include <termios.h> #include <error.h> #include <getopt.h> @@ -43,7 +42,6 @@ #include <unistd.h> #include <fcntl.h> -#include <termios.h> #include <linux/vt.h> #include <linux/major.h> #include <linux/kd.h> @@ -62,6 +60,10 @@ #define DRM_MAJOR 226 +#ifndef KDSKBMUTE +#define KDSKBMUTE 0x4B51 +#endif + #define MAX_ARGV_SIZE 256 struct weston_launch { @@ -71,7 +73,6 @@ struct weston_launch { int ttynr; int sock[2]; int drm_fd; - struct termios terminal_attributes; int kb_mode; struct passwd *pw; @@ -391,16 +392,13 @@ quit(struct weston_launch *wl, int status) pam_end(wl->ph, err); } - if (ioctl(wl->tty, KDSKBMODE, wl->kb_mode)) + if (ioctl(wl->tty, KDSKBMUTE, 0) && + ioctl(wl->tty, KDSKBMODE, wl->kb_mode)) fprintf(stderr, "failed to restore keyboard mode: %m\n"); if (ioctl(wl->tty, KDSETMODE, KD_TEXT)) fprintf(stderr, "failed to set KD_TEXT mode on tty: %m\n"); - if (tcsetattr(wl->tty, TCSANOW, &wl->terminal_attributes) < 0) - fprintf(stderr, - "could not restore terminal to canonical mode\n"); - mode.mode = VT_AUTO; if (ioctl(wl->tty, VT_SETMODE, &mode) < 0) fprintf(stderr, "could not reset vt handling\n"); @@ -464,11 +462,9 @@ handle_signal(struct weston_launch *wl) static int setup_tty(struct weston_launch *wl, const char *tty) { - struct termios raw_attributes; struct stat buf; struct vt_mode mode = { 0 }; char *t; - int ret; if (!wl->new_user) { wl->tty = STDIN_FILENO; @@ -506,28 +502,14 @@ setup_tty(struct weston_launch *wl, const char *tty) wl->ttynr = minor(buf.st_rdev); } - if (tcgetattr(wl->tty, &wl->terminal_attributes) < 0) - error(1, errno, "could not get terminal attributes: %m\n"); + if (ioctl(wl->tty, KDGKBMODE, &wl->kb_mode)) + error(1, errno, "failed to get current keyboard mode: %m\n"); - /* Ignore control characters and disable echo */ - raw_attributes = wl->terminal_attributes; - cfmakeraw(&raw_attributes); + if (ioctl(wl->tty, KDSKBMUTE, 1) && + ioctl(wl->tty, KDSKBMODE, K_OFF)) + error(1, errno, "failed to set K_OFF keyboard mode: %m\n"); - /* Fix up line endings to be normal (cfmakeraw hoses them) */ - raw_attributes.c_oflag |= OPOST | OCRNL; - - if (tcsetattr(wl->tty, TCSANOW, &raw_attributes) < 0) - error(1, errno, "could not put terminal into raw mode: %m\n"); - - ioctl(wl->tty, KDGKBMODE, &wl->kb_mode); - ret = ioctl(wl->tty, KDSKBMODE, K_OFF); - if (ret) - ret = ioctl(wl->tty, KDSKBMODE, K_RAW); - if (ret) - error(1, errno, "failed to set keyboard mode on tty: %m\n"); - - ret = ioctl(wl->tty, KDSETMODE, KD_GRAPHICS); - if (ret) + if (ioctl(wl->tty, KDSETMODE, KD_GRAPHICS)) error(1, errno, "failed to set KD_GRAPHICS mode on tty: %m\n"); mode.mode = VT_PROCESS; @@ -597,9 +579,7 @@ launch_compositor(struct weston_launch *wl, int argc, char *argv[]) drop_privileges(wl); - if (wl->tty != STDIN_FILENO) - setenv_fd("WESTON_TTY_FD", wl->tty); - + setenv_fd("WESTON_TTY_FD", wl->tty); setenv_fd("WESTON_LAUNCHER_SOCK", wl->sock[1]); unsetenv("DISPLAY"); |