1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
41 #include "qwindowsysteminterface.h"
42 #include <qpa/qplatformwindow.h>
43 #include "qwindowsysteminterface_p.h"
44 #include "private/qguiapplication_p.h"
45 #include "private/qevent_p.h"
46 #include "private/qtouchdevice_p.h"
47 #include <QAbstractEventDispatcher>
48 #include <qpa/qplatformdrag.h>
54 QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
55 bool QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = false;
57 //------------------------------------------------------------
59 // Callback functions for plugins:
62 QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePrivate::windowSystemEventQueue;
64 extern QPointer<QWindow> qt_last_mouse_receiver;
67 \class QWindowSystemInterface
72 \brief The QWindowSystemInterface provides an event queue for the QPA platform.
74 The platform plugins call the various functions to notify about events. The events are queued
75 until sendWindowSystemEvents() is called by the event dispatcher.
78 void QWindowSystemInterface::handleEnterEvent(QWindow *tlw, const QPointF &local, const QPointF &global)
81 QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw, local, global);
82 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
86 void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
88 QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
89 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
93 This method can be used to ensure leave and enter events are both in queue when moving from
94 one QWindow to another. This allows QWindow subclasses to check for a queued enter event
95 when handling the leave event (\c QWindowSystemInterfacePrivate::peekWindowSystemEvent) to
96 determine where mouse went and act accordingly. E.g. QWidgetWindow needs to know if mouse
97 cursor moves between windows in same window hierarchy.
99 void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global)
101 bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents;
103 setSynchronousWindowsSystemEvents(false);
104 handleLeaveEvent(leave);
105 handleEnterEvent(enter, local, global);
106 if (wasSynchronous) {
107 flushWindowSystemEvents();
108 setSynchronousWindowsSystemEvents(true);
112 void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
114 QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
115 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
118 void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowState newState)
120 QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
121 new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);
122 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
125 void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
127 QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
128 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
131 void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
134 QWindowSystemInterfacePrivate::CloseEvent *e =
135 new QWindowSystemInterfacePrivate::CloseEvent(tlw);
136 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
142 \a w == 0 means that the event is in global coords only, \a local will be ignored in this case
145 void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
147 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
148 handleMouseEvent(w, time, local, global, b, mods);
151 void QWindowSystemInterface::handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
153 QWindowSystemInterfacePrivate::MouseEvent * e =
154 new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp, local, global, b, mods);
155 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
158 void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
160 const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
161 handleFrameStrutMouseEvent(w, time, local, global, b, mods);
164 void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
166 QWindowSystemInterfacePrivate::MouseEvent * e =
167 new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp,
168 QWindowSystemInterfacePrivate::FrameStrutMouse,
169 local, global, b, mods);
170 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
173 bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
174 const QString & text, bool autorep, ushort count)
176 unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
177 return tryHandleShortcutEvent(w, timestamp, k, mods, text, autorep, count);
180 bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
181 const QString & text, bool autorep, ushort count)
183 #ifndef QT_NO_SHORTCUT
184 QGuiApplicationPrivate::modifier_buttons = mods;
186 QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count);
187 qevent.setTimestamp(timestamp);
188 return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent);
201 bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
202 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
203 const QString &text, bool autorep, ushort count)
205 unsigned long timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
206 return tryHandleExtendedShortcutEvent(w, timestamp, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
209 bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
210 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
211 const QString &text, bool autorep, ushort count)
213 #ifndef QT_NO_SHORTCUT
214 QGuiApplicationPrivate::modifier_buttons = mods;
216 QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
217 qevent.setTimestamp(timestamp);
218 return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent);
224 Q_UNUSED(nativeScanCode)
225 Q_UNUSED(nativeVirtualKey)
226 Q_UNUSED(nativeModifiers)
235 void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
236 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
237 handleKeyEvent(w, time, t, k, mods, text, autorep, count);
240 void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
242 QWindowSystemInterfacePrivate::KeyEvent * e =
243 new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
244 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
247 void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
248 quint32 nativeScanCode, quint32 nativeVirtualKey,
249 quint32 nativeModifiers,
250 const QString& text, bool autorep,
253 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
254 handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
255 text, autorep, count);
258 void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
259 Qt::KeyboardModifiers modifiers,
260 quint32 nativeScanCode, quint32 nativeVirtualKey,
261 quint32 nativeModifiers,
262 const QString& text, bool autorep,
265 QWindowSystemInterfacePrivate::KeyEvent * e =
266 new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
267 nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
268 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
271 void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) {
272 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
273 handleWheelEvent(w, time, local, global, d, o, mods);
276 void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods)
278 QPoint point = (o == Qt::Vertical) ? QPoint(0, d) : QPoint(d, 0);
279 handleWheelEvent(tlw, timestamp, local, global, QPoint(), point, mods);
282 void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
284 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
285 handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods);
288 void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
290 // Qt 4 sends two separate wheel events for horizontal and vertical
291 // deltas. For Qt 5 we want to send the deltas in one event, but at the
292 // same time preserve source and behavior compatibility with Qt 4.
294 // In addition high-resolution pixel-based deltas are also supported.
295 // Platforms that does not support these may pass a null point here.
296 // Angle deltas must always be sent in addition to pixel deltas.
297 QWindowSystemInterfacePrivate::WheelEvent *e;
299 if (angleDelta.isNull())
302 // Simple case: vertical deltas only:
303 if (angleDelta.y() != 0 && angleDelta.x() == 0) {
304 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
305 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
309 // Simple case: horizontal deltas only:
310 if (angleDelta.y() == 0 && angleDelta.x() != 0) {
311 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods);
312 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
316 // Both horizontal and vertical deltas: Send two wheel events.
317 // The first event contains the Qt 5 pixel and angle delta as points,
318 // and in addition the Qt 4 compatibility vertical angle delta.
319 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
320 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
322 // The second event contains null pixel and angle points and the
323 // Qt 4 compatibility horizontal angle delta.
324 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods);
325 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
329 QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *exposed, const QRegion ®ion)
330 : WindowSystemEvent(Expose)
332 , isExposed(exposed && exposed->handle() ? exposed->handle()->isExposed() : false)
337 int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
339 return windowSystemEventQueue.count();
342 QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
344 return windowSystemEventQueue.takeFirstOrReturnNull();
347 QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent()
349 return windowSystemEventQueue.takeFirstNonUserInputOrReturnNull();
352 QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)
354 return windowSystemEventQueue.peekAtFirstOfType(t);
357 void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *event)
359 windowSystemEventQueue.remove(event);
362 void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
364 if (synchronousWindowsSystemEvents) {
365 QGuiApplicationPrivate::processWindowSystemEvent(ev);
367 windowSystemEventQueue.append(ev);
368 QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
370 dispatcher->wakeUp();
374 void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device)
376 QTouchDevicePrivate::registerDevice(device);
379 void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device,
380 const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
382 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
383 handleTouchEvent(w, time, device, points, mods);
386 QList<QTouchEvent::TouchPoint> QWindowSystemInterfacePrivate::convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type)
388 QList<QTouchEvent::TouchPoint> touchPoints;
389 Qt::TouchPointStates states;
390 QTouchEvent::TouchPoint p;
392 QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin();
393 QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();
394 while (point != end) {
396 p.setPressure(point->pressure);
397 states |= point->state;
398 p.setState(point->state);
400 const QPointF screenPos = point->area.center();
401 p.setScreenPos(screenPos);
402 p.setScreenRect(point->area);
404 // The local pos and rect are not set, they will be calculated
405 // when the event gets processed by QGuiApplication.
407 p.setNormalizedPos(point->normalPosition);
408 p.setVelocity(point->velocity);
409 p.setFlags(point->flags);
410 p.setRawScreenPositions(point->rawPositions);
412 touchPoints.append(p);
416 // Determine the event type based on the combined point states.
418 *type = QEvent::TouchUpdate;
419 if (states == Qt::TouchPointPressed)
420 *type = QEvent::TouchBegin;
421 else if (states == Qt::TouchPointReleased)
422 *type = QEvent::TouchEnd;
428 void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device,
429 const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
431 if (!points.size()) // Touch events must have at least one point
434 if (!QTouchDevicePrivate::isRegistered(device)) // Disallow passing bogus, non-registered devices.
438 QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::convertTouchPoints(points, &type);
440 QWindowSystemInterfacePrivate::TouchEvent *e =
441 new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods);
442 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
445 void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device,
446 Qt::KeyboardModifiers mods)
448 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
449 handleTouchCancelEvent(w, time, device, mods);
452 void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
453 Qt::KeyboardModifiers mods)
455 QWindowSystemInterfacePrivate::TouchEvent *e =
456 new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device,
457 QList<QTouchEvent::TouchPoint>(), mods);
458 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
461 void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)
463 QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =
464 new QWindowSystemInterfacePrivate::ScreenOrientationEvent(screen, orientation);
465 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
468 void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const QRect &geometry)
470 QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
471 new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screen, geometry);
472 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
475 void QWindowSystemInterface::handleScreenAvailableGeometryChange(QScreen *screen, const QRect &availableGeometry)
477 QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e =
478 new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screen, availableGeometry);
479 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
482 void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal dpiX, qreal dpiY)
484 QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e =
485 new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, dpiX, dpiY);
486 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
489 void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate)
491 QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e =
492 new QWindowSystemInterfacePrivate::ScreenRefreshRateEvent(screen, newRefreshRate);
493 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
496 void QWindowSystemInterface::handleThemeChange(QWindow *tlw)
498 QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(tlw);
499 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
502 void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion ®ion)
504 QWindowSystemInterfacePrivate::ExposeEvent *e = new QWindowSystemInterfacePrivate::ExposeEvent(tlw, region);
505 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
508 void QWindowSystemInterface::flushWindowSystemEvents()
510 sendWindowSystemEventsImplementation(QEventLoop::AllEvents);
513 bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
515 QCoreApplication::sendPostedEvents(); // handle gui and posted events
516 return sendWindowSystemEventsImplementation(flags);
519 void QWindowSystemInterface::setSynchronousWindowsSystemEvents(bool enable)
521 QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents = enable;
524 bool QWindowSystemInterface::sendWindowSystemEventsImplementation(QEventLoop::ProcessEventsFlags flags)
528 while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
529 QWindowSystemInterfacePrivate::WindowSystemEvent *event =
530 (flags & QEventLoop::ExcludeUserInputEvents) ?
531 QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() :
532 QWindowSystemInterfacePrivate::getWindowSystemEvent();
536 QGuiApplicationPrivate::processWindowSystemEvent(event);
540 return (nevents > 0);
543 int QWindowSystemInterface::windowSystemEventsQueued()
545 return QWindowSystemInterfacePrivate::windowSystemEventsQueued();
548 #ifndef QT_NO_DRAGANDDROP
549 QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)
551 return QGuiApplicationPrivate::processDrag(w, dropData, p,supportedActions);
554 QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)
556 return QGuiApplicationPrivate::processDrop(w, dropData, p,supportedActions);
558 #endif // QT_NO_DRAGANDDROP
561 \fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
562 \brief Passes a native event identified by \a eventType to the \a window.
564 \note This function can only be called from the GUI thread.
567 bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
569 return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result);
572 void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName)
574 QWindowSystemInterfacePrivate::FileOpenEvent e(fileName);
575 QGuiApplicationPrivate::processWindowSystemEvent(&e);
578 void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
579 int device, int pointerType, qreal pressure, int xTilt, int yTilt,
580 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
581 Qt::KeyboardModifiers modifiers)
583 QWindowSystemInterfacePrivate::TabletEvent *e =
584 new QWindowSystemInterfacePrivate::TabletEvent(w, timestamp, down, local, global, device, pointerType, pressure,
585 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);
586 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
589 void QWindowSystemInterface::handleTabletEvent(QWindow *w, bool down, const QPointF &local, const QPointF &global,
590 int device, int pointerType, qreal pressure, int xTilt, int yTilt,
591 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
592 Qt::KeyboardModifiers modifiers)
594 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();
595 handleTabletEvent(w, time, down, local, global, device, pointerType, pressure,
596 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);
599 void QWindowSystemInterface::handleTabletEnterProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid)
601 QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e =
602 new QWindowSystemInterfacePrivate::TabletEnterProximityEvent(timestamp, device, pointerType, uid);
603 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
606 void QWindowSystemInterface::handleTabletEnterProximityEvent(int device, int pointerType, qint64 uid)
608 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();
609 handleTabletEnterProximityEvent(time, device, pointerType, uid);
612 void QWindowSystemInterface::handleTabletLeaveProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid)
614 QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e =
615 new QWindowSystemInterfacePrivate::TabletLeaveProximityEvent(timestamp, device, pointerType, uid);
616 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
619 void QWindowSystemInterface::handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid)
621 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();
622 handleTabletLeaveProximityEvent(time, device, pointerType, uid);
625 void QWindowSystemInterface::handlePlatformPanelEvent(QWindow *w)
627 QWindowSystemInterfacePrivate::PlatformPanelEvent *e =
628 new QWindowSystemInterfacePrivate::PlatformPanelEvent(w);
629 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
632 #ifndef QT_NO_CONTEXTMENU
633 void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTriggered,
634 const QPoint &pos, const QPoint &globalPos,
635 Qt::KeyboardModifiers modifiers)
637 QWindowSystemInterfacePrivate::ContextMenuEvent *e =
638 new QWindowSystemInterfacePrivate::ContextMenuEvent(w, mouseTriggered, pos,
639 globalPos, modifiers);
640 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
644 Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier) {
645 QWindowSystemInterface::handleMouseEvent(w, local, global, b, mods);
648 Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
650 QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count);
653 static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
655 QWindowSystemInterface::TouchPoint p;
657 p.flags = pt.flags();
658 p.normalPosition = pt.normalizedPos();
659 p.area = pt.screenRect();
660 p.pressure = pt.pressure();
661 p.state = pt.state();
662 p.velocity = pt.velocity();
663 p.rawPositions = pt.rawScreenPositions();
666 static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList)
668 QList<struct QWindowSystemInterface::TouchPoint> newList;
670 Q_FOREACH (QTouchEvent::TouchPoint p, pointList)
672 newList.append(touchPoint(p));
677 Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
678 const QList<QTouchEvent::TouchPoint> &points,
679 Qt::KeyboardModifiers mods = Qt::NoModifier)
681 QWindowSystemInterface::handleTouchEvent(w, device, touchPointList(points), mods);