Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandcompositor_p.h
Go to the documentation of this file.
1// Copyright (C) 2017-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// Copyright (C) 2017 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:critical reason:network-protocol
5
6#ifndef QWAYLANDCOMPOSITOR_P_H
7#define QWAYLANDCOMPOSITOR_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h>
21#include <QtWaylandCompositor/QWaylandCompositor>
22#include <QtCore/private/qobject_p.h>
23#include <QtCore/QSet>
24#include <QtCore/QElapsedTimer>
25
26#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
27
28#include <QtCore/qpointer.h>
29
30#include <vector>
31
32#if QT_CONFIG(xkbcommon)
33#include <QtGui/private/qxkbcommon_p.h>
34#endif
35
36QT_BEGIN_NAMESPACE
37
38namespace QtWayland {
40 class ClientBufferIntegration;
41 class ServerBufferIntegration;
43 class BufferManager;
44}
45
46class QWindowSystemEventHandler;
47class QWaylandSurface;
48
49class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandCompositorPrivate : public QObjectPrivate, public QtWaylandServer::wl_compositor, public QtWaylandServer::wl_subcompositor
50{
51public:
52 static QWaylandCompositorPrivate *get(QWaylandCompositor *compositor) { return compositor->d_func(); }
53
54 QWaylandCompositorPrivate(QWaylandCompositor *compositor);
55 ~QWaylandCompositorPrivate() override;
56
57#if QT_CONFIG(xkbcommon)
58 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
59#endif
60
61 void preInit();
62 void init();
63
64 void destroySurface(QWaylandSurface *surface);
65 void unregisterSurface(QWaylandSurface *surface);
66
67 QWaylandOutput *defaultOutput() const { return outputs.size() ? outputs.first() : nullptr; }
68
69 inline const QList<QtWayland::ClientBufferIntegration *> clientBufferIntegrations() const;
70 inline QtWayland::ServerBufferIntegration *serverBufferIntegration() const;
71
72#if QT_CONFIG(wayland_datadevice)
73 QtWayland::DataDeviceManager *dataDeviceManager() const { return data_device_manager; }
74#endif
75 QtWayland::BufferManager *bufferManager() const { return buffer_manager; }
76 void feedRetainedSelectionData(QMimeData *data);
77
78 QWaylandPointer *callCreatePointerDevice(QWaylandSeat *seat)
79 { return q_func()->createPointerDevice(seat); }
80 QWaylandKeyboard *callCreateKeyboardDevice(QWaylandSeat *seat)
81 { return q_func()->createKeyboardDevice(seat); }
82 QWaylandTouch *callCreateTouchDevice(QWaylandSeat *seat)
83 { return q_func()->createTouchDevice(seat); }
84
85 inline void addClient(QWaylandClient *client);
86 inline void removeClient(QWaylandClient *client);
87
88 void addPolishObject(QObject *object);
89
90 inline void addOutput(QWaylandOutput *output);
91 inline void removeOutput(QWaylandOutput *output);
92
93 void connectToExternalSockets();
94
95 virtual QWaylandSeat *seatFor(QInputEvent *inputEvent);
96
97protected:
98 void compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) override;
99 void compositor_create_region(wl_compositor::Resource *resource, uint32_t id) override;
100
101 void subcompositor_get_subsurface(wl_subcompositor::Resource *resource, uint32_t id, struct ::wl_resource *surface, struct ::wl_resource *parent) override;
102
103 virtual QWaylandSurface *createDefaultSurface();
104protected:
105 void initializeHardwareIntegration();
106 void initializeExtensions();
107 void initializeSeats();
108
109 void loadClientBufferIntegration();
110 void loadServerBufferIntegration();
111
112 QByteArray socket_name;
113 QList<int> externally_added_socket_fds;
114 struct wl_display *display = nullptr;
115 bool ownsDisplay = false;
116 QVector<QWaylandCompositor::ShmFormat> shmFormats;
117
118 QList<QWaylandSeat *> seats;
119 QList<QWaylandOutput *> outputs;
120
121 QList<QWaylandSurface *> all_surfaces;
122
123#if QT_CONFIG(wayland_datadevice)
124 QtWayland::DataDeviceManager *data_device_manager = nullptr;
125#endif
126 QtWayland::BufferManager *buffer_manager = nullptr;
127
128 QElapsedTimer timer;
129
130 wl_event_loop *loop = nullptr;
131
132 QList<QWaylandClient *> clients;
133
134#if QT_CONFIG(opengl)
135 bool use_hw_integration_extension = true;
136 QScopedPointer<QtWayland::HardwareIntegration> hw_integration;
137 QScopedPointer<QtWayland::ServerBufferIntegration> server_buffer_integration;
138#endif
139 QList<QtWayland::ClientBufferIntegration*> client_buffer_integrations;
140
141 QScopedPointer<QWindowSystemEventHandler> eventHandler;
142
143 bool retainSelection = false;
144 bool preInitialized = false;
145 bool initialized = false;
146 std::vector<QPointer<QObject> > polish_objects;
147
148#if QT_CONFIG(xkbcommon)
149 QXkbCommon::ScopedXKBContext mXkbContext;
150#endif
151
152 Q_DECLARE_PUBLIC(QWaylandCompositor)
153 Q_DISABLE_COPY(QWaylandCompositorPrivate)
154};
155
156const QList<QtWayland::ClientBufferIntegration *> QWaylandCompositorPrivate::clientBufferIntegrations() const
157{
158 return client_buffer_integrations;
159}
160
161QtWayland::ServerBufferIntegration * QWaylandCompositorPrivate::serverBufferIntegration() const
162{
163#if QT_CONFIG(opengl)
164 return server_buffer_integration.data();
165#else
166 return 0;
167#endif
168}
169
170void QWaylandCompositorPrivate::addClient(QWaylandClient *client)
171{
172 Q_ASSERT(!clients.contains(client));
173 clients.append(client);
174}
175
176void QWaylandCompositorPrivate::removeClient(QWaylandClient *client)
177{
178 Q_ASSERT(clients.contains(client));
179 clients.removeOne(client);
180}
181
182void QWaylandCompositorPrivate::addOutput(QWaylandOutput *output)
183{
184 Q_ASSERT(output);
185 Q_Q(QWaylandCompositor);
186 if (outputs.contains(output))
187 return;
188 outputs.append(output);
189 emit q->outputAdded(output);
190 if (!outputs.isEmpty() && outputs.first() == output)
191 emit q->defaultOutputChanged();
192}
193
194void QWaylandCompositorPrivate::removeOutput(QWaylandOutput *output)
195{
196 Q_ASSERT(output);
197 Q_ASSERT(outputs.count(output) == 1);
198 Q_Q(QWaylandCompositor);
199 bool wasDefault = !outputs.isEmpty() && outputs.first() == output;
200 if (!outputs.removeOne(output))
201 return;
202 emit q->outputRemoved(output);
203 if (wasDefault)
204 emit q->defaultOutputChanged();
205}
206
207QT_END_NAMESPACE
208
209#endif //QWAYLANDCOMPOSITOR_P_H
\inmodule QtSql
void handleKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *ke)
bool sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) override
WindowSystemEventHandler(QWaylandCompositor *c)
QtWayland::ClientBuffer * createBufferFor(wl_resource *buffer) override
void initializeHardware(wl_display *display) override
Combined button and popup list for selecting options.
#define Q_PUBLIC_LOGGING_CATEGORY(name,...)
const QLoggingCategory & qLcWaylandCompositorTextInput()
const QLoggingCategory & qLcWaylandCompositorInputMethods()