Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ui/ozone/platform/dri/virtual_terminal_manager.cc

Issue 696983002: Remove Virtual Terminal Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove VT* files from dri/BUILD.gn Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/dri/virtual_terminal_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/virtual_terminal_manager.h"
6
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <linux/kd.h>
10 #include <linux/vt.h>
11 #include <sys/ioctl.h>
12 #include <unistd.h>
13
14 #include "base/logging.h"
15
16 namespace ui {
17
18 namespace {
19
20 const char kTTYDevice[] = "/dev/tty1";
21
22 const int kVT = 1;
23
24 } // namespace
25
26 VirtualTerminalManager::VirtualTerminalManager() {
27 // Use the current console.
28 fd_ = open(kTTYDevice, O_RDWR | O_CLOEXEC, 0);
29 if (fd_ < 0)
30 LOG(ERROR) << "Failed to open '" << kTTYDevice << "' " << strerror(errno);
31
32 if (ioctl(fd_, VT_ACTIVATE, kVT) || ioctl(fd_, VT_WAITACTIVE, kVT))
33 LOG(ERROR) << "Failed to switch to VT: " << kVT
34 << " error: " << strerror(errno);;
35
36 if (ioctl(fd_, KDGETMODE, &vt_mode_))
37 LOG(ERROR) << "Failed to get VT mode: " << strerror(errno);
38
39 if (ioctl(fd_, KDSETMODE, KD_GRAPHICS))
40 LOG(ERROR) << "Failed to set graphics mode: " << strerror(errno);
41
42 if (tcgetattr(fd_, &terminal_attributes_))
43 LOG(ERROR) << "Failed to get terminal attributes";
44
45 // Stop the TTY from processing keys and echo-ing them to the terminal.
46 struct termios raw_attributes = terminal_attributes_;
47 cfmakeraw(&raw_attributes);
48 raw_attributes.c_oflag |= OPOST;
49 if (tcsetattr(fd_, TCSANOW, &raw_attributes))
50 LOG(ERROR) << "Failed to set raw attributes";
51
52 if (ioctl(fd_, KDGKBMODE, &previous_keyboard_mode_))
53 LOG(ERROR) << "Failed to get keyboard mode";
54
55 if (ioctl(fd_, KDSKBMODE, K_OFF) && ioctl(fd_, KDSKBMODE, K_RAW))
56 LOG(ERROR) << "Failed to set keyboard mode";
57 }
58
59 VirtualTerminalManager::~VirtualTerminalManager() {
60 if (fd_ < 0)
61 return;
62
63 if (ioctl(fd_, KDSETMODE, &vt_mode_))
64 LOG(ERROR) << "Failed to restore VT mode";
65
66 if (ioctl(fd_, KDSKBMODE, previous_keyboard_mode_))
67 LOG(ERROR) << "Failed to restore keyboard mode";
68
69 if (tcsetattr(fd_, TCSANOW, &terminal_attributes_))
70 LOG(ERROR) << "Failed to restore terminal attributes";
71
72 close(fd_);
73 }
74
75 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/virtual_terminal_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698