Qt 4.8
qeventdispatcher_qws.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 QtGui module 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 
42 #include "qplatformdefs.h"
43 #include "qapplication.h"
44 #include "private/qwscommand_qws_p.h"
45 #include "qwsdisplay_qws.h"
46 #include "qwsevent_qws.h"
47 #include "qwindowsystem_qws.h"
48 #include "qeventdispatcher_qws_p.h"
49 #include "private/qeventdispatcher_unix_p.h"
50 #ifndef QT_NO_THREAD
51 # include "qmutex.h"
52 #endif
53 
54 #include <errno.h>
55 
57 
59 
61 {
63 public:
65  { }
67 };
68 
69 
72 { }
73 
75 { }
76 
77 
78 
79 // from qapplication_qws.cpp
80 extern QWSDisplay* qt_fbdpy; // QWS `display'
81 
82 //#define ZERO_FOR_THE_MOMENT
83 
84 bool QEventDispatcherQWS::processEvents(QEventLoop::ProcessEventsFlags flags)
85 {
87  // process events from the QWS server
88  int nevents = 0;
89 
90  // handle gui and posted events
91  d->interrupt = false;
93 
94  while (!d->interrupt) { // also flushes output buffer ###can be optimized
95  QWSEvent *event;
97  && !d->queuedUserInputEvents.isEmpty()) {
98  // process a pending user input event
99  event = d->queuedUserInputEvents.takeFirst();
100  } else if (qt_fbdpy->eventPending()) {
101  event = qt_fbdpy->getEvent(); // get next event
102  if (flags & QEventLoop::ExcludeUserInputEvents) {
103  // queue user input events
104  if (event->type == QWSEvent::Mouse || event->type == QWSEvent::Key) {
105  d->queuedUserInputEvents.append(event);
106  continue;
107  }
108  }
109  } else {
110  break;
111  }
112 
113  if (filterEvent(event)) {
114  delete event;
115  continue;
116  }
117  nevents++;
118 
119  bool ret = qApp->qwsProcessEvent(event) == 1;
120  delete event;
121  if (ret) {
122  return true;
123  }
124  }
125 
126  if (!d->interrupt) {
128  if (!qt_get_server_queue()->isEmpty()) {
130  }
131 
133  return true;
134  }
135  return (nevents > 0);
136 }
137 
139 {
140  extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
141  return qGlobalPostedEventsCount() || qt_fbdpy->eventPending();
142 }
143 
145 {
146 
147 }
148 
150 {
151 
152 }
153 
155 {
156  if(qApp)
157  qApp->sendPostedEvents();
158  (void)qt_fbdpy->eventPending(); // flush
159 }
160 
161 
162 int QEventDispatcherQWS::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
163  timeval *timeout)
164 {
165  return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
166 }
167 
double d
Definition: qnumeric_p.h:62
The QWSDisplay class provides a display for QWS; it is an internal class.
bool filterEvent(void *message)
Sends message through the event filter that was set by setEventFilter().
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QWSDisplay * qt_fbdpy
QList< QWSCommand * > * qt_get_server_queue()
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout)
bool eventPending() const
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
static void processEventQueue()
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool isEmpty(const char *str)
#define qApp
bool hasPendingEvents()
Returns true if there is an event waiting; otherwise returns false.
unsigned int uint
Definition: qglobal.h:996
static void sendPostedEvents()
Q_CORE_EXPORT uint qGlobalPostedEventsCount()
QWSEvent * getEvent()
bool processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
void flush()
Flushes the event queue.
bool processEvents(QEventLoop::ProcessEventsFlags flags)
Processes pending events that match flags until there are no more events to process.
virtual int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout)
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
Definition: qglobal.h:88
QObject * parent
Definition: qobject.h:92
QList< QWSEvent * > queuedUserInputEvents
QEventDispatcherQWS(QObject *parent=0)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62