5#include <QtCore/QSocketNotifier>
6#include <QtCore/private/qglobal_p.h>
8#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && (QT_CONFIG(evdev) || QT_CONFIG(libinput))
12#include <private/qcore_unix_p.h>
21#define KDSKBMUTE 0x4B51
25#define KBD_OFF_MODE K_OFF
27#define KBD_OFF_MODE K_RAW
35static void setTTYCursor(
bool enable)
37 static bool ignore = qEnvironmentVariableIntValue(
"QT_QPA_PRESERVE_CONSOLE_STATE");
41 const char *
const devs[] = {
"/dev/tty0",
"/dev/tty",
"/dev/console", 0 };
43 for (
const char *
const *dev = devs; *dev; ++dev) {
44 fd = QT_OPEN(*dev, O_RDWR);
47 const char *termctl = enable ?
"\033[9;15]\033[?33h\033[?25h\033[?0c" :
"\033[9;0]\033[?33l\033[?25l\033[?1c";
48 QT_WRITE(fd, termctl, strlen(termctl) + 1);
57static QFbVtHandler *vth;
59void QFbVtHandler::signalHandler(
int sigNo)
62 QT_WRITE(vth->m_sigFd[0], &a,
sizeof(a));
75 if (::socketpair(AF_UNIX, SOCK_STREAM, 0, m_sigFd)) {
76 qErrnoWarning(errno,
"QFbVtHandler: socketpair() failed");
82 setKeyboardEnabled(
false);
84 m_signalNotifier =
new QSocketNotifier(m_sigFd[1], QSocketNotifier::Read,
this);
85 connect(m_signalNotifier, &QSocketNotifier::activated,
this, &QFbVtHandler::handleSignal);
87 if (!qEnvironmentVariableIntValue(
"QT_QPA_NO_SIGNAL_HANDLER")) {
90 sa.sa_handler = signalHandler;
91 sigemptyset(&sa.sa_mask);
92 sigaction(SIGINT, &sa, 0);
93 sigaction(SIGTSTP, &sa, 0);
94 sigaction(SIGCONT, &sa, 0);
95 sigaction(SIGTERM, &sa, 0);
103 setKeyboardEnabled(
true);
106 if (m_signalNotifier) {
120 ::ioctl(m_tty, KDSKBMUTE, 0);
121 ::ioctl(m_tty, KDSKBMODE, m_oldKbdMode);
123 ::ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
124 if (!qEnvironmentVariableIntValue(
"QT_QPA_ENABLE_TERMINAL_KEYBOARD")) {
125 ::ioctl(m_tty, KDSKBMUTE, 1);
126 ::ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
137 m_signalNotifier->setEnabled(
false);
140 if (QT_READ(m_sigFd[1], &sigNo,
sizeof(sigNo)) ==
sizeof(sigNo)) {
147 emit aboutToSuspend();
148 setKeyboardEnabled(
true);
150 ::kill(getpid(), SIGSTOP);
154 setKeyboardEnabled(
false);
162 m_signalNotifier->setEnabled(
true);
170 setKeyboardEnabled(
true);
178#include "moc_qfbvthandler_p.cpp"