QWindowSystemInterface Class

The QWindowSystemInterface provides an event queue for the QPA platform. More...

Header: #include <QWindowSystemInterface>

Static Public Members

bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)
QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF &global = QPointF())
void handlePrimaryScreenChanged(QPlatformScreen *newPrimary)
void handleScreenAdded(QPlatformScreen *platformScreen, bool isPrimary = false)
void handleScreenRemoved(QPlatformScreen *platformScreen)
bool handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text = QString(), bool autorepeat = false, ushort count = 1)
void registerInputDevice(const QInputDevice *device)

Detailed Description

\since5.0 \internal \preliminary \ingroup qpa

The platform plugins call the various functions to notify about events. The events are queued until sendWindowSystemEvents() is called by the event dispatcher.

Member Function Documentation

[static] bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents)

Make Qt Gui process all events on the event queue immediately. Return the accepted state for the last event on the queue.

[static] QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)

Drag and drop events are sent immediately.

### FIXME? Perhaps DnD API should add some convenience APIs that are more intuitive for the possible DND operations. Here passing nullptr as drop data is used to indicate that drop was canceled and QDragLeaveEvent should be sent as a result.

[static] void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF &global = QPointF())

This method can be used to ensure leave and enter events are both in queue when moving from one QWindow to another. This allows QWindow subclasses to check for a queued enter event when handling the leave event (QWindowSystemInterfacePrivate::peekWindowSystemEvent) to determine where mouse went and act accordingly. E.g. QWidgetWindow needs to know if mouse cursor moves between windows in same window hierarchy.

[static] void QWindowSystemInterface::handlePrimaryScreenChanged(QPlatformScreen *newPrimary)

Should be called whenever the primary screen changes.

When the screen specified as primary changes, this method will notify QGuiApplication and emit the QGuiApplication::primaryScreenChanged signal.

[static] void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *platformScreen, bool isPrimary = false)

Should be called by the implementation whenever a new screen is added.

The first screen added will be the primary screen, used for default-created windows, GL contexts, and other resources unless otherwise specified.

This adds the screen to QGuiApplication::screens(), and emits the QGuiApplication::screenAdded() signal.

The screen should be deleted by calling QWindowSystemInterface::handleScreenRemoved().

[static] void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen)

Should be called by the implementation whenever a screen is removed.

This removes the screen from QGuiApplication::screens(), and deletes it.

Failing to call this and manually deleting the QPlatformScreen instead may lead to a crash due to a pure virtual call.

[static] bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text = QString(), bool autorepeat = false, ushort count = 1)

w == 0 means that the event is in global coords only, local will be ignored in this case

[static] void QWindowSystemInterface::registerInputDevice(const QInputDevice *device)

\internalRegister a new input device.

It is expected that every platform plugin will discover available input devices at startup, and whenever a new device is plugged in, if possible. If that's not possible, then it at least must call this function before sending an event whose QInputEvent::source() is this device.

When a device is unplugged, the platform plugin should destroy the corresponding QInputDevice instance. There is no unregisterInputDevice() function, because it's enough for the destructor to call QInputDevicePrivate::unregisterDevice(); while other parts of Qt can connect to the QObject::destroyed() signal to be notified when a device is unplugged or otherwise destroyed.