Qt 4.8
qwindowsysteminterface_qpa.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 ****************************************************************************/
43 #include "qapplication_p.h"
44 #include <QAbstractEventDispatcher>
45 #include <private/qlocale_p.h>
46 
48 
49 
51 
52 //------------------------------------------------------------
53 //
54 // Callback functions for plugins:
55 //
56 
59 
61 
62 
64 {
65  if (tlw) {
67  if (data->in_destructor)
68  return;
69 
72  }
73 }
74 
76 {
77  if (tlw) {
79  if (data->in_destructor)
80  return;
81  }
84 }
85 
87 {
90 }
91 
93 {
97 }
98 
100 {
101  if (tlw) {
103  if (data->in_destructor)
104  return;
105  }
108 }
109 
110 
112 {
113  if (tlw) {
117  }
118 }
119 
126 void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
127  unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
128  handleMouseEvent(w, time, local, global, b);
129 }
130 
131 void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
132 {
133  if (tlw) {
135  if (data->in_destructor)
136  tlw = 0;
137  }
139  new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b);
141 }
142 
143 void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
144  unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
145  handleKeyEvent(w, time, t, k, mods, text, autorep, count);
146 }
147 
148 void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
149 {
150  if (tlw) {
152  if (data->in_destructor)
153  tlw = 0;
154  }
155 
157  new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
159 }
160 
161 void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
162  quint32 nativeScanCode, quint32 nativeVirtualKey,
163  quint32 nativeModifiers,
164  const QString& text, bool autorep,
165  ushort count)
166 {
167  unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
168  handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
169  text, autorep, count);
170 }
171 
173  Qt::KeyboardModifiers modifiers,
174  quint32 nativeScanCode, quint32 nativeVirtualKey,
175  quint32 nativeModifiers,
176  const QString& text, bool autorep,
177  ushort count)
178 {
179  if (tlw) {
181  if (data->in_destructor)
182  tlw = 0;
183  }
184 
186  new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
187  nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
189 }
190 
191 void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
192  unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
193  handleWheelEvent(w, time, local, global, d, o);
194 }
195 
196 void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
197 {
198  if (tlw) {
200  if (data->in_destructor)
201  tlw = 0;
202  }
203 
205  new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o);
207 }
208 
210 {
211  queueMutex.lock();
212  int ret = windowSystemEventQueue.count();
213  queueMutex.unlock();
214  return ret;
215 }
216 
218 {
219  queueMutex.lock();
221  if (windowSystemEventQueue.isEmpty())
222  ret = 0;
223  else
224  ret = windowSystemEventQueue.takeFirst();
225  queueMutex.unlock();
226  return ret;
227 }
228 
230 {
231  queueMutex.lock();
232  windowSystemEventQueue.append(ev);
233  queueMutex.unlock();
234 
235  QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher();
236  if (dispatcher)
237  dispatcher->wakeUp();
238 }
239 
241  unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
242  handleTouchEvent(w, time, type, devType, points);
243 }
244 
246 {
247  if (!points.size()) // Touch events must have at least one point
248  return;
249 
250  QList<QTouchEvent::TouchPoint> touchPoints;
251  Qt::TouchPointStates states;
253 
256  while (point != end) {
257  p.setId(point->id);
258  p.setPressure(point->pressure);
259  states |= point->state;
260  Qt::TouchPointStates state = point->state;
261  if (point->isPrimary) {
262  state |= Qt::TouchPointPrimary;
263  }
264  p.setState(state);
265  p.setRect(point->area);
266  p.setScreenPos(point->area.center());
267  p.setNormalizedPos(point->normalPosition);
268 
269  touchPoints.append(p);
270  ++point;
271  }
272 
274  new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, devType, touchPoints);
276 }
277 
279 {
283 }
284 
286 {
290 }
291 
293 {
297 }
298 
300 {
303 
306 }
307 
309 {
313 }
314 
static void updateSystemPrivate()
Definition: qlocale.cpp:478
double d
Definition: qnumeric_p.h:62
void setScreenPos(const QPointF &screenPos)
Definition: qevent.cpp:4695
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
void setRect(const QRectF &rect)
Definition: qevent.cpp:4775
static void handleWheelEvent(QWidget *w, const QPoint &local, const QPoint &global, int d, Qt::Orientation o)
static void handleScreenAvailableGeometryChange(int screenIndex)
static void handleScreenGeometryChange(int screenIndex)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setNormalizedPos(const QPointF &normalizedPos)
Definition: qevent.cpp:4703
DeviceType
This enum represents the type of device that generated a QTouchEvent.
Definition: qevent.h:805
static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList< struct TouchPoint > &points)
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static QList< WindowSystemEvent * > windowSystemEventQueue
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static void handleWindowActivated(QWidget *w)
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static const char * data(const QByteArray &arr)
static void queueWindowSystemEvent(WindowSystemEvent *ev)
static void handleCloseEvent(QWidget *w)
virtual void wakeUp()=0
Wakes up the event loop.
unsigned long ulong
Definition: qglobal.h:997
static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static void handleWindowStateChanged(QWidget *w, Qt::WindowState newState)
void setId(int id)
Definition: qevent.cpp:4663
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
static WindowSystemEvent * getWindowSystemEvent()
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static void handlePlatformPanelEvent(QWidget *w)
unsigned short ushort
Definition: qglobal.h:995
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static void handleGeometryChange(QWidget *w, const QRect &newRect)
void setPressure(qreal pressure)
Definition: qevent.cpp:4799
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
uint in_destructor
Definition: qwidget.h:129
QPointer< QWidget > qt_last_mouse_receiver
static void handleScreenCountChange(int count)
static const KeyPair *const end
Orientation
Definition: qnamespace.h:174
Q_GUI_EXPORT QWidgetData * qt_qwidget_data(QWidget *widget)
Definition: qwidget.cpp:12915
static void handleEnterEvent(QWidget *w)
WindowState
Definition: qnamespace.h:366
static void handleLeaveEvent(QWidget *w)
The QAbstractEventDispatcher class provides an interface to manage Qt&#39;s event queue.
#define text
Definition: qobjectdefs.h:80
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272