qwindowsysteminterface.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QElapsedTimer QWindowSystemInterfacePrivate::eventTime;-
6bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;-
7bool QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse = true;-
8QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;-
9QMutex QWindowSystemInterfacePrivate::flushEventMutex;-
10QAtomicInt QWindowSystemInterfacePrivate::eventAccepted;-
11QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;-
12-
13-
14-
15-
16-
17-
18QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePrivate::windowSystemEventQueue;-
19-
20extern QPointer<QWindow> qt_last_mouse_receiver;-
21void QWindowSystemInterface::handleEnterEvent(QWindow *tlw, const QPointF &local, const QPointF &global)-
22{-
23 if (tlw
tlwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
24 QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw, QHighDpi::fromNativeLocalPosition(local, tlw), QHighDpi::fromNativePixels(global, tlw)););-
25 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
26 }
never executed: end of block
0
27}
never executed: end of block
0
28-
29void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)-
30{-
31 QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);-
32 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
33}-
34void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global)-
35{-
36 bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;-
37 if (wasSynchronous)-
38 setSynchronousWindowSystemEvents(false);-
39 handleLeaveEvent(leave);-
40 handleEnterEvent(enter, local, global);-
41 if (wasSynchronous) {-
42 flushWindowSystemEvents();-
43 setSynchronousWindowSystemEvents(true);-
44 }-
45}-
46-
47void QWindowSystemInterface::handleWindowActivated(QWindow *tlw, Qt::FocusReason r)-
48{-
49 QWindowSystemInterfacePrivate::ActivatedWindowEvent *e =-
50 new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw, r);-
51 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
52}-
53-
54void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowState newState)-
55{-
56 QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =-
57 new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);-
58 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
59}-
60-
61void QWindowSystemInterface::handleWindowScreenChanged(QWindow *tlw, QScreen *screen)-
62{-
63 QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e =-
64 new QWindowSystemInterfacePrivate::WindowScreenChangedEvent(tlw, screen);-
65 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
66}-
67-
68void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate)-
69{-
70 ((!(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState))) ? qt_assert("QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)",__FILE__,135141) : qt_noop());-
71 QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e =-
72 new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState, forcePropagate);-
73 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
74}-
75-
76-
77-
78-
79void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect, const QRect &oldRect)-
80{-
81 QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw, QHighDpi::fromNativePixels(newRect, tlw), QHighDpi::fromNativePixels(oldRect, tlw));-
82 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
83}-
84-
85void QWindowSystemInterface::handleCloseEvent(QWindow *tlw, bool *accepted)-
86{-
87 if (tlw) {-
88 QWindowSystemInterfacePrivate::CloseEvent *e =-
89 new QWindowSystemInterfacePrivate::CloseEvent(tlw, accepted);-
90 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
91 }-
92}-
93-
94-
95-
96-
97-
98-
99void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b,-
100 Qt::KeyboardModifiers mods, Qt::MouseEventSource source)-
101{-
102 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
103 handleMouseEvent(w, time, local, global, b, mods, source);-
104}-
105-
106void QWindowSystemInterface::handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b,-
107 Qt::KeyboardModifiers mods, Qt::MouseEventSource source)-
108{-
109 QWindowSystemInterfacePrivate::MouseEvent * e =-
110 new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp, QHighDpi::fromNativeLocalPosition(local, w), QHighDpi::fromNativePixels(global, w), b, mods, source);-
111 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
112}-
113-
114void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b,-
115 Qt::KeyboardModifiers mods, Qt::MouseEventSource source)-
116{-
117 const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
118 handleFrameStrutMouseEvent(w, time, local, global, b, mods, source);-
119}-
120-
121void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b,-
122 Qt::KeyboardModifiers mods, Qt::MouseEventSource source)-
123{-
124 QWindowSystemInterfacePrivate::MouseEvent * e =-
125 new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp,-
126 QWindowSystemInterfacePrivate::FrameStrutMouse,-
127 QHighDpi::fromNativeLocalPosition(local, w), QHighDpi::fromNativePixels(global, w), b, mods, source);-
128 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
129}-
130-
131bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode,-
132 quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text, bool autorepeat, ushort count)-
133{-
134-
135 if (!window)-
136 window = QGuiApplication::focusWindow();-
137-
138 QShortcutMap &shortcutMap = QGuiApplicationPrivate::instance()->shortcutMap;-
139 if (shortcutMap.state() == QKeySequence::NoMatch) {-
140-
141-
142-
143-
144-
145 QWindowSystemInterfacePrivate::KeyEvent *shortcutOverrideEvent = new QWindowSystemInterfacePrivate::KeyEvent(window, timestamp,-
146 QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorepeat, count);-
147-
148 {-
149-
150 QScopedValueRollback<bool> syncRollback(QWindowSystemInterfacePrivate::synchronousWindowSystemEvents);-
151 QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = true;-
152-
153 if (QWindowSystemInterfacePrivate::handleWindowSystemEvent(shortcutOverrideEvent))-
154 return false;-
155 }-
156 }-
157-
158-
159-
160-
161 QKeyEvent keyEvent(QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode,-
162 nativeVirtualKey, nativeModifiers, text, autorepeat, count);-
163-
164 return shortcutMap.tryShortcut(&keyEvent);-
165}-
166-
167-
168bool QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {-
169 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
170 return handleKeyEvent(w, time, t, k, mods, text, autorep, count);-
171}-
172-
173bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)-
174{-
175-
176-
177-
178-
179-
180 QWindowSystemInterfacePrivate::KeyEvent * e =-
181 new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);-
182 return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
183}-
184-
185bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,-
186 quint32 nativeScanCode, quint32 nativeVirtualKey,-
187 quint32 nativeModifiers,-
188 const QString& text, bool autorep,-
189 ushort count, bool tryShortcutOverride)-
190{-
191 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
192 return handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,-
193 text, autorep, count, tryShortcutOverride);-
194}-
195-
196bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,-
197 Qt::KeyboardModifiers modifiers,-
198 quint32 nativeScanCode, quint32 nativeVirtualKey,-
199 quint32 nativeModifiers,-
200 const QString& text, bool autorep,-
201 ushort count, bool tryShortcutOverride)-
202{-
203-
204-
205-
206-
207-
208-
209 (void)tryShortcutOverride;-
210-
211-
212 QWindowSystemInterfacePrivate::KeyEvent * e =-
213 new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,-
214 nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);-
215 return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
216}-
217-
218void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods) {-
219 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
220 handleWheelEvent(w, time, local, global, d, o, mods);-
221}-
222-
223void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods)-
224{-
225 QPoint point = (o == Qt::Vertical) ? QPoint(0, d) : QPoint(d, 0);-
226 handleWheelEvent(tlw, timestamp, local, global, QPoint(), point, mods);-
227}-
228-
229void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource source)-
230{-
231 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
232 handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods, phase, source);-
233}-
234-
235void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase,-
236 Qt::MouseEventSource source, bool invertedScrolling)-
237{-
238-
239-
240-
241-
242-
243-
244-
245 if (!QGuiApplicationPrivate::scrollNoPhaseAllowed && phase == Qt::NoScrollPhase)-
phase = Qt::ScrollUpdate;QWindowSystemInterfacePrivate::WheelEvent *e;
246-
247-
248-
249 if (angleDelta.isNull()
angleDelta.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& phase == Qt::ScrollUpdate
phase == Qt::ScrollUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
250 return;
never executed: return;
0
251-
252-
253 if (angleDelta.y() != 0
angleDelta.y() != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& angleDelta.x() == 0
angleDelta.x() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
254 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, QHighDpi::fromNativeLocalPosition(local, tlw), QHighDpi::fromNativePixels(global, tlw), pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical,-
255 mods, phase, source, invertedScrolling);-
256 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
257 return;
never executed: return;
0
258 }-
259-
260-
261 if (angleDelta.y() == 0
angleDelta.y() == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& angleDelta.x() != 0
angleDelta.x() != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
262 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, QHighDpi::fromNativeLocalPosition(local, tlw), QHighDpi::fromNativePixels(global, tlw), pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling);-
263 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
264 return;
never executed: return;
0
265 }-
266-
267-
268-
269-
270 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, QHighDpi::fromNativeLocalPosition(local, tlw), QHighDpi::fromNativePixels(global, tlw), pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling);-
271 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
272-
273-
274-
275 e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, QHighDpi::fromNativeLocalPosition(local, tlw), QHighDpi::fromNativePixels(global, tlw), QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling);-
276 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
277}
never executed: end of block
0
278-
279-
280QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *exposed, const QRegion &region)-
281 : WindowSystemEvent(Expose)-
282 , exposed(exposed)-
283 , isExposed(exposed && exposed->handle() ? exposed->handle()->isExposed() : false)-
284 , region(region)-
285{-
286}-
287-
288int QWindowSystemInterfacePrivate::windowSystemEventsQueued()-
289{-
290 return windowSystemEventQueue.count();-
291}-
292-
293QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()-
294{-
295 return windowSystemEventQueue.takeFirstOrReturnNull();-
296}-
297-
298QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent()-
299{-
300 return windowSystemEventQueue.takeFirstNonUserInputOrReturnNull();-
301}-
302-
303QWindowSystemInterfacePrivate::WindowSystemEvent *QWindowSystemInterfacePrivate::peekWindowSystemEvent(EventType t)-
304{-
305 return windowSystemEventQueue.peekAtFirstOfType(t);-
306}-
307-
308void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *event)-
309{-
310 windowSystemEventQueue.remove(event);-
311}-
312-
313void QWindowSystemInterfacePrivate::postWindowSystemEvent(WindowSystemEvent *ev)-
314{-
315 windowSystemEventQueue.append(ev);-
316 QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();-
317 if (dispatcher)-
318 dispatcher->wakeUp();-
319}-
320bool QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)-
321{-
322 bool accepted = true;-
323 if (synchronousWindowSystemEvents) {-
324 if (QThread::currentThread() == QGuiApplication::instance()->thread()) {-
325-
326 QGuiApplicationPrivate::processWindowSystemEvent(ev);-
327 accepted = ev->eventAccepted;-
328 delete ev;-
329 } else {-
330-
331-
332-
333-
334 postWindowSystemEvent(ev);-
335 accepted = QWindowSystemInterface::flushWindowSystemEvents();-
336 }-
337 } else {-
338 postWindowSystemEvent(ev);-
339 }-
340 return accepted;-
341}-
342-
343void QWindowSystemInterface::registerTouchDevice(const QTouchDevice *device)-
344{-
345 QTouchDevicePrivate::registerDevice(device);-
346}-
347-
348void QWindowSystemInterface::unregisterTouchDevice(const QTouchDevice *device)-
349{-
350 QTouchDevicePrivate::unregisterDevice(device);-
351}-
352-
353bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device)-
354{-
355 return QTouchDevicePrivate::isRegistered(device);-
356}-
357-
358void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device,-
359 const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)-
360{-
361 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
362 handleTouchEvent(w, time, device, points, mods);-
363}-
364-
365QList<QTouchEvent::TouchPoint>-
366 QWindowSystemInterfacePrivate::fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points,-
367 const QWindow *window,-
368 QEvent::Type *type)-
369{-
370 QList<QTouchEvent::TouchPoint> touchPoints;-
371 Qt::TouchPointStates states;-
372 QTouchEvent::TouchPoint p;-
373-
374 touchPoints.reserve(points.count());-
375 QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin();-
376 QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();-
377 while (point != end) {-
378 p.setId(point->id);-
379 p.setPressure(point->pressure);-
380 states |= point->state;-
381 p.setState(point->state);-
382-
383 const QPointF screenPos = point->area.center();-
384 p.setScreenPos(QHighDpi::fromNativePixels(screenPos, window));-
385 p.setScreenRect(QHighDpi::fromNativePixels(point->area, window));-
386-
387-
388-
389-
390 p.setNormalizedPos(QHighDpi::fromNativePixels(point->normalPosition, window));-
391 p.setVelocity(QHighDpi::fromNativePixels(point->velocity, window));-
392 p.setFlags(point->flags);-
393 p.setRawScreenPositions(QHighDpi::fromNativePixels(point->rawPositions, window));-
394-
395 touchPoints.append(p);-
396 ++point;-
397 }-
398-
399-
400 if (type) {-
401 *type = QEvent::TouchUpdate;-
402 if (states == Qt::TouchPointPressed)-
403 *type = QEvent::TouchBegin;-
404 else if (states == Qt::TouchPointReleased)-
405 *type = QEvent::TouchEnd;-
406 }-
407-
408 return touchPoints;-
409}-
410-
411QList<QWindowSystemInterface::TouchPoint>-
412 QWindowSystemInterfacePrivate::toNativeTouchPoints(const QList<QTouchEvent::TouchPoint>& pointList,-
413 const QWindow *window)-
414{-
415 QList<QWindowSystemInterface::TouchPoint> newList;-
416 newList.reserve(pointList.size());-
417 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(pointList)>::type> _container_((pointList)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QTouchEvent::TouchPoint &pt = *_container_.i; _container_.control; _container_.control = 0: pointList) {-
418 QWindowSystemInterface::TouchPoint p;-
419 p.id = pt.id();-
420 p.flags = pt.flags();-
421 p.normalPosition = QHighDpi::toNativeLocalPosition(pt.normalizedPos(), window);-
422 p.area = QHighDpi::toNativePixels(pt.screenRect(), window);-
423 p.pressure = pt.pressure();-
424 p.state = pt.state();-
425 p.velocity = pt.velocity();-
426 p.rawPositions = pt.rawScreenPositions();-
427 newList.append(p);-
428 }
never executed: end of block
0
429 return
never executed: return newList;
newList;
never executed: return newList;
0
430}-
431-
432void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device,-
433 const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)-
434{-
435 if (!points.size())-
436 return;-
437-
438 if (!QTouchDevicePrivate::isRegistered(device))-
439 return;-
440-
441 QEvent::Type type;-
442 QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, tlw, &type);-
443-
444 QWindowSystemInterfacePrivate::TouchEvent *e =-
445 new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods);-
446 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
447}-
448-
449void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device,-
450 Qt::KeyboardModifiers mods)-
451{-
452 unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
453 handleTouchCancelEvent(w, time, device, mods);-
454}-
455-
456void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device,-
457 Qt::KeyboardModifiers mods)-
458{-
459 QWindowSystemInterfacePrivate::TouchEvent *e =-
460 new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device,-
461 QList<QTouchEvent::TouchPoint>(), mods);-
462 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
463}-
464-
465void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)-
466{-
467 QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =-
468 new QWindowSystemInterfacePrivate::ScreenOrientationEvent(screen, orientation);-
469 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
470}-
471-
472void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const QRect &geometry, const QRect &availableGeometry)-
473{-
474 QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =-
475 new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screen, QHighDpi::fromNativeScreenGeometry(geometry, screen), QHighDpi::fromNative(availableGeometry, screen, geometry.topLeft()));-
476 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
477}-
478-
479void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal dpiX, qreal dpiY)-
480{-
481 QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e =-
482 new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, dpiX, dpiY);-
483 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
484}-
485-
486void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate)-
487{-
488 QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e =-
489 new QWindowSystemInterfacePrivate::ScreenRefreshRateEvent(screen, newRefreshRate);-
490 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
491}-
492-
493void QWindowSystemInterface::handleThemeChange(QWindow *tlw)-
494{-
495 QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(tlw);-
496 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
497}-
498-
499void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &region)-
500{-
501 QWindowSystemInterfacePrivate::ExposeEvent *e =-
502 new QWindowSystemInterfacePrivate::ExposeEvent(tlw, QHighDpi::fromNativeLocalExposedRegion(region, tlw));-
503 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
504}-
505-
506void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)-
507{-
508 ((!(QThread::currentThread() == QGuiApplication::instance()->thread())) ? qt_assert("QThread::currentThread() == QGuiApplication::instance()->thread()",__FILE__,601606) : qt_noop());-
509-
510 QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);-
511 sendWindowSystemEvents(flags);-
512 QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();-
513}-
514-
515-
516-
517-
518-
519bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)-
520{-
521 const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();-
522 if (!count)-
523 return false;-
524 if (!QGuiApplication::instance()) {-
525 QMessageLogger(__FILE__, 618623, __PRETTY_FUNCTION__).warning().nospace()-
526 << "QWindowSystemInterface::flushWindowSystemEvents() invoked after "-
527 "QGuiApplication destruction, discarding " << count << " events.";-
528 QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();-
529 return false;-
530 }-
531 if (QThread::currentThread() != QGuiApplication::instance()->thread()) {-
532-
533-
534 QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);-
535 QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);-
536 QWindowSystemInterfacePrivate::postWindowSystemEvent(e);-
537 QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);-
538 } else {-
539 sendWindowSystemEvents(flags);-
540 }-
541 return QWindowSystemInterfacePrivate::eventAccepted.load() > 0;-
542}-
543-
544bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)-
545{-
546 int nevents = 0;-
547-
548 while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {-
549 QWindowSystemInterfacePrivate::WindowSystemEvent *event =-
550 (flags & QEventLoop::ExcludeUserInputEvents) ?-
551 QWindowSystemInterfacePrivate::getNonUserInputWindowSystemEvent() :-
552 QWindowSystemInterfacePrivate::getWindowSystemEvent();-
553 if (!event)-
554 break;-
555-
556 if (QWindowSystemInterfacePrivate::eventHandler) {-
557 if (QWindowSystemInterfacePrivate::eventHandler->sendEvent(event))-
558 nevents++;-
559 } else {-
560 nevents++;-
561 QGuiApplicationPrivate::processWindowSystemEvent(event);-
562 }-
563-
564-
565-
566-
567 if (event->type != QWindowSystemInterfacePrivate::FlushEvents)-
568 QWindowSystemInterfacePrivate::eventAccepted.store(event->eventAccepted);-
569-
570 delete event;-
571 }-
572-
573 return (nevents > 0);-
574}-
575-
576void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSystemEventHandler *handler)-
577{-
578 if (!eventHandler)-
579 eventHandler = handler;-
580}-
581-
582void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler)-
583{-
584 if (eventHandler == handler)-
585 eventHandler = 0;-
586}-
587-
588void QWindowSystemInterface::setSynchronousWindowSystemEvents(bool enable)-
589{-
590 QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = enable;-
591}-
592-
593int QWindowSystemInterface::windowSystemEventsQueued()-
594{-
595 return QWindowSystemInterfacePrivate::windowSystemEventsQueued();-
596}-
597-
598-
599QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)-
600{-
601 return QGuiApplicationPrivate::processDrag(w, dropData, QHighDpi::fromNativeLocalPosition(p, w) ,supportedActions);-
602}-
603-
604QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)-
605{-
606 return QGuiApplicationPrivate::processDrop(w, dropData, QHighDpi::fromNativeLocalPosition(p, w),supportedActions);-
607}-
608bool QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)-
609{-
610 return QGuiApplicationPrivate::processNativeEvent(window, eventType, message, result);-
611}-
612-
613void QWindowSystemInterface::handleFileOpenEvent(const QString& fileName)-
614{-
615 QWindowSystemInterfacePrivate::FileOpenEvent e(fileName);-
616 QGuiApplicationPrivate::processWindowSystemEvent(&e);-
617}-
618-
619void QWindowSystemInterface::handleFileOpenEvent(const QUrl &url)-
620{-
621 QWindowSystemInterfacePrivate::FileOpenEvent e(url);-
622 QGuiApplicationPrivate::processWindowSystemEvent(&e);-
623}-
624-
625void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, const QPointF &local, const QPointF &global,-
626 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,-
627 qreal tangentialPressure, qreal rotation, int z, qint64 uid,-
628 Qt::KeyboardModifiers modifiers)-
629{-
630 QWindowSystemInterfacePrivate::TabletEvent *e =-
631 new QWindowSystemInterfacePrivate::TabletEvent(w,timestamp,-
632 QHighDpi::fromNativeLocalPosition(local, w),-
633 QHighDpi::fromNativePixels(global, w),-
634 device, pointerType, buttons, pressure,-
635 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);-
636 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
637}-
638-
639void QWindowSystemInterface::handleTabletEvent(QWindow *w, const QPointF &local, const QPointF &global,-
640 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,-
641 qreal tangentialPressure, qreal rotation, int z, qint64 uid,-
642 Qt::KeyboardModifiers modifiers)-
643{-
644 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
645 handleTabletEvent(w, time, local, global, device, pointerType, buttons, pressure,-
646 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);-
647}-
648-
649void QWindowSystemInterface::handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,-
650 int device, int pointerType, qreal pressure, int xTilt, int yTilt,-
651 qreal tangentialPressure, qreal rotation, int z, qint64 uid,-
652 Qt::KeyboardModifiers modifiers)-
653{-
654 handleTabletEvent(w, timestamp, local, global, device, pointerType, (down ? Qt::LeftButton : Qt::NoButton), pressure,-
655 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);-
656}-
657-
658void QWindowSystemInterface::handleTabletEvent(QWindow *w, bool down, const QPointF &local, const QPointF &global,-
659 int device, int pointerType, qreal pressure, int xTilt, int yTilt,-
660 qreal tangentialPressure, qreal rotation, int z, qint64 uid,-
661 Qt::KeyboardModifiers modifiers)-
662{-
663 handleTabletEvent(w, local, global, device, pointerType, (down ? Qt::LeftButton : Qt::NoButton), pressure,-
664 xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);-
665}-
666-
667void QWindowSystemInterface::handleTabletEnterProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid)-
668{-
669 QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e =-
670 new QWindowSystemInterfacePrivate::TabletEnterProximityEvent(timestamp, device, pointerType, uid);-
671 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
672}-
673-
674void QWindowSystemInterface::handleTabletEnterProximityEvent(int device, int pointerType, qint64 uid)-
675{-
676 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
677 handleTabletEnterProximityEvent(time, device, pointerType, uid);-
678}-
679-
680void QWindowSystemInterface::handleTabletLeaveProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid)-
681{-
682 QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e =-
683 new QWindowSystemInterfacePrivate::TabletLeaveProximityEvent(timestamp, device, pointerType, uid);-
684 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
685}-
686-
687void QWindowSystemInterface::handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid)-
688{-
689 ulong time = QWindowSystemInterfacePrivate::eventTime.elapsed();-
690 handleTabletLeaveProximityEvent(time, device, pointerType, uid);-
691}-
692-
693-
694void QWindowSystemInterface::handleGestureEvent(QWindow *window, ulong timestamp, Qt::NativeGestureType type,-
695 QPointF &local, QPointF &global)-
696{-
697 QWindowSystemInterfacePrivate::GestureEvent *e =-
698 new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);-
699 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
700}-
701-
702void QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type,-
703 qreal value, QPointF &local, QPointF &global)-
704{-
705 QWindowSystemInterfacePrivate::GestureEvent *e =-
706 new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);-
707 e->realValue = value;-
708 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
709}-
710-
711void QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type,-
712 ulong sequenceId, quint64 value, QPointF &local, QPointF &global)-
713{-
714 QWindowSystemInterfacePrivate::GestureEvent *e =-
715 new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);-
716 e->sequenceId = sequenceId;-
717 e->intValue = value;-
718 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
719}-
720-
721-
722void QWindowSystemInterface::handlePlatformPanelEvent(QWindow *w)-
723{-
724 QWindowSystemInterfacePrivate::PlatformPanelEvent *e =-
725 new QWindowSystemInterfacePrivate::PlatformPanelEvent(w);-
726 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
727}-
728-
729-
730void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTriggered,-
731 const QPoint &pos, const QPoint &globalPos,-
732 Qt::KeyboardModifiers modifiers)-
733{-
734 QWindowSystemInterfacePrivate::ContextMenuEvent *e =-
735 new QWindowSystemInterfacePrivate::ContextMenuEvent(w, mouseTriggered, pos,-
736 globalPos, modifiers);-
737 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
738}-
739-
740-
741-
742void QWindowSystemInterface::handleEnterWhatsThisEvent()-
743{-
744 QWindowSystemInterfacePrivate::WindowSystemEvent *e =-
745 new QWindowSystemInterfacePrivate::WindowSystemEvent(QWindowSystemInterfacePrivate::EnterWhatsThisMode);-
746 QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);-
747}-
748-
749-
750-
751__attribute__((visibility("default"))) QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p)-
752{-
753 QDebugStateSaver saver(dbg);-
754 dbg.nospace() << "TouchPoint(" << p.id << " @" << p.area << " normalized " << p.normalPosition-
755 << " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;-
756 return dbg;-
757}-
758-
759-
760-
761-
762-
763__attribute__((visibility("default"))) void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp)-
764{-
765 bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;-
766 QWindowSystemInterface::setSynchronousWindowSystemEvents(true);-
767 const qreal factor = QHighDpiScaling::factor(w);-
768 QWindowSystemInterface::handleMouseEvent(w, timestamp, local * factor,-
769 global * factor, b, mods);-
770 QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);-
}
__attribute__((visibility("default"))) void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier)
{
qt_handleMouseEvent(w, local, global, b, mods, QWindowSystemInterfacePrivate::eventTime.elapsed());}
772-
773__attribute__((visibility("default"))) void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)-
774{-
775 bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;-
776 QWindowSystemInterface::setSynchronousWindowSystemEvents(true);-
777 QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count);-
778 QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);-
779}-
780-
781__attribute__((visibility("default"))) bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1)-
782{-
783 QGuiApplicationPrivate::modifier_buttons = mods;-
784-
785 QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count);-
786 qevent.setTimestamp(timestamp);-
787-
788 QShortcutMap &shortcutMap = QGuiApplicationPrivate::instance()->shortcutMap;-
789 if (shortcutMap.state() == QKeySequence::NoMatch) {-
790-
791 QCoreApplication::sendEvent(o, &qevent);-
792 if (qevent.isAccepted())-
793 return false;-
794 }-
795-
796-
797 return shortcutMap.tryShortcut(&qevent);-
798}-
799-
800__attribute__((visibility("default"))) void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,-
801 const QList<QTouchEvent::TouchPoint> &points,-
802 Qt::KeyboardModifiers mods = Qt::NoModifier)-
803{-
804 bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents;-
805 QWindowSystemInterface::setSynchronousWindowSystemEvents(true);-
806 QWindowSystemInterface::handleTouchEvent(w, device,-
807 QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods);-
808 QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous);-
809}-
810-
811QWindowSystemEventHandler::~QWindowSystemEventHandler()-
812{-
813 QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(this);-
814}-
815-
816bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)-
817{-
818 QGuiApplicationPrivate::processWindowSystemEvent(e);-
819 return true;-
820}-
821-
822QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD,-
823 QPoint angleD, int qt4D, Qt::Orientation qt4O, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource src, bool inverted)-
824 : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D),-
825 qt4Orientation(qt4O), localPos(local), globalPos(global), phase(!QGuiApplicationPrivate::scrollNoPhaseAllowed &&phase== Qt::NoScrollPhase ? Qt::ScrollUpdate :(phase), source(src), inverted(inverted)-
826{-
827}
never executed: end of block
0
828-
829void QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(bool v)-
830{-
831 platformSynthesizesMouse = v;-
832}
never executed: end of block
0
833-
834-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9