-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.h
54 lines (41 loc) · 1.25 KB
/
common.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
#ifndef COMMON_H
#define COMMON_H
// QCursor must be include before X.h (XInput2.h)
#include <QCursor>
#include <QString>
#include <QDebug>
#include <X11/extensions/XInput2.h>
/* Return 1 if XI2 is available, 0 otherwise */
static int has_xi2(Display *dpy)
{
int major, minor;
int rc;
/* We support XI 2.2 */
major = 2;
minor = 2;
rc = XIQueryVersion(dpy, &major, &minor);
if (rc == BadRequest) {
qDebug() << (QString("No XI2 support. Server supports version %d.%d only.")
.arg(major).arg(minor));
return 0;
} else if (rc != Success) {
qDebug() << "Internal Error! This is a bug in Xlib.";
}
qDebug() << (QString("XI2 supported. Server provides version %d.%d.")
.arg(major).arg(minor));
return 1;
}
static void select_events(Display *dpy, Window win)
{
XIEventMask evmasks[1];
unsigned char mask1[(XI_LASTEVENT + 7)/8];
memset(mask1, 0, sizeof(mask1));
/* select for button and key events from all master devices */
XISetMask(mask1, XI_RawMotion);
evmasks[0].deviceid = XIAllMasterDevices;
evmasks[0].mask_len = sizeof(mask1);
evmasks[0].mask = mask1;
XISelectEvents(dpy, win, evmasks, 1);
XFlush(dpy);
}
#endif // COMMON_H