blob: bc92d0ece7361db134acb1771f572dcab7317ce9 (
plain)
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
72
73
74
75
76
77
78
|
#include "qopenkodeeventloopintegration.h"
#include <QDebug>
#include <KD/kd.h>
#include <KD/ATX_keyboard.h>
QT_BEGIN_NAMESPACE
static const int QT_EVENT_WAKEUP_EVENTLOOP = KD_EVENT_USER + 1;
void kdprocessevent( const KDEvent *event)
{
switch (event->type) {
case KD_EVENT_INPUT:
qDebug() << "KD_EVENT_INPUT";
break;
case KD_EVENT_INPUT_POINTER:
qDebug() << "KD_EVENT_INPUT_POINTER";
break;
case KD_EVENT_WINDOW_CLOSE:
qDebug() << "KD_EVENT_WINDOW_CLOSE";
break;
case KD_EVENT_WINDOWPROPERTY_CHANGE:
qDebug() << "KD_EVENT_WINDOWPROPERTY_CHANGE";
qDebug() << event->data.windowproperty.pname;
break;
case KD_EVENT_WINDOW_FOCUS:
qDebug() << "KD_EVENT_WINDOW_FOCUS";
break;
case KD_EVENT_WINDOW_REDRAW:
qDebug() << "KD_EVENT_WINDOW_REDRAW";
break;
case KD_EVENT_USER:
qDebug() << "KD_EVENT_USER";
break;
case KD_EVENT_INPUT_KEY_ATX:
qDebug() << "KD_EVENT_INPUT_KEY_ATX";
break;
case QT_EVENT_WAKEUP_EVENTLOOP:
// qDebug() << "QT_EVENT_WAKEUP_EVENTLOOP";
break;
default:
break;
}
kdDefaultEvent(event);
}
QOpenKODEEventLoopIntegration::QOpenKODEEventLoopIntegration()
{
m_kdThread = kdThreadSelf();
kdInstallCallback(&kdprocessevent,QT_EVENT_WAKEUP_EVENTLOOP,this);
}
void QOpenKODEEventLoopIntegration::processEvents(qint64 msec)
{
if (msec == 0)
msec = -1;
const KDEvent *event = kdWaitEvent(msec*1000);
if (event) {
kdDefaultEvent(event);
while ((event = kdWaitEvent(0)) != 0) {
kdDefaultEvent(event);
}
}
}
void QOpenKODEEventLoopIntegration::wakeup()
{
KDEvent *event = kdCreateEvent();
event->type = QT_EVENT_WAKEUP_EVENTLOOP;
event->userptr = this;
kdPostThreadEvent(event,m_kdThread);
}
QT_END_NAMESPACE
|