Qt 4.8
qopenkodeeventloopintegration.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
43 
44 #include <QDebug>
45 
46 #include <KD/kd.h>
47 #include <KD/ATX_keyboard.h>
48 
50 
51 static const int QT_EVENT_WAKEUP_EVENTLOOP = KD_EVENT_USER + 1;
52 
53 void kdprocessevent( const KDEvent *event)
54 {
55  switch (event->type) {
56  case KD_EVENT_INPUT:
57  qDebug() << "KD_EVENT_INPUT";
58  break;
59  case KD_EVENT_INPUT_POINTER:
60  qDebug() << "KD_EVENT_INPUT_POINTER";
61  break;
62  case KD_EVENT_WINDOW_CLOSE:
63  qDebug() << "KD_EVENT_WINDOW_CLOSE";
64  break;
65  case KD_EVENT_WINDOWPROPERTY_CHANGE:
66  qDebug() << "KD_EVENT_WINDOWPROPERTY_CHANGE";
67  qDebug() << event->data.windowproperty.pname;
68  break;
69  case KD_EVENT_WINDOW_FOCUS:
70  qDebug() << "KD_EVENT_WINDOW_FOCUS";
71  break;
72  case KD_EVENT_WINDOW_REDRAW:
73  qDebug() << "KD_EVENT_WINDOW_REDRAW";
74  break;
75  case KD_EVENT_USER:
76  qDebug() << "KD_EVENT_USER";
77  break;
78  case KD_EVENT_INPUT_KEY_ATX:
79  qDebug() << "KD_EVENT_INPUT_KEY_ATX";
80  break;
83  break;
84  default:
85  break;
86  }
87 
88  kdDefaultEvent(event);
89 
90 }
91 
93  : m_quit(false)
94 {
95  m_kdThread = kdThreadSelf();
96  kdInstallCallback(&kdprocessevent,QT_EVENT_WAKEUP_EVENTLOOP,this);
97 }
98 
100 {
101 
102  while(!m_quit) {
103  qint64 msec = nextTimerEvent();
104  const KDEvent *event = kdWaitEvent(msec);
105  if (event) {
106  kdDefaultEvent(event);
107  while ((event = kdWaitEvent(0)) != 0) {
108  kdDefaultEvent(event);
109  }
110  }
112  }
113 }
114 
116 {
117  m_quit = true;
118 }
119 
121 {
122  KDEvent *event = kdCreateEvent();
123  event->type = QT_EVENT_WAKEUP_EVENTLOOP;
124  event->userptr = this;
125  kdPostThreadEvent(event,m_kdThread);
126 }
127 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
__int64 qint64
Definition: qglobal.h:942
static const int QT_EVENT_WAKEUP_EVENTLOOP
void kdprocessevent(const KDEvent *event)