Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpadx/src/backends/x11/xrecordkeyboardmonitor.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #ifndef XRECORDKEYBOARDMONITOR_H | ||||
20 | #define XRECORDKEYBOARDMONITOR_H | ||||
21 | | ||||
22 | #include <QVector> | ||||
23 | #include <QSocketNotifier> | ||||
24 | #include <QX11Info> | ||||
25 | | ||||
26 | #include <xcb/xcb.h> | ||||
27 | #include <xcb/record.h> | ||||
28 | | ||||
29 | class XRecordKeyboardMonitor : public QObject | ||||
30 | { | ||||
31 | Q_OBJECT | ||||
32 | | ||||
33 | public: | ||||
34 | XRecordKeyboardMonitor(Display *display); | ||||
35 | ~XRecordKeyboardMonitor(); | ||||
36 | | ||||
37 | Q_SIGNALS: | ||||
38 | void keyboardActivityStarted(); | ||||
39 | void keyboardActivityFinished(); | ||||
40 | | ||||
41 | private Q_SLOTS: | ||||
42 | void processNextReply(); | ||||
43 | | ||||
44 | private: | ||||
45 | void process(xcb_record_enable_context_reply_t *reply); | ||||
46 | bool activity() const { return m_keysPressed && !m_modifiersPressed; } | ||||
47 | | ||||
48 | QSocketNotifier *m_notifier; | ||||
49 | xcb_connection_t *m_connection; | ||||
50 | xcb_record_context_t m_context; | ||||
51 | xcb_record_enable_context_cookie_t m_cookie; | ||||
52 | | ||||
53 | QVector<bool> m_modifier, m_ignore, m_pressed; | ||||
54 | int m_modifiersPressed, m_keysPressed; | ||||
55 | }; | ||||
56 | | ||||
57 | #endif // XRECORDKEYBOARDMONITOR_H |