-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmouseEventThread.h
71 lines (59 loc) · 1.66 KB
/
mouseEventThread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef MOUSEEVENTTHREAD_H
#define MOUSEEVENTTHREAD_H
#include <QApplication>
#include <QThread>
#include <QDebug>
#include <QObject>
#include <QX11Info>
#include <QRect>
#include <QPoint>
#include <X11/X.h>
#include <X11/Xlibint.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <X11/cursorfont.h>
#include <X11/keysymdef.h>
#include <X11/keysym.h>
#include <X11/extensions/record.h>
#include <X11/extensions/XTest.h>
#define WheelUp 4
#define WheelDown 5
#define WheelLeft 6
#define WheelRight 7
typedef union {
unsigned char type ;
xEvent event ;
xResourceReq req ;
xGenericReply reply ;
xError error ;
xConnSetupPrefix setup;
} XRecordDatum;
using namespace std;
class MouseEventThread : public QThread {
Q_OBJECT
public:
MouseEventThread(QRect screenRect, int winID, double sensibility, QObject *parent = nullptr);
~MouseEventThread();
static void callback(XPointer closure, XRecordInterceptData* hook);
void processEvent(XRecordInterceptData* hook);
int queryCursor(int &relX, int &relY, int &absX, int &absY);
void setMouseSensibility(double mouseSensibility);
public slots:
void cleanup();
private:
void run() override;
Display *controlDisplay;
Display *dataDisplay;
XRecordContext ctx;
XRecordRange *rr;
Window rootWindow;
Window appWindow;
double sensibility;
// int dx, dy, lastx, lasty = 0;
signals:
void mouseEvent(QPoint relPosition, QPoint rawPosition);
void mousePress(QPoint relPosition, QPoint rawPosition);
void mouseRelease(QPoint relPosition, QPoint rawPosition);
};
#endif // MOUSEEVENTTHREAD_H