1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifndef MUMBLE_MUMBLE_GLOBALSHORTCUT_UNIX_H_
7 #define MUMBLE_MUMBLE_GLOBALSHORTCUT_UNIX_H_
8 
9 #include "GlobalShortcut.h"
10 #include "ConfigDialog.h"
11 #include "Global.h"
12 
13 #include <X11/X.h>
14 #include <X11/Xlib.h>
15 #ifndef NO_XINPUT2
16 #include <X11/extensions/XI2.h>
17 #include <X11/extensions/XInput2.h>
18 #endif
19 #include <X11/Xutil.h>
20 #ifdef Q_OS_LINUX
21 #include <linux/input.h>
22 #include <fcntl.h>
23 #endif
24 
25 #define NUM_BUTTONS 0x2ff
26 
27 class GlobalShortcutX : public GlobalShortcutEngine {
28 	private:
29 		Q_OBJECT
30 		Q_DISABLE_COPY(GlobalShortcutX)
31 	public:
32 		Display *display;
33 		QSet<Window> qsRootWindows;
34 		int iXIopcode;
35 		QSet<int> qsMasterDevices;
36 
37 		volatile bool bRunning;
38 		QSet<QString> qsKeyboards;
39 		QMap<QString, QFile *> qmInputDevices;
40 
41 		GlobalShortcutX();
42 		~GlobalShortcutX() Q_DECL_OVERRIDE;
43 		void run() Q_DECL_OVERRIDE;
44 		QString buttonName(const QVariant &) Q_DECL_OVERRIDE;
45 
46 		void queryXIMasterList();
47 	public slots:
48 		void displayReadyRead(int);
49 		void inputReadyRead(int);
50 		void directoryChanged(const QString &);
51 };
52 
53 #endif
54