| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/platformsupport/fbconvenience/qfbvthandler.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | - | |||||||||||||
| 12 | - | |||||||||||||
| 13 | static void setTTYCursor(bool enable) | - | ||||||||||||
| 14 | { | - | ||||||||||||
| 15 | const char * const devs[] = { "/dev/tty0", "/dev/tty", "/dev/console", 0 }; | - | ||||||||||||
| 16 | int fd = -1; | - | ||||||||||||
| 17 | for (const char * const *dev = devs; *
| 0 | ||||||||||||
| 18 | fd = qt_safe_open(*dev, 02); | - | ||||||||||||
| 19 | if (fd != -1
| 0 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | const char *termctl = enable
| 0 | ||||||||||||
| 22 | qt_safe_write(fd, termctl, strlen(termctl) + 1); | - | ||||||||||||
| 23 | qt_safe_close(fd); | - | ||||||||||||
| 24 | return; never executed: return; | 0 | ||||||||||||
| 25 | } | - | ||||||||||||
| 26 | } never executed: end of block | 0 | ||||||||||||
| 27 | } never executed: end of block | 0 | ||||||||||||
| 28 | - | |||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | static QFbVtHandler *vth; | - | ||||||||||||
| 32 | - | |||||||||||||
| 33 | void QFbVtHandler::signalHandler(int sigNo) | - | ||||||||||||
| 34 | { | - | ||||||||||||
| 35 | char a = sigNo; | - | ||||||||||||
| 36 | qt_safe_write(vth->m_sigFd[0], &a, sizeof(a)); | - | ||||||||||||
| 37 | } never executed: end of block | 0 | ||||||||||||
| 38 | - | |||||||||||||
| 39 | - | |||||||||||||
| 40 | QFbVtHandler::QFbVtHandler(QObject *parent) | - | ||||||||||||
| 41 | : QObject(parent), | - | ||||||||||||
| 42 | m_tty(-1), | - | ||||||||||||
| 43 | m_signalNotifier(0) | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | if (isatty(0)
| 0 | ||||||||||||
| 47 | m_tty = 0; never executed: m_tty = 0; | 0 | ||||||||||||
| 48 | - | |||||||||||||
| 49 | if (::
| 0 | ||||||||||||
| 50 | qErrnoWarning((*__errno_location ()), "QFbVtHandler: socketpair() failed"); | - | ||||||||||||
| 51 | return; never executed: return; | 0 | ||||||||||||
| 52 | } | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | vth = this; | - | ||||||||||||
| 55 | setTTYCursor(false); | - | ||||||||||||
| 56 | setKeyboardEnabled(false); | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | m_signalNotifier = new QSocketNotifier(m_sigFd[1], QSocketNotifier::Read, this); | - | ||||||||||||
| 59 | connect(m_signalNotifier, &QSocketNotifier::activated, this, &QFbVtHandler::handleSignal); | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | if (!qEnvironmentVariableIntValue("QT_QPA_NO_SIGNAL_HANDLER")
| 0 | ||||||||||||
| 62 | struct sigaction sa; | - | ||||||||||||
| 63 | sa.sa_flags = 0; | - | ||||||||||||
| 64 | sa.__sigaction_handler.sa_handler = signalHandler; | - | ||||||||||||
| 65 | sigemptyset(&sa.sa_mask); | - | ||||||||||||
| 66 | sigaction(2, &sa, 0); | - | ||||||||||||
| 67 | sigaction(20, &sa, 0); | - | ||||||||||||
| 68 | sigaction(18, &sa, 0); | - | ||||||||||||
| 69 | sigaction(15, &sa, 0); | - | ||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | } never executed: end of block | 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | QFbVtHandler::~QFbVtHandler() | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | setKeyboardEnabled(true); | - | ||||||||||||
| 78 | setTTYCursor(true); | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | if (m_signalNotifier
| 0 | ||||||||||||
| 81 | close(m_sigFd[0]); | - | ||||||||||||
| 82 | close(m_sigFd[1]); | - | ||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||
| 84 | - | |||||||||||||
| 85 | } never executed: end of block | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | void QFbVtHandler::setKeyboardEnabled(bool enable) | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | if (m_tty == -1
| 0 | ||||||||||||
| 91 | return; never executed: return; | 0 | ||||||||||||
| 92 | - | |||||||||||||
| 93 | if (enable
| 0 | ||||||||||||
| 94 | ::ioctl(m_tty, 0x4B51, 0); | - | ||||||||||||
| 95 | ::ioctl(m_tty, 0x4B45, m_oldKbdMode); | - | ||||||||||||
| 96 | } never executed: else {end of block | 0 | ||||||||||||
| 97 | ::ioctl(m_tty, 0x4B44, &m_oldKbdMode); | - | ||||||||||||
| 98 | if (!qEnvironmentVariableIntValue("QT_QPA_ENABLE_TERMINAL_KEYBOARD")
| 0 | ||||||||||||
| 99 | ::ioctl(m_tty, 0x4B51, 1); | - | ||||||||||||
| 100 | ::ioctl(m_tty, 0x4B45, 0x04); | - | ||||||||||||
| 101 | } never executed: end of block | 0 | ||||||||||||
| 102 | } never executed: end of block | 0 | ||||||||||||
| 103 | - | |||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 | } | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | void QFbVtHandler::handleSignal() | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | m_signalNotifier->setEnabled(false); | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | char sigNo; | - | ||||||||||||
| 114 | if (qt_safe_read(m_sigFd[1], &sigNo, sizeof(sigNo)) == sizeof(sigNo)
| 0 | ||||||||||||
| 115 | switch (sigNo) { | - | ||||||||||||
| 116 | case never executed: 2:case 2:never executed: case 2: | 0 | ||||||||||||
| 117 | case never executed: 15:case 15:never executed: case 15: | 0 | ||||||||||||
| 118 | handleInt(); | - | ||||||||||||
| 119 | break; never executed: break; | 0 | ||||||||||||
| 120 | case never executed: 20:case 20:never executed: case 20: | 0 | ||||||||||||
| 121 | aboutToSuspend(); | - | ||||||||||||
| 122 | setKeyboardEnabled(true); | - | ||||||||||||
| 123 | setTTYCursor(true); | - | ||||||||||||
| 124 | ::kill(getpid(), 19); | - | ||||||||||||
| 125 | break; never executed: break; | 0 | ||||||||||||
| 126 | case never executed: 18:case 18:never executed: case 18: | 0 | ||||||||||||
| 127 | setTTYCursor(false); | - | ||||||||||||
| 128 | setKeyboardEnabled(false); | - | ||||||||||||
| 129 | resumed(); | - | ||||||||||||
| 130 | break; never executed: break; | 0 | ||||||||||||
| 131 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 132 | break; never executed: break; | 0 | ||||||||||||
| 133 | } | - | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | m_signalNotifier->setEnabled(true); | - | ||||||||||||
| 137 | - | |||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||
| 139 | - | |||||||||||||
| 140 | void QFbVtHandler::handleInt() | - | ||||||||||||
| 141 | { | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | interrupted(); | - | ||||||||||||
| 144 | setKeyboardEnabled(true); | - | ||||||||||||
| 145 | setTTYCursor(true); | - | ||||||||||||
| 146 | _exit(1); | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | } never executed: end of block | 0 | ||||||||||||
| 149 | - | |||||||||||||
| 150 | - | |||||||||||||
| Switch to Source code | Preprocessed file |