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
qtwaylandcompositor-overview.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page qtwaylandcompositor-index.html
6 \title Qt Wayland Compositor
7 \brief An API to develop display servers that support the Wayland protocol.
8
9 The Qt Wayland Compositor is a module that provides convenient and powerful
10 QML and C++ APIs for developing custom display servers based on the
11 \l {https://wayland.freedesktop.org/}{Wayland} protocol. The display server,
12 often called a compositor, displays content from client applications that
13 support the Wayland protocol.
14
15 Wayland's design philosophy is to keep the core protocol simple and minimal.
16 Developers can then expand on this core protocol with use-case-specific
17 extensions. Qt Wayland Compositor supports many common extensions by default,
18 and also has APIs to enable the creation of new, custom extensions.
19
20 Typically, a compositor written with Qt Wayland Compositor becomes a
21 subsystem inside a larger application manager process. Qt Wayland Compositor
22 provides the APIs to communicate with clients and display their content on
23 the screen. The QML APIs contain high-level APIs that easily integrate with
24 the rest of Qt, enabling convenient animations, effects, and UI through
25 Qt Quick. There are also C++ APIs available - if you need more low-level
26 access.
27
28 An application manager would typically implement additional features such as
29 application life cycle, virtual keyboard input, security, and Inter-Process
30 Communication (IPC). Qt provides the APIs that can be used to develop the
31 remaining parts of an application manager in other modules. The
32 \l {https://www.qt.io/qt-automotive-suite/}{Qt Automotive Suite} provides
33 \l{https://doc.qt.io/QtApplicationManager}{Qt Application Manager}, which is a complete application manager that
34 includes a compositor developed using Qt Wayland Compositor.
35
36 For more information on Wayland, see \l{Wayland and Qt}.
37
38 \section1 Features of Qt Wayland Compositor
39
40 The Qt Wayland Compositor includes features necessary to create a compositor:
41
42 \list
43 \li A QML API to display and manipulate client content, fully integrated
44 with all the features in Qt Quick.
45 \li A C++ API for low-level access and control.
46 \li Support for common extensions, including XDG Shell and IVI Application.
47 \li APIs to easily expand the support for custom extensions.
48 \endlist
49
50 \section1 Environment Variables and Command-line Arguments
51
52 The Qt Wayland Compositor recognizes the following environment variables and
53 command-line arguments:
54
55 \list
56 \li Environment variables:
57 \list
58 \li \b QT_WAYLAND_HARDWARE_INTEGRATION Selects the hardware integration
59 plugin to use.
60 \li \b QT_WAYLAND_CLIENT_BUFFER_INTEGRATION Selects the client buffer
61 integration plugin to use.
62 \li \b QT_WAYLAND_SERVER_BUFFER_INTEGRATION Selects the server
63 integration plugin to use.
64 \li \b QT_IVI_SURFACE_ID Specifies the IVI surface ID for the client's surface
65 in IVI-compositor environments.
66 \endlist
67 \li Command-line arguments:
68 \list
69 \li \c{--wayland-socket-name} Overrides the default socket name used for
70 communicating with clients.
71 \endlist
72 \endlist
73
74 \section1 Running the Wayland compositor
75
76 As long as it does not depend on any unavailable platform-specific features, the compositor can
77 easily be tested on an X11-based desktop system. This can be useful during development, both for
78 simplified debugging and efficient turn-around on trying out new features.
79
80 Qt Wayland supports several backends for sharing graphics buffers between clients and the
81 server. The main one is:
82
83 \list
84 \li \c{wayland-egl}: This is the default backend and should be preferred whenever possible.
85 It requires support in the OpenGL driver on the system for this to work.
86 \endlist
87
88 Other backends may be selected by setting the \c QT_WAYLAND_CLIENT_BUFFER_INTEGRATION environment variable.
89
90 \note If Qt Wayland Compositor is unable to initialize the client buffer backend, then it will
91 fall back to using the "shared memory" backend (based on \c{wl_shm}) as a fail-safe. This backend
92 will use CPU memory for sharing the graphics buffers and copy the data back and forth as needed.
93 This has performance implications, especially on high density screens and limited graphics
94 hardware. When investigating performance issues with Qt Wayland Compositor, start by checking that
95 the correct client buffer integration is used.
96
97 Also bear in mind that if your system is already running a Wayland compositor, you may have to set
98 \c XDG_RUNTIME_DIR to point to a different location. If this is the case, you will see warnings
99 when starting the compositor. The \c XDG_RUNTIME_DIR can point to any accessible location which
100 is not already in use.
101
102 For instance, if you want to run the \l{Fancy Compositor}{fancy-compositor}
103 example with the \c wayland-egl backend, you could use the following command line:
104
105 \code
106 % XDG_RUNTIME_DIR=~/my_temporary_runtime QT_XCB_GL_INTEGRATION=xcb_egl QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=wayland-egl ./fancy-compositor
107 \endcode
108
109 The client can subsequently be run on the compositor by setting the same \c XDG_RUNTIME_DIR and
110 by passing "-platform wayland" as a command line argument. The \c QT_QPA_PLATFORM environment
111 variable can also be used to select the Wayland QPA plugin on the client side.
112
113 \note In most cases, the client will adapt to the same OpenGL as the server when it connects.
114 However, when running with the EGL backend on some specific drivers, it is required that the
115 initialization happens earlier. If you encounter this problem, you may pass
116 "-platform wayland-egl" instead to pre-initialize the client to EGL.
117
118 \section1 Troubleshooting
119
120 Sometimes, when you are developing a complex compositor, you may encounter issues that require
121 further investigation.
122
123 Setting the \c WAYLAND_DEBUG environment variable to "1" will enable log output for the Wayland
124 library itself. This can be very useful, for example, when debugging custom extensions to the
125 Wayland protocol. It will show you exactly which events and requests are being passed between
126 the client and the server, as well as timestamps for these.
127
128 In addition, Qt has logging categories \c qt.waylandcompositor.* and \c qt.qpa.wayland.* to
129 enable additional logging. The latter should be set on the client side, as it enables logging
130 from the Wayland QPA plugin.
131
132 \section1 Examples
133
134 Take a look at the \l{Qt Wayland Compositor Examples} to learn how these APIs
135 can be used to write custom compositors.
136
137 \section1 API Reference
138
139 The Qt Wayland Compositor can be used from C++ or QML:
140
141 \list
142 \li \l{Qt Wayland Compositor QML Types}
143 \li \l{Qt Wayland Compositor C++ Classes}
144 \endlist
145
146 In addition, the module provides the CMake function
147 \l{qt_generate_wayland_protocol_server_sources}{qt_generate_wayland_protocol_server_sources()}.
148
149 \section1 Module Evolution
150 \l{Porting to Qt 6 - Qt Wayland Compositor} lists important changes in the
151 module API and functionality that were done for the Qt 6 series of Qt.
152
153 \section1 Licenses and Attributions
154
155 Qt Wayland Compositor and the Qt Wayland integration plugin
156 are available under commercial licenses from \l{The Qt Company}.
157
158 In addition, Qt Wayland Compositor is available under the
159 \l{GNU General Public License, version 3}, while
160 the Qt Wayland integration plugin is available under the
161 \l{GNU Lesser General Public License, version 3} or the
162 \l{GNU General Public License, version 2}.
163
164 See \l{Qt Licensing} for further details.
165
166 Qt Wayland Compositor and the Qt Wayland integration plugin
167 use protocol definitions under following permissive licenses:
168
169 \annotatedlist attributions-qtwaylandcompositor
170
171*/