KWayland::Client::ConnectionThread
#include <connection_thread.h>

Signals | |
void | connected () |
void | connectionDied () |
void | errorOccurred () |
void | eventsRead () |
void | failed () |
Public Slots | |
void | flush () |
void | initConnection () |
Public Member Functions | |
ConnectionThread (QObject *parent=nullptr) | |
wl_display * | display () |
int | errorCode () const |
bool | hasError () const |
void | roundtrip () |
void | setSocketFd (int fd) |
void | setSocketName (const QString &socketName) |
QString | socketName () const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static QVector< ConnectionThread * > | connections () |
static ConnectionThread * | fromApplication (QObject *parent=nullptr) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions | |
ConnectionThread (wl_display *display, QObject *parent) | |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
![]() | |
objectName | |
![]() | |
typedef | QObjectList |
Detailed Description
Creates and manages the connection to a Wayland server.
The purpose of this class is to create the connection to a Wayland server and to manage it. As the name suggests it's intended to move instances of this class into a dedicated thread. This also means that this class doesn't inherit QThread. In order to use it in a threaded way one needs to create a QThread and move the object there:
To finalize the initialization of the connection one needs to call ::initConnection. This starts an asynchronous connection initialization. In case the initialization succeeds the signal ::connected will be emitted, otherwise ::failed will be emitted:
This class is also responsible for dispatching events. Whenever new data is available on the Wayland socket, it will be dispatched and the signal ::eventsRead is emitted. This allows further event queues in other threads to also dispatch their events.
Furthermore this class flushes the Wayland connection whenever the QAbstractEventDispatcher is about to block.
To disconnect the connection to the Wayland server one should delete the instance of this class and quit the dedicated thread:
In addition the ConnectionThread provides integration with QtWayland QPA plugin. For that it provides a static factory method:
The semantics of the ConnectionThread are slightly changed if it's integrated with QtWayland. The ConnectionThread does not hold the connection, does not emit connected or released signals (one can safely assume that the connection is valid when integrating with the Qt application), does not dispatch events. Given that the use case of the ConnectionThread is rather limited to a convenient API around wl_display to allow easily setup an own Registry in a QtWayland powered application. Also moving the ConnectionThread to a different thread is not necessarily recommended in that case as QtWayland holds it's connection in an own thread anyway.
Definition at line 106 of file connection_thread.h.
Member Function Documentation
◆ connected
|
signal |
Emitted once a connection to a Wayland server is established.
Normally emitted after invoking initConnection(), but might also be emitted after re-connecting to another server.
◆ connectionDied
|
signal |
Emitted if the Wayland server connection dies.
If the socket reappears, it is tried to reconnect.
◆ connections()
|
static |
- Returns
- all connections created in this application
- Since
- 5.37
Definition at line 310 of file connection_thread.cpp.
◆ display()
wl_display * KWayland::Client::ConnectionThread::display | ( | ) |
The display this ConnectionThread is connected to.
As long as there is no connection this method returns null
.
- See also
- initConnection
Definition at line 263 of file connection_thread.cpp.
◆ errorCode()
int KWayland::Client::ConnectionThread::errorCode | ( | ) | const |
- Returns
- the error code of the last occurred error or
0
if the connection doesn't have an error
- See also
- hasError
- errorOccurred
- Since
- 5.23
Definition at line 305 of file connection_thread.cpp.
◆ errorOccurred
|
signal |
The Wayland connection experienced a fatal error.
The ConnectionThread is no longer valid, no requests may be sent. This has the same effects as connectionDied.
- Since
- 5.23
◆ eventsRead
|
signal |
Emitted whenever new events are ready to be read.
◆ failed
|
signal |
Emitted if connecting to a Wayland server failed.
◆ flush
|
slot |
Explicitly flush the Wayland display.
- Since
- 5.3
Definition at line 273 of file connection_thread.cpp.
◆ fromApplication()
|
static |
Creates a ConnectionThread for the used QGuiApplication.
This is an integration feature for QtWayland. On non-wayland platforms this method returns nullptr
.
The returned ConnectionThread will be fully setup, which means it manages a wl_display. There is no need to initConnection and the connected or failed signals won't be emitted. When the created ConnectionThread gets destroyed the managed wl_display won't be disconnected as that's managed by Qt.
The returned ConnectionThread is not able to detect (protocol) error. The signal errorOccurred won't be emitted, hasError will return false
, even if the actual connection held by QtWayland is on error. The behavior of QtWayland is to exit the application on error.
- Since
- 5.4
Definition at line 220 of file connection_thread.cpp.
◆ hasError()
bool KWayland::Client::ConnectionThread::hasError | ( | ) | const |
- Returns
- whether the Wayland connection experienced an error
- See also
- errorCode
- errorOccurred
- Since
- 5.23
Definition at line 300 of file connection_thread.cpp.
◆ initConnection
|
slot |
Initializes the connection in an asynchronous way.
In case the connection gets established the signal ::connected will be emitted, on failure the signal ::failed will be emitted.
Definition at line 235 of file connection_thread.cpp.
◆ roundtrip()
void KWayland::Client::ConnectionThread::roundtrip | ( | ) |
Trigger a blocking roundtrip to the Wayland server.
Ensures that all events are processed before returning to the event loop.
- Since
- 5.4
Definition at line 281 of file connection_thread.cpp.
◆ setSocketFd()
void KWayland::Client::ConnectionThread::setSocketFd | ( | int | fd | ) |
Sets the socket fd
to connect to.
Only applies if called before calling initConnection. If this method is invoked, the connection will be created on the file descriptor and not on the socket name passed through setSocketName or through the default environment variable WAYLAND_DISPLAY.
- See also
- setSocketName
Definition at line 254 of file connection_thread.cpp.
◆ setSocketName()
void KWayland::Client::ConnectionThread::setSocketName | ( | const QString & | socketName | ) |
Sets the socketName
to connect to.
Only applies if called before calling initConnection. The default socket name is derived from environment variable WAYLAND_DISPLAY and if not set is hard coded to "wayland-0".
The socket name will be ignored if a file descriptor has been set through setSocketFd.
- See also
- setSocketFd
Definition at line 245 of file connection_thread.cpp.
◆ socketName()
QString KWayland::Client::ConnectionThread::socketName | ( | ) | const |
- Returns
- the name of the socket it connects to.
Definition at line 268 of file connection_thread.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 04:08:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.