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