diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2018-03-08 17:55:23 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2018-04-12 14:22:33 +0800 |
commit | 8473bb6316ba481036d2458825849dff6c61710d (patch) | |
tree | 12670c10877a2234a451ad8aaaad3c28cb863838 | |
parent | dce7a8aae105a1f3b94822a2d7087c715610cb39 (diff) | |
download | fbterm-8473bb6316ba481036d2458825849dff6c61710d.tar.gz fbterm-8473bb6316ba481036d2458825849dff6c61710d.zip |
input: move VT setup to input layer
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | src/fbterm.cpp | 11 | ||||
-rw-r--r-- | src/input.cpp | 18 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/fbterm.cpp b/src/fbterm.cpp index 2320ee2..0368eeb 100644 --- a/src/fbterm.cpp +++ b/src/fbterm.cpp @@ -21,10 +21,8 @@ #include <unistd.h> #include <stdio.h> #include <signal.h> -#include <sys/ioctl.h> #include <sys/stat.h> #include <sys/wait.h> -#include <linux/vt.h> #include "config.h" #include "fbterm.h" #include "fbshell.h" @@ -111,14 +109,6 @@ void FbTerm::init() { if (!TtyInput::instance() || !Screen::instance()) return; - struct vt_mode vtm; - vtm.mode = VT_PROCESS; - vtm.waitv = 0; - vtm.relsig = SIGUSR1; - vtm.acqsig = SIGUSR2; - vtm.frsig = 0; - ioctl(STDIN_FILENO, VT_SETMODE, &vtm); - #ifdef HAVE_SIGNALFD sigset_t sigmask; sigemptyset(&sigmask); @@ -190,7 +180,6 @@ void FbTerm::processSignal(u32 signo) Screen::instance()->switchVc(false); TtyInput::instance()->switchVc(false); Mouse::instance()->switchVc(false); - ioctl(STDIN_FILENO, VT_RELDISP, 1); break; case SIGUSR2: diff --git a/src/input.cpp b/src/input.cpp index a623536..b3b4ee6 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -19,6 +19,7 @@ */ #include <unistd.h> +#include <signal.h> #include <stdio.h> #include <string.h> #include <termios.h> @@ -110,6 +111,15 @@ TtyInputVT::TtyInputVT() s32 ret = ::write(STDIN_FILENO, hide_cursor, sizeof(hide_cursor) - 1); ret = ::write(STDIN_FILENO, disable_blank, sizeof(disable_blank) - 1); + + struct vt_mode vtm; + vtm.mode = VT_PROCESS; + vtm.waitv = 0; + vtm.relsig = SIGUSR1; + vtm.acqsig = SIGUSR2; + vtm.frsig = 0; + ioctl(STDIN_FILENO, VT_SETMODE, &vtm); + } TtyInputVT::~TtyInputVT() @@ -141,7 +151,13 @@ void TtyInputVT::switchVc(bool enter) { setupSysKey(!enter); - if (!enter || inited) return; + if (!enter) { + ioctl(STDIN_FILENO, VT_RELDISP, 1); + return; + } + + if (inited) + return; inited = true; tcgetattr(STDIN_FILENO, &oldTm); |