Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
HookUnixNativeEventFilter.cpp
1#include "HookUnixNativeEventFilter.h"
2#include "xcb/xcb.h"
3
4#include <QApplication>
5#include <QLoggingCategory>
6
7static Q_LOGGING_CATEGORY(log, "Client.Hook.Unix")
8
10{
11
12}
13
14void
15print_modifiers (uint32_t mask)
16{
17 const char **mod, *mods[] = {
18 "Shift", "Lock", "Ctrl", "Alt",
19 "Mod2", "Mod3", "Mod4", "Mod5",
20 "Button1", "Button2", "Button3", "Button4", "Button5"
21 };
22 qDebug() << "Modifier mask: ";
23 for (mod = mods ; mask; mask >>= 1, mod++)
24 if (mask & 1)
25 qDebug() << *mod;
26 putchar ('\n');
27}
28
29#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
30bool CHookUnixNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
31#else
32bool CHookUnixNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
33#endif
34{
35 qDebug(log) << "CClient::nativeEventFilter:" << eventType;
36 if (eventType == "xcb_generic_event_t") {
37 xcb_generic_event_t* e = static_cast<xcb_generic_event_t *>(message);
38 switch (e->response_type & ~0x80) {
39 case XCB_KEY_PRESS: {
40 xcb_key_press_event_t *ev = (xcb_key_press_event_t *)e;
41 print_modifiers(ev->state);
42
43 qDebug("Key [%ld] pressed in window %ld\n",
44 ev->detail,
45 ev->event);
46 break;
47 }
48 case XCB_KEY_RELEASE: {
49 xcb_key_release_event_t *ev = (xcb_key_release_event_t *)e;
50 print_modifiers(ev->state);
51
52 qDebug ("Key released in window %ld\n",
53 ev->event);
54 break;
55 }
56 }
57 }
58 return false;
59}