1 /*
2     SPDX-FileCopyrightText: 2010 Andriy Rysin <rysin@kde.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef XINPUT_HELPER_H_
8 #define XINPUT_HELPER_H_
9 
10 #include "x11_helper.h"
11 
12 #include <X11/Xlib.h>
13 #include <fixx11h.h>
14 
15 class QTimer;
16 class UdevDeviceNotifier;
17 
18 class XInputEventNotifier : public XEventNotifier
19 {
20     Q_OBJECT
21 
22 public:
23     explicit XInputEventNotifier(QWidget *parent = nullptr);
24 
25     void start() override;
26     void stop() override;
27 
28     int registerForNewDeviceEvent(Display *dpy);
29 
30 Q_SIGNALS:
31     void newKeyboardDevice();
32     void newPointerDevice();
33 
34 protected:
35     bool processOtherEvents(xcb_generic_event_t *event) override;
36 
37 private:
38     int getNewDeviceEventType(xcb_generic_event_t *event);
39 
40     int xinputEventType;
41     Display *display;
42     UdevDeviceNotifier *udevNotifier;
43     QTimer *keyboardNotificationTimer;
44     QTimer *mouseNotificationTimer;
45 };
46 
47 #endif /* XINPUT_HELPER_H_ */
48