Warning, file /plasma/kwin/src/wayland/display.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QList> 0012 #include <QObject> 0013 0014 #include "clientconnection.h" 0015 0016 struct wl_client; 0017 struct wl_display; 0018 0019 namespace KWaylandServer 0020 { 0021 /** 0022 * @short KWayland Server. 0023 * 0024 * This namespace groups all classes related to the Server module. 0025 * 0026 * The main entry point into the KWaylandServer API is the Display class. 0027 * It allows to create a Wayland server and create various global objects on it. 0028 * 0029 * KWaylandServer is an API to easily create a head-less Wayland server with a 0030 * Qt style API. 0031 * 0032 * @see Display 0033 */ 0034 0035 class ClientBuffer; 0036 class ClientConnection; 0037 class DisplayPrivate; 0038 class OutputInterface; 0039 class OutputDeviceV2Interface; 0040 class SeatInterface; 0041 0042 /** 0043 * @brief Class holding the Wayland server display loop. 0044 * 0045 * @todo Improve documentation 0046 */ 0047 class KWIN_EXPORT Display : public QObject 0048 { 0049 Q_OBJECT 0050 Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged) 0051 public: 0052 explicit Display(QObject *parent = nullptr); 0053 virtual ~Display(); 0054 0055 /** 0056 * Adds a socket with the given @p fileDescriptor to the Wayland display. This function 0057 * returns @c true if the socket has been added successfully; otherwise returns @c false. 0058 * 0059 * The compositor can call this function even after the display has been started. 0060 * @arg socketName can optionally be parsed to store the socket name represented by the given file-descriptor 0061 * 0062 * @see start() 0063 */ 0064 bool addSocketFileDescriptor(int fileDescriptor, const QString &socketName = QString()); 0065 /** 0066 * Adds a UNIX socket with the specified @p name to the Wayland display. This function 0067 * returns @c true if the socket has been added successfully; otherwise returns @c false. 0068 * 0069 * If the specified socket name @p name is empty, the display will pick a free socket with 0070 * a filename "wayland-%d". 0071 * 0072 * The compositor can call this function even after the display has been started. 0073 * 0074 * @see start() 0075 */ 0076 bool addSocketName(const QString &name = QString()); 0077 0078 /** 0079 * Returns the list of socket names that the display listens for client connections. 0080 */ 0081 QStringList socketNames() const; 0082 0083 quint32 serial(); 0084 quint32 nextSerial(); 0085 0086 /** 0087 * Start accepting client connections. If the display has started successfully, this 0088 * function returns @c true; otherwise @c false is returned. 0089 */ 0090 bool start(); 0091 void dispatchEvents(); 0092 0093 /** 0094 * Create a client for the given file descriptor. 0095 * 0096 * The client is created as if it connected through the normal server 0097 * socket. This method can be used to create a connection bypassing the 0098 * normal socket connection. It's recommended to use together with 0099 * socketpair and pass the other side of the socket to the client. 0100 * 0101 * @param fd The file descriptor for the socket to the client 0102 * @returns The new ClientConnection or @c null on failure. 0103 */ 0104 ClientConnection *createClient(int fd); 0105 0106 operator wl_display *(); 0107 operator wl_display *() const; 0108 bool isRunning() const; 0109 0110 void createShm(); 0111 /** 0112 * @returns All SeatInterface currently managed on the Display. 0113 */ 0114 QVector<SeatInterface *> seats() const; 0115 QList<OutputDeviceV2Interface *> outputDevices() const; 0116 QList<OutputInterface *> outputs() const; 0117 QVector<OutputInterface *> outputsIntersecting(const QRect &rect) const; 0118 0119 /** 0120 * Gets the ClientConnection for the given @p client. 0121 * If there is no ClientConnection yet for the given @p client, it will be created. 0122 * @param client The native client for which the ClientConnection is retrieved 0123 * @return The ClientConnection for the given native client 0124 */ 0125 ClientConnection *getConnection(wl_client *client); 0126 QVector<ClientConnection *> connections() const; 0127 0128 /** 0129 * Set the EGL @p display for this Wayland display. 0130 * The EGLDisplay can only be set once and must be alive as long as the Wayland display 0131 * is alive. The user should have set up the binding between the EGLDisplay and the 0132 * Wayland display prior to calling this method. 0133 * 0134 * @see eglDisplay 0135 */ 0136 void setEglDisplay(void *display); 0137 /** 0138 * @returns the EGLDisplay used for this Wayland display or EGL_NO_DISPLAY if not set. 0139 * @see setEglDisplay 0140 */ 0141 void *eglDisplay() const; 0142 0143 /** 0144 * Returns the client buffer with the specified @a resource. Returns @c null if there's 0145 * no such a buffer. 0146 */ 0147 ClientBuffer *clientBufferForResource(wl_resource *resource) const; 0148 0149 private Q_SLOTS: 0150 void flush(); 0151 0152 Q_SIGNALS: 0153 void socketNamesChanged(); 0154 void runningChanged(bool); 0155 void clientConnected(KWaylandServer::ClientConnection *); 0156 void clientDisconnected(KWaylandServer::ClientConnection *); 0157 0158 private: 0159 friend class DisplayPrivate; 0160 std::unique_ptr<DisplayPrivate> d; 0161 }; 0162 0163 }