QtBase  v6.3.1
qwindowsysteminterface.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 #include "qwindowsysteminterface.h"
40 #include <qpa/qplatformwindow.h>
42 #include "private/qguiapplication_p.h"
43 #include "private/qevent_p.h"
44 #include "private/qeventpoint_p.h"
45 #include "private/qpointingdevice_p.h"
46 #include "private/qscreen_p.h"
47 #include <QAbstractEventDispatcher>
48 #include <qpa/qplatformintegration.h>
49 #include <qdebug.h>
50 #include "qhighdpiscaling_p.h"
51 
52 #include <QtCore/qscopedvaluerollback.h>
53 #include <QtCore/private/qlocking_p.h>
54 
55 #if QT_CONFIG(draganddrop)
56 #include <qpa/qplatformdrag.h>
57 #endif
58 
60 
61 Q_LOGGING_CATEGORY(lcQpaInputDevices, "qt.qpa.input.devices")
62 
64 bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;
65 bool QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse = true;
67 QMutex QWindowSystemInterfacePrivate::flushEventMutex;
70 QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePrivate::windowSystemEventQueue;
71 
73 
74 
75 // ------------------- QWindowSystemInterfacePrivate -------------------
76 
87 template<typename Delivery>
89 {
90  template<typename EventType, typename ...Args>
91  static bool handleEvent(Args ...);
92 };
93 
94 /*
95  Handles a window system event.
96 
97  By default this function posts the event on the window system event queue and
98  wakes the Gui event dispatcher. Qt Gui will then handle the event asynchronously
99  at a later point. The return value is not used in asynchronous mode and will
100  always be true.
101 
102  In synchronous mode Qt Gui will process the event immediately. The return value
103  indicates if Qt accepted the event. If the event is delivered from another thread
104  than the Qt main thread the window system event queue is flushed, which may deliver
105  other events as well.
106 
107  \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents()
108 */
109 template<>
110 template<typename EventType, typename ...Args>
112 {
116 }
117 
118 /*
119  Handles a window system event synchronously.
120 
121  Qt Gui will process the event immediately. The return value indicates if Qt
122  accepted the event.
123 
124  If the event is delivered from another thread than the Qt main thread the
125  window system event queue is flushed, which may deliver other events as
126  well.
127 */
128 template<>
129 template<typename EventType, typename ...Args>
131 {
132  if (QThread::currentThread() == QGuiApplication::instance()->thread()) {
133  EventType event(args...);
134  // Process the event immediately on the Gui thread and return the accepted state
136  return event.eventAccepted;
137  } else {
138  // Post the event on the Qt main thread queue and flush the queue.
139  // This will wake up the Gui thread which will process the event.
140  // Return the accepted state for the last event on the queue,
141  // which is the event posted by this function.
144  }
145 }
146 
147 /*
148  Handles a window system event asynchronously by posting the event to Qt Gui.
149 
150  This function posts the event on the window system event queue and wakes the
151  Gui event dispatcher. Qt Gui will then handle the event asynchronously at a
152  later point.
153 */
154 template<>
155 template<typename EventType, typename ...Args>
157 {
160  dispatcher->wakeUp();
161  return true;
162 }
163 
164 template <typename EventType, typename Delivery = QWindowSystemInterface::DefaultDelivery, typename ...Args>
165 static bool handleWindowSystemEvent(Args ...args)
166 {
167  return QWindowSystemHelper<Delivery>::template handleEvent<EventType>(args...);
168 }
169 
171 {
172  return windowSystemEventQueue.count();
173 }
174 
176 {
178 }
179 
181 {
183 }
184 
186 {
188 }
189 
191 {
193 }
194 
196 {
198 }
199 
201 {
202  if (!eventHandler)
203  eventHandler = handler;
204 }
205 
207 {
208  if (eventHandler == handler)
209  eventHandler = nullptr;
210 }
211 
213 {
215 }
216 
218 {
220  return true;
221 }
222 
223 //------------------------------------------------------------
224 //
225 // Callback functions for plugins:
226 //
227 
228 #define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName, ...) \
229  template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::DefaultDelivery>(__VA_ARGS__); \
230  template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::SynchronousDelivery>(__VA_ARGS__); \
231  template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::AsynchronousDelivery>(__VA_ARGS__); \
232  template<typename Delivery> ReturnType QWindowSystemInterface::HandlerName(__VA_ARGS__)
233 
246 QT_DEFINE_QPA_EVENT_HANDLER(void, handleEnterEvent, QWindow *window, const QPointF &local, const QPointF &global)
247 {
248  if (window) {
249  handleWindowSystemEvent<QWindowSystemInterfacePrivate::EnterEvent, Delivery>(window,
251  }
252 }
253 
254 QT_DEFINE_QPA_EVENT_HANDLER(void, handleLeaveEvent, QWindow *window)
255 {
256  handleWindowSystemEvent<QWindowSystemInterfacePrivate::LeaveEvent, Delivery>(window);
257 }
258 
267 {
268  handleLeaveEvent<AsynchronousDelivery>(leave);
269  handleEnterEvent(enter, local, global);
270 }
271 
273 {
274  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ActivatedWindowEvent, Delivery>(window, r);
275 }
276 
277 QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowStates newState, int oldState)
278 {
279  Q_ASSERT(window);
280  if (oldState < Qt::WindowNoState)
281  oldState = window->windowStates();
282 
283  handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowStateChangedEvent, Delivery>(window, newState, Qt::WindowStates(oldState));
284 }
285 
286 QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowScreenChanged, QWindow *window, QScreen *screen)
287 {
288  handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowScreenChangedEvent, Delivery>(window, screen);
289 }
290 
291 QT_DEFINE_QPA_EVENT_HANDLER(void, handleSafeAreaMarginsChanged, QWindow *window)
292 {
293  handleWindowSystemEvent<QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent, Delivery>(window);
294 }
295 
296 QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate)
297 {
299  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent, Delivery>(newState, forcePropagate);
300 }
301 
302 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleApplicationTermination)
303 {
304  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowSystemEvent, Delivery>(
306 }
307 
309  : WindowSystemEvent(GeometryChange)
310  , window(window)
311  , newGeometry(newGeometry)
312 {
313  if (const QPlatformWindow *pw = window->handle()) {
314  const auto nativeGeometry = pw->QPlatformWindow::geometry();
316  }
317 }
318 
319 QT_DEFINE_QPA_EVENT_HANDLER(void, handleGeometryChange, QWindow *window, const QRect &newRect)
320 {
321  Q_ASSERT(window);
322  const auto newRectDi = QHighDpi::fromNativeWindowGeometry(newRect, window);
323  if (window->handle()) {
324  // Persist the new geometry so that QWindow::geometry() can be queried in the resize event
325  window->handle()->QPlatformWindow::setGeometry(newRect);
326  // FIXME: This does not work during platform window creation, where the QWindow does not
327  // have its handle set up yet. Platforms that deliver events during window creation need
328  // to handle the persistence manually, e.g. by overriding geometry().
329  }
330  handleWindowSystemEvent<QWindowSystemInterfacePrivate::GeometryChangeEvent, Delivery>(window, newRectDi);
331 }
332 
335  , window(window)
336  , isExposed(window && window->handle() ? window->handle()->isExposed() : false)
337  , region(region)
338 {
339 }
340 
358 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleExposeEvent, QWindow *window, const QRegion &region)
359 {
360  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::ExposeEvent, Delivery>(window,
362 }
363 
364 QT_DEFINE_QPA_EVENT_HANDLER(bool, handlePaintEvent, QWindow *window, const QRegion &region)
365 {
366  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::PaintEvent, Delivery>(window,
368 }
369 
370 
371 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleCloseEvent, QWindow *window)
372 {
373  Q_ASSERT(window);
374  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, Delivery>(window);
375 }
376 
383 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window,
384  const QPointF &local, const QPointF &global, Qt::MouseButtons state,
385  Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
387 {
389  return handleMouseEvent<Delivery>(window, time, local, global, state, button, type, mods, source);
390 }
391 
393  const QPointF &local, const QPointF &global, Qt::MouseButtons state,
394  Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
396 {
398  return handleMouseEvent<Delivery>(window, time, device, local, global, state, button, type, mods, source);
399 }
400 
401 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp,
402  const QPointF &local, const QPointF &global, Qt::MouseButtons state,
403  Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
405 {
406  return handleMouseEvent<Delivery>(window, timestamp, QPointingDevice::primaryPointingDevice(),
407  local, global, state, button, type, mods, source);
408 }
409 
410 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
411  const QPointF &local, const QPointF &global, Qt::MouseButtons state,
412  Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
414 {
416  "QWindowSystemInterface::handleMouseEvent",
417  "QTBUG-71263: Native double clicks are not implemented.");
420 
421  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::MouseEvent, Delivery>(window,
422  timestamp, localPos, globalPos, state, mods, button, type, source, false, device);
423 }
424 
426  const QPointF &local, const QPointF &global,
427  Qt::MouseButtons state,
429  Qt::KeyboardModifiers mods,
431 {
432  const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
433  return handleFrameStrutMouseEvent(window, time, local, global, state, button, type, mods, source);
434 }
435 
437  const QPointF &local, const QPointF &global,
438  Qt::MouseButtons state,
440  Qt::KeyboardModifiers mods,
442 {
443  const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
444  return handleFrameStrutMouseEvent(window, time, device, local, global, state, button, type, mods, source);
445 }
446 
448  const QPointF &local, const QPointF &global,
449  Qt::MouseButtons state,
451  Qt::KeyboardModifiers mods,
453 {
454  return handleFrameStrutMouseEvent(window, timestamp, QPointingDevice::primaryPointingDevice(),
455  local, global, state, button, type, mods, source);
456 }
457 
459  const QPointF &local, const QPointF &global,
460  Qt::MouseButtons state,
462  Qt::KeyboardModifiers mods,
464 {
467 
468  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::MouseEvent>(window,
469  timestamp, localPos, globalPos, state, mods, button, type, source, true, device);
470 }
471 
472 bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode,
473  quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text, bool autorepeat, ushort count)
474 {
475 #if QT_CONFIG(shortcut)
476  if (!window)
478 
479  QShortcutMap &shortcutMap = QGuiApplicationPrivate::instance()->shortcutMap;
480  if (shortcutMap.state() == QKeySequence::NoMatch) {
481  // Check if the shortcut is overridden by some object in the event delivery path (typically the focus object).
482  // If so, we should not look up the shortcut in the shortcut map, but instead deliver the event as a regular
483  // key event, so that the target that accepted the shortcut override event can handle it. Note that we only
484  // do this if the shortcut map hasn't found a partial shortcut match yet. If it has, the shortcut can not be
485  // overridden.
486  bool overridden = handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent, SynchronousDelivery>
487  (window,timestamp, QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode,
488  nativeVirtualKey, nativeModifiers, text, autorepeat, count);
489  if (overridden)
490  return false;
491  }
492 
493  // The shortcut event is dispatched as a QShortcutEvent, not a QKeyEvent, but we use
494  // the QKeyEvent as a container for the various properties that the shortcut map needs
495  // to inspect to determine if a shortcut matched the keys that were pressed.
496  QKeyEvent keyEvent(QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode,
497  nativeVirtualKey, nativeModifiers, text, autorepeat, count);
498 
499  return shortcutMap.tryShortcut(&keyEvent);
500 #else
501  Q_UNUSED(window);
502  Q_UNUSED(timestamp);
503  Q_UNUSED(keyCode);
504  Q_UNUSED(modifiers);
505  Q_UNUSED(nativeScanCode);
506  Q_UNUSED(nativeVirtualKey);
507  Q_UNUSED(nativeModifiers);
508  Q_UNUSED(text);
509  Q_UNUSED(autorepeat);
510  Q_UNUSED(count);
511  return false;
512 #endif
513 }
514 
515 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
517  return handleKeyEvent<Delivery>(window, time, t, k, mods, text, autorep, count);
518 }
519 
520 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
521 {
522 #if defined(Q_OS_MACOS)
523  if (t == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(window, timestamp, k, mods, 0, 0, 0, text, autorep, count))
524  return true;
525 #endif
526 
527  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent, Delivery>(window,
528  timestamp, t, k, mods, text, autorep, count);
529 }
530 
532  quint32 nativeScanCode, quint32 nativeVirtualKey,
533  quint32 nativeModifiers,
534  const QString& text, bool autorep,
535  ushort count, bool tryShortcutOverride)
536 {
538  return handleExtendedKeyEvent(window, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
539  text, autorep, count, tryShortcutOverride);
540 }
541 
543  Qt::KeyboardModifiers modifiers,
544  quint32 nativeScanCode, quint32 nativeVirtualKey,
545  quint32 nativeModifiers,
546  const QString& text, bool autorep,
547  ushort count, bool tryShortcutOverride)
548 {
549 #if defined(Q_OS_MACOS)
551  timestamp, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count)) {
552  return true;
553  }
554 #else
555  Q_UNUSED(tryShortcutOverride);
556 #endif
557 
558  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent>(window,
559  timestamp, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
560 }
561 
562 bool QWindowSystemInterface::handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource source)
563 {
565  return handleWheelEvent(window, time, local, global, pixelDelta, angleDelta, mods, phase, source);
566 }
567 
568 bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase,
569  Qt::MouseEventSource source, bool invertedScrolling)
570 {
571  return handleWheelEvent(window, timestamp, QPointingDevice::primaryPointingDevice(), local, global,
572  pixelDelta, angleDelta, mods, phase, source, invertedScrolling);
573 }
574 
576  const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta,
577  Qt::KeyboardModifiers mods, Qt::ScrollPhase phase,
578  Qt::MouseEventSource source, bool invertedScrolling)
579 {
580  // Qt 4 sends two separate wheel events for horizontal and vertical
581  // deltas. For Qt 5 we want to send the deltas in one event, but at the
582  // same time preserve source and behavior compatibility with Qt 4.
583  //
584  // In addition high-resolution pixel-based deltas are also supported.
585  // Platforms that does not support these may pass a null point here.
586  // Angle deltas must always be sent in addition to pixel deltas.
587 
588  // Pass Qt::ScrollBegin and Qt::ScrollEnd through
589  // even if the wheel delta is null.
590  if (angleDelta.isNull() && phase == Qt::ScrollUpdate)
591  return false;
592 
593  // Simple case: vertical deltas only:
594  if (angleDelta.y() != 0 && angleDelta.x() == 0) {
595  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
597  pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
598  }
599 
600  // Simple case: horizontal deltas only:
601  if (angleDelta.y() == 0 && angleDelta.x() != 0) {
602  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
604  pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
605  }
606 
607  bool acceptVert;
608  bool acceptHorz;
609  // Both horizontal and vertical deltas: Send two wheel events.
610  // The first event contains the Qt 5 pixel and angle delta as points,
611  // and in addition the Qt 4 compatibility vertical angle delta.
612  acceptVert = handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
614  pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
615 
616  // The second event contains null pixel and angle points and the
617  // Qt 4 compatibility horizontal angle delta.
618  acceptHorz = handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
620  QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
621 
622  return acceptVert || acceptHorz;
623 }
624 
642 {
643  qCDebug(lcQpaInputDevices) << "register" << device;
645 }
646 
676  const QWindow *window, QEvent::Type *type)
677 {
678  QList<QEventPoint> touchPoints;
680 
681  touchPoints.reserve(points.count());
684  while (point != end) {
685  QPointF globalPos = QHighDpi::fromNativePixels(point->area.center(), window);
686  QEventPoint p(point->id, point->state, globalPos, globalPos);
687  states |= point->state;
688  if (point->uniqueId >= 0)
689  QMutableEventPoint::setUniqueId(p, QPointingDeviceUniqueId::fromNumericId(point->uniqueId));
690  QMutableEventPoint::setPressure(p, point->pressure);
691  QMutableEventPoint::setRotation(p, point->rotation);
692  QMutableEventPoint::setEllipseDiameters(p, QHighDpi::fromNativePixels(point->area.size(), window));
693  QMutableEventPoint::setVelocity(p, QHighDpi::fromNativePixels(point->velocity, window));
694 
695  // The local pos is not set: it will be calculated
696  // when the event gets processed by QGuiApplication.
697 
698  touchPoints.append(p);
699  ++point;
700  }
701 
702  // Determine the event type based on the combined point states.
703  if (type) {
705  if (states == QEventPoint::State::Pressed)
707  else if (states == QEventPoint::State::Released)
709  }
710 
711  return touchPoints;
712 }
713 
716 {
718  p.id = pt.id();
719  QRectF area(QPointF(), pt.ellipseDiameters());
720  area.moveCenter(pt.globalPosition());
721  // TODO store ellipseDiameters in QWindowSystemInterface::TouchPoint or just use QEventPoint
722  p.area = QHighDpi::toNativePixels(area, window);
723  p.pressure = pt.pressure();
724  p.state = pt.state();
725  p.velocity = QHighDpi::toNativePixels(pt.velocity(), window);
726  return p;
727 }
728 
730  const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
731 {
733  return handleTouchEvent<Delivery>(window, time, device, points, mods);
734 }
735 
736 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
737  const QList<TouchPoint> &points, Qt::KeyboardModifiers mods)
738 {
739  if (!points.size()) // Touch events must have at least one point
740  return false;
741 
742  if (!QPointingDevicePrivate::isRegistered(device)) // Disallow passing bogus, non-registered devices.
743  return false;
744 
746  QList<QEventPoint> touchPoints =
748 
749  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TouchEvent, Delivery>(window,
750  timestamp, type, device, touchPoints, mods);
751 }
752 
753 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, const QPointingDevice *device,
754  Qt::KeyboardModifiers mods)
755 {
757  return handleTouchCancelEvent<Delivery>(window, time, device, mods);
758 }
759 
760 QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
761  Qt::KeyboardModifiers mods)
762 {
763  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TouchEvent, Delivery>(window,
764  timestamp, QEvent::TouchCancel, device, QList<QEventPoint>(), mods);
765 }
766 
779 {
780  QScreen *screen = new QScreen(ps);
781 
782  if (isPrimary)
784  else
786 
789  screen->d_func()->updateHighDpi();
790 
791  emit qGuiApp->screenAdded(screen);
792 
793  if (isPrimary)
794  emit qGuiApp->primaryScreenChanged(screen);
795 }
796 
806 {
807  // Important to keep this order since the QSceen doesn't own the platform screen.
808  // The QScreen destructor will take care changing the primary screen, so no need here.
809  delete platformScreen->screen();
810  delete platformScreen;
811 }
812 
820 {
821  QScreen *newPrimaryScreen = newPrimary->screen();
822  int indexOfScreen = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen);
823  Q_ASSERT(indexOfScreen >= 0);
824  if (indexOfScreen == 0)
825  return;
826 
828  emit qGuiApp->primaryScreenChanged(newPrimaryScreen);
829 }
830 
832 {
833  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenOrientationEvent>(screen, orientation);
834 }
835 
836 void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const QRect &geometry, const QRect &availableGeometry)
837 {
838  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenGeometryEvent>(screen,
839  QHighDpi::fromNativeScreenGeometry(geometry, screen), QHighDpi::fromNative(availableGeometry,
840  screen, geometry.topLeft()));
841 }
842 
844 {
845  const QDpi effectiveDpi = QPlatformScreen::overrideDpi(QDpi{dpiX, dpiY});
846  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent>(screen,
847  effectiveDpi.first, effectiveDpi.second);
848 }
849 
851 {
852  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent>(screen, newRefreshRate);
853 }
854 
855 QT_DEFINE_QPA_EVENT_HANDLER(void, handleThemeChange, QWindow *window)
856 {
857  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ThemeChangeEvent, Delivery>(window);
858 }
859 
860 #if QT_CONFIG(draganddrop)
868 QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData,
869  const QPoint &p, Qt::DropActions supportedActions,
870  Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
871 {
873  return QGuiApplicationPrivate::processDrag(window, dropData, pos, supportedActions, buttons, modifiers);
874 }
875 
876 QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, const QMimeData *dropData,
877  const QPoint &p, Qt::DropActions supportedActions,
878  Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
879 {
881  return QGuiApplicationPrivate::processDrop(window, dropData, pos, supportedActions, buttons, modifiers);
882 }
883 #endif // QT_CONFIG(draganddrop)
884 
893 {
895 }
896 
898 {
901 }
902 
904 {
907 }
908 
910 {
911  platformSynthesizesMouse = v;
912 }
913 
915  const QPointF &local, const QPointF &global,
916  Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
917  qreal tangentialPressure, qreal rotation, int z,
918  Qt::KeyboardModifiers modifiers)
919 {
920  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEvent>(window,
921  timestamp,
924  device, buttons, pressure,
925  xTilt, yTilt, tangentialPressure, rotation, z, modifiers);
926 }
927 
929  const QPointF &local, const QPointF &global,
930  Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
931  qreal tangentialPressure, qreal rotation, int z,
932  Qt::KeyboardModifiers modifiers)
933 {
935  return handleTabletEvent(window, time, device, local, global,
936  buttons, pressure, xTilt, yTilt, tangentialPressure,
937  rotation, z, modifiers);
938 }
939 
941  int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
942  qreal tangentialPressure, qreal rotation, int z, qint64 uid,
943  Qt::KeyboardModifiers modifiers)
944 {
947  return handleTabletEvent(window, timestamp, dev, local, global, buttons, pressure,
948  xTilt, yTilt, tangentialPressure, rotation, z, modifiers);
949 }
950 
952  int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
953  qreal tangentialPressure, qreal rotation, int z, qint64 uid,
954  Qt::KeyboardModifiers modifiers)
955 {
957  return handleTabletEvent(window, time, local, global, device, pointerType, buttons, pressure,
958  xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers);
959 }
960 
962  bool inProximity, const QPointF &local, const QPointF &global,
963  Qt::MouseButtons buttons, int xTilt, int yTilt,
964  qreal tangentialPressure, qreal rotation, int z,
965  Qt::KeyboardModifiers modifiers)
966 {
967  Q_UNUSED(window);
968  Q_UNUSED(local);
969  Q_UNUSED(global);
970  Q_UNUSED(buttons);
971  Q_UNUSED(xTilt);
972  Q_UNUSED(yTilt);
973  Q_UNUSED(tangentialPressure);
975  Q_UNUSED(z);
976  Q_UNUSED(modifiers);
977  return inProximity
978  ? handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEnterProximityEvent>(timestamp, device)
979  : handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent>(timestamp, device);
980 }
981 
983  bool inProximity, const QPointF &local, const QPointF &global,
984  Qt::MouseButtons buttons, int xTilt, int yTilt,
985  qreal tangentialPressure, qreal rotation, int z,
986  Qt::KeyboardModifiers modifiers)
987 {
989  return handleTabletEnterLeaveProximityEvent(window, time, device, inProximity,
990  local, global, buttons, xTilt, yTilt,
991  tangentialPressure, rotation, z, modifiers);
992 }
993 
994 
995 bool QWindowSystemInterface::handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid)
996 {
998  QPointingDevice::PointerType(pointerType),
1000  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEnterProximityEvent>(timestamp, device);
1001 }
1002 
1003 void QWindowSystemInterface::handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid)
1004 {
1006  handleTabletEnterProximityEvent(time, deviceType, pointerType, uid);
1007 }
1008 
1009 bool QWindowSystemInterface::handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid)
1010 {
1012  QPointingDevice::PointerType(pointerType),
1014  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent>(timestamp, device);
1015 }
1016 
1017 void QWindowSystemInterface::handleTabletLeaveProximityEvent(int deviceType, int pointerType, qint64 uid)
1018 {
1020  handleTabletLeaveProximityEvent(time, deviceType, pointerType, uid);
1021 }
1022 
1023 #ifndef QT_NO_GESTURES
1025  Qt::NativeGestureType type, const QPointF &local, const QPointF &global, int fingerCount)
1026 {
1027  return handleGestureEventWithValueAndDelta(window, timestamp, device, type, {}, {}, local, global, fingerCount);
1028 }
1029 
1031  Qt::NativeGestureType type, qreal value, const QPointF &local, const QPointF &global, int fingerCount)
1032 {
1033  return handleGestureEventWithValueAndDelta(window, timestamp, device, type, value, {}, local, global, fingerCount);
1034 }
1035 
1037  Qt::NativeGestureType type, qreal value, const QPointF &delta,
1038  const QPointF &local, const QPointF &global, int fingerCount)
1039 {
1042 
1043  return handleWindowSystemEvent<QWindowSystemInterfacePrivate::GestureEvent>(window,
1044  timestamp, type, device, fingerCount, localPos, globalPos, value, delta);
1045 }
1046 #endif // QT_NO_GESTURES
1047 
1049 {
1050  handleWindowSystemEvent<QWindowSystemInterfacePrivate::PlatformPanelEvent>(w);
1051 }
1052 
1053 #ifndef QT_NO_CONTEXTMENU
1055  const QPoint &pos, const QPoint &globalPos,
1056  Qt::KeyboardModifiers modifiers)
1057 {
1058  handleWindowSystemEvent<QWindowSystemInterfacePrivate::ContextMenuEvent>(window,
1059  mouseTriggered, pos, globalPos, modifiers);
1060 }
1061 #endif
1062 
1063 #if QT_CONFIG(whatsthis)
1064 void QWindowSystemInterface::handleEnterWhatsThisEvent()
1065 {
1066  handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowSystemEvent>(
1068 }
1069 #endif
1070 
1071 #ifndef QT_NO_DEBUG_STREAM
1073 {
1074  QDebugStateSaver saver(dbg);
1075  dbg.nospace() << "TouchPoint(" << p.id << " @" << p.area << " normalized " << p.normalPosition
1076  << " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;
1077  return dbg;
1078 }
1079 #endif
1080 
1081 // ------------------ Event dispatcher functionality ------------------
1082 
1087 bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
1088 {
1090  if (!count)
1091  return false;
1092  if (!QGuiApplication::instance()) {
1093  qWarning().nospace()
1094  << "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
1095  "QGuiApplication destruction, discarding " << count << " events.";
1097  return false;
1098  }
1099  if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
1100  // Post a FlushEvents event which will trigger a call back to
1101  // deferredFlushWindowSystemEvents from the Gui thread.
1103  handleWindowSystemEvent<QWindowSystemInterfacePrivate::FlushEventsEvent, AsynchronousDelivery>(flags);
1105  } else {
1106  sendWindowSystemEvents(flags);
1107  }
1109 }
1110 
1112 {
1114 
1116  sendWindowSystemEvents(flags);
1118 }
1119 
1120 bool QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
1121 {
1122  int nevents = 0;
1123 
1129  if (!event)
1130  break;
1131 
1134  nevents++;
1135  } else {
1136  nevents++;
1138  }
1139 
1140  // Record the accepted state for the processed event
1141  // (excluding flush events). This state can then be
1142  // returned by flushWindowSystemEvents().
1145 
1146  delete event;
1147  }
1148 
1149  return (nevents > 0);
1150 }
1151 
1153 {
1155 }
1156 
1158 {
1160 }
1161 
1163 {
1165 }
1166 
1167 // --------------------- QtTestLib support ---------------------
1168 
1169 // The following functions are used by testlib, and need to be synchronous to avoid
1170 // race conditions with plugins delivering native events from secondary threads.
1171 // FIXME: It seems unnecessary to export these wrapper functions, when qtestlib could access
1172 // QWindowSystemInterface directly (by adding dependency to gui-private), see QTBUG-63146.
1173 
1174 Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global,
1175  Qt::MouseButtons state, Qt::MouseButton button,
1176  QEvent::Type type, Qt::KeyboardModifiers mods, int timestamp)
1177 {
1180  QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(window,
1181  timestamp, nativeLocal, nativeGlobal, state, button, type, mods);
1182 }
1183 
1184 Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
1185 {
1186  QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(window, t, k, mods, text, autorep, count);
1187 }
1188 
1189 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)
1190 {
1191 #if QT_CONFIG(shortcut)
1192 
1193  // FIXME: This method should not allow targeting a specific object, but should
1194  // instead forward the event to a window, which then takes care of normal event
1195  // propagation. We need to fix a lot of tests before we can refactor this (the
1196  // window needs to be exposed and active and have a focus object), so we leave
1197  // it as is for now. See QTBUG-48577.
1198 
1200 
1201  QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count);
1202  qevent.setTimestamp(timestamp);
1203 
1204  QShortcutMap &shortcutMap = QGuiApplicationPrivate::instance()->shortcutMap;
1205  if (shortcutMap.state() == QKeySequence::NoMatch) {
1206  // Try sending as QKeyEvent::ShortcutOverride first
1207  QCoreApplication::sendEvent(o, &qevent);
1208  if (qevent.isAccepted())
1209  return false;
1210  }
1211 
1212  // Then as QShortcutEvent
1213  return shortcutMap.tryShortcut(&qevent);
1214 #else
1215  Q_UNUSED(o);
1216  Q_UNUSED(timestamp);
1217  Q_UNUSED(k);
1218  Q_UNUSED(mods);
1219  Q_UNUSED(text);
1220  Q_UNUSED(autorep);
1221  Q_UNUSED(count);
1222  return false;
1223 #endif
1224 }
1225 
1226 namespace QTest
1227 {
1229  QInputDevice::Capabilities caps = QInputDevice::Capability::Position)
1230  {
1231  static qint64 nextId = 0x100000000;
1232  QPointingDevice *ret = new QPointingDevice(QLatin1String("test touch device"), nextId++,
1234  caps, 8, 0);
1236  return ret;
1237  }
1238 }
1239 
1241  const QList<QEventPoint> &points,
1242  Qt::KeyboardModifiers mods = Qt::NoModifier)
1243 {
1244  QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window, device,
1246 }
1247 
1248 
The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.
The QAtomicInt class provides platform-independent atomic operations on int.
Definition: qatomic.h:158
void storeRelaxed(T newValue) noexcept
Definition: qbasicatomic.h:91
T loadRelaxed() const noexcept
Definition: qbasicatomic.h:90
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
static QCoreApplication * instance()
static bool sendEvent(QObject *receiver, QEvent *event)
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
QDebug & nospace()
Definition: qdebug.h:113
Convenience class for custom QDebug operators.
Definition: qdebug.h:176
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:49
qint64 elapsed() const noexcept
@ NonClientAreaMouseButtonDblClick
Definition: qcoreevent.h:228
@ ShortcutOverride
Definition: qcoreevent.h:171
@ KeyPress
Definition: qcoreevent.h:77
@ TouchCancel
Definition: qcoreevent.h:277
@ TouchEnd
Definition: qcoreevent.h:256
@ TouchUpdate
Definition: qcoreevent.h:255
@ TouchBegin
Definition: qcoreevent.h:254
@ MouseButtonDblClick
Definition: qcoreevent.h:75
bool isAccepted() const
Definition: qcoreevent.h:311
@ ExcludeUserInputEvents
Definition: qeventloop.h:60
The QEventPoint class provides information about a point in a QPointerEvent.
Definition: qeventpoint.h:56
static QWindow * focusWindow()
static QPlatformIntegration * platformIntegration()
static QAbstractEventDispatcher * qt_qpa_core_dispatcher()
static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result)
static QGuiApplicationPrivate * instance()
static QList< QScreen * > screen_list
static Qt::KeyboardModifiers modifier_buttons
static void resetCachedDevicePixelRatio()
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
static void updateHighDpiScaling()
The QInputDevice class describes a device from which a QInputEvent originates.
Definition: qinputdevice.h:53
static void registerDevice(const QInputDevice *dev)
static bool isRegistered(const QInputDevice *dev)
virtual void setTimestamp(quint64 timestamp)
Definition: qevent.h:88
The QKeyEvent class describes a key event.
Definition: qevent.h:471
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
qsizetype size() const noexcept
Definition: qlist.h:414
void swapItemsAt(qsizetype i, qsizetype j)
Definition: qlist.h:679
const_iterator constBegin() const noexcept
Definition: qlist.h:630
void prepend(rvalue_ref t)
Definition: qlist.h:484
void reserve(qsizetype size)
Definition: qlist.h:757
void append(parameter_type t)
Definition: qlist.h:469
const_iterator constEnd() const noexcept
Definition: qlist.h:631
The QMimeData class provides a container for data that records information about its MIME type.
Definition: qmimedata.h:52
The QMutex class provides access serialization between threads.
Definition: qmutex.h:285
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes.
Definition: qmutex.h:317
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
static QDpi overrideDpi(const QDpi &in)
QScreen * screen() const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
constexpr bool isNull() const noexcept
Definition: qpoint.h:150
constexpr int x() const noexcept
Definition: qpoint.h:155
constexpr int y() const noexcept
Definition: qpoint.h:160
The QPointer class is a template class that provides guarded pointers to QObject.
Definition: qpointer.h:54
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static const QPointingDevice * primaryPointingDevice(const QString &seatName=QString())
static const QPointingDevice * tabletDevice(QInputDevice::DeviceType deviceType, QPointingDevice::PointerType pointerType, QPointingDeviceUniqueId uniqueId)
static QPointingDeviceUniqueId fromNumericId(qint64 id)
The QRectF class defines a finite rectangle in the plane using floating point precision.
Definition: qrect.h:511
constexpr void moveCenter(const QPointF &p) noexcept
Definition: qrect.h:735
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
constexpr QPoint topLeft() const noexcept
Definition: qrect.h:248
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:63
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition: qscreen.h:68
bool tryShortcut(QKeyEvent *e)
QKeySequence::SequenceMatch state()
The QString class provides a Unicode character string.
Definition: qstring.h:388
static QThread * currentThread()
Definition: qthread.cpp:879
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:130
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
The QWindow class represents a window in the underlying windowing system.
Definition: qwindow.h:99
virtual bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *event)
static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result)
Passes a native event identified by eventType to the window.
static bool handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value, const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount=2)
static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry)
static bool handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value, const QPointF &local, const QPointF &global, int fingerCount=2)
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1, bool tryShortcutOverride=true)
static void handleFileOpenEvent(const QString &fileName)
static void handleContextMenuEvent(QWindow *window, bool mouseTriggered, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers)
static void handlePrimaryScreenChanged(QPlatformScreen *newPrimary)
static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
static void setSynchronousWindowSystemEvents(bool enable)
static void registerInputDevice(const QInputDevice *device)
static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid)
static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary=false)
static void handlePlatformPanelEvent(QWindow *window)
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local=QPointF(), const QPointF &global=QPointF())
static void handleScreenRemoved(QPlatformScreen *screen)
static bool handleFrameStrutMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid)
static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation)
static bool handleShortcutEvent(QWindow *window, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static bool handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, const QPointF &local, const QPointF &global, int fingerCount=0)
static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate)
static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, bool inProximity, const QPointF &local=QPointF(), const QPointF &global=QPointF(), Qt::MouseButtons buttons={}, int xTilt=0, int yTilt=0, qreal tangentialPressure=0, qreal rotation=0, int z=0, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
static void handleEnterEvent(QWindow *window, const QPointF &local=QPointF(), const QPointF &global=QPointF())
static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY)
static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
ExposeEvent(QWindow *window, const QRegion &region)
GeometryChangeEvent(QWindow *window, const QRect &newGeometry)
WindowSystemEvent * peekAtFirstOfType(EventType t) const
static QWindowSystemEventHandler * eventHandler
static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler)
static WindowSystemEvent * getWindowSystemEvent()
static void removeWindowSystemEvent(WindowSystemEvent *event)
static QWindowSystemInterface::TouchPoint toNativeTouchPoint(const QEventPoint &point, const QWindow *window)
static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler)
static WindowSystemEventList windowSystemEventQueue
static WindowSystemEvent * getNonUserInputWindowSystemEvent()
static WindowSystemEvent * peekWindowSystemEvent(EventType t)
static QList< QEventPoint > fromNativeTouchPoints(const QList< QWindowSystemInterface::TouchPoint > &points, const QWindow *window, QEvent::Type *type=nullptr)
static QList< QWindowSystemInterface::TouchPoint > toNativeTouchPoints(const EventPointList &pointList, const QWindow *window)
float rotation
QRhiGraphicsPipeline * ps
QPushButton * button
[2]
double e
else opt state
[0]
#define local
Definition: zutil.h:30
#define true
Definition: ftrandom.c:51
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
T toNativePixels(const T &value, const C *context)
T toNativeLocalPosition(const T &value, const C *context)
T toNativeGlobalPosition(const T &value, const C *context)
T fromNativeLocalPosition(const T &value, const C *context)
T fromNativeGlobalPosition(const T &value, const C *context)
QRect fromNativeScreenGeometry(const QRect &nativeScreenGeometry, const QScreen *screen)
QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QWindow *window)
T fromNativePixels(const T &value, const C *context)
T fromNative(const T &value, qreal scaleFactor, QPoint origin=QPoint(0, 0))
T fromNativeWindowGeometry(const T &value, const C *context)
[15]
Definition: tst_encoder.cpp:33
Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType=QInputDevice::DeviceType::TouchScreen, QInputDevice::Capabilities caps=QInputDevice::Capability::Position)
@ WindowNoState
Definition: qnamespace.h:277
MouseButton
Definition: qnamespace.h:81
@ Horizontal
Definition: qnamespace.h:124
@ Vertical
Definition: qnamespace.h:125
MouseEventSource
Definition: qnamespace.h:1703
ScreenOrientation
Definition: qnamespace.h:296
@ NoModifier
Definition: qnamespace.h:1074
ApplicationState
Definition: qnamespace.h:287
NativeGestureType
Definition: qnamespace.h:1663
ScrollPhase
Definition: qnamespace.h:1695
@ ScrollUpdate
Definition: qnamespace.h:1698
FocusReason
Definition: qnamespace.h:1360
#define QString()
Definition: parse-defines.h:51
EGLOutputLayerEXT EGLint EGLAttrib value
unsigned int quint32
Definition: qglobal.h:288
unsigned long ulong
Definition: qglobal.h:335
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
long long qint64
Definition: qglobal.h:298
unsigned short ushort
Definition: qglobal.h:333
ptrdiff_t qintptr
Definition: qglobal.h:309
#define qGuiApp
QPair< qreal, qreal > QDpi
@ text
#define qWarning
Definition: qlogging.h:179
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLenum type
Definition: qopengl.h:270
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: qopengl.h:270
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLuint64 GLenum void * handle
GLuint64 key
GLboolean r
[2]
GLfloat GLfloat GLfloat w
[0]
GLuint GLuint end
GLenum GLenum GLsizei count
GLbitfield flags
GLboolean enable
GLsizei GLsizei GLchar * source
struct _cl_event * event
Definition: qopenglext.h:2998
GLfixed GLfixed GLint GLint GLfixed points
Definition: qopenglext.h:5206
GLdouble GLdouble t
[9]
Definition: qopenglext.h:243
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
GLuint * states
Definition: qopenglext.h:9584
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
#define Q_ASSERT_X(cond, x, msg)
Definition: qrandom.cpp:85
#define emit
Definition: qtmetamacros.h:85
#define leave(x)
Definition: qurlquery.cpp:243
Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< QEventPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
QPointer< QWindow > qt_last_mouse_receiver
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p)
#define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName,...)
Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods, int timestamp)
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)
Q_UNUSED(salary)
[21]
QScreen * screen
[1]
Definition: main.cpp:76
QUrl url("http://www.example.com/List of holidays.xml")
[0]
QTime time
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
Definition: main.cpp:58
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition: qlist.h:966
static bool handleEvent(Args ...)
Global global
Definition: main.cpp:114