qfbvthandler.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/fbconvenience/qfbvthandler.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13static 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; *
*devDescription
TRUEnever evaluated
FALSEnever evaluated
dev
*devDescription
TRUEnever evaluated
FALSEnever evaluated
; ++dev) {
0
18 fd = qt_safe_open(*dev, 02);-
19 if (fd != -1
fd != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
20-
21 const char *termctl = enable
enableDescription
TRUEnever evaluated
FALSEnever evaluated
? "\033[9;15]\033[?33h\033[?25h\033[?0c" : "\033[9;0]\033[?33l\033[?25l\033[?1c";
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-
31static QFbVtHandler *vth;-
32-
33void 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-
40QFbVtHandler::QFbVtHandler(QObject *parent)-
41 : QObject(parent),-
42 m_tty(-1),-
43 m_signalNotifier(0)-
44{-
45-
46 if (isatty(0)
isatty(0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
47 m_tty = 0;
never executed: m_tty = 0;
0
48-
49 if (::
::socketpair(1...M, 0, m_sigFd)Description
TRUEnever evaluated
FALSEnever evaluated
socketpair(1, SOCK_STREAM, 0, m_sigFd)
::socketpair(1...M, 0, m_sigFd)Description
TRUEnever evaluated
FALSEnever evaluated
) {
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")
!qEnvironmentV...GNAL_HANDLER")Description
TRUEnever evaluated
FALSEnever evaluated
) {
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-
74QFbVtHandler::~QFbVtHandler()-
75{-
76-
77 setKeyboardEnabled(true);-
78 setTTYCursor(true);-
79-
80 if (m_signalNotifier
m_signalNotifierDescription
TRUEnever evaluated
FALSEnever evaluated
) {
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-
87void QFbVtHandler::setKeyboardEnabled(bool enable)-
88{-
89-
90 if (m_tty == -1
m_tty == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
91 return;
never executed: return;
0
92-
93 if (enable
enableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
94 ::ioctl(m_tty, 0x4B51, 0);-
95 ::ioctl(m_tty, 0x4B45, m_oldKbdMode);-
96 }
never executed: end of block
else {
0
97 ::ioctl(m_tty, 0x4B44, &m_oldKbdMode);-
98 if (!qEnvironmentVariableIntValue("QT_QPA_ENABLE_TERMINAL_KEYBOARD")
!qEnvironmentV...NAL_KEYBOARD")Description
TRUEnever evaluated
FALSEnever evaluated
) {
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-
108void 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)
qt_safe_read(m... sizeof(sigNo)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 switch (sigNo) {-
116 case
never executed: case 2:
2:
never executed: case 2:
0
117 case
never executed: case 15:
15:
never executed: case 15:
0
118 handleInt();-
119 break;
never executed: break;
0
120 case
never executed: case 20:
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: case 18:
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-
140void 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 codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9