76QEglFSIntegration::QEglFSIntegration()
77 : m_display(EGL_NO_DISPLAY),
78 m_inputContext(
nullptr),
79 m_fontDb(
new QGenericUnixFontDatabase),
80 m_disableInputHandlers(
false)
82 m_disableInputHandlers = qEnvironmentVariableIntValue(
"QT_QPA_EGLFS_DISABLE_INPUT");
87void QEglFSIntegration::initialize()
89 qt_egl_device_integration()->platformInit();
91 m_display = qt_egl_device_integration()->createDisplay(nativeDisplay());
92 if (Q_UNLIKELY(m_display == EGL_NO_DISPLAY))
93 qFatal(
"Could not open egl display");
96 if (Q_UNLIKELY(!eglInitialize(m_display, &major, &minor)))
97 qFatal(
"Could not initialize egl display");
99 m_inputContext = QPlatformInputContextFactory::create();
101 m_vtHandler.reset(
new QFbVtHandler);
103 if (qt_egl_device_integration()->usesDefaultScreen())
104 QWindowSystemInterface::handleScreenAdded(
new QEglFSScreen(display()));
106 qt_egl_device_integration()->screenInit();
109 if (!m_disableInputHandlers)
110 createInputHandlers();
113void QEglFSIntegration::destroy()
115 const auto toplevels = qGuiApp->topLevelWindows();
116 for (QWindow *w : toplevels)
119 qt_egl_device_integration()->screenDestroy();
121 if (m_display != EGL_NO_DISPLAY)
122 eglTerminate(m_display);
124 qt_egl_device_integration()->platformDestroy();
165QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window)
const
167 QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
168 QEglFSWindow *w = qt_egl_device_integration()->createWindow(window);
171 const auto showWithoutActivating = window->property(
"_q_showWithoutActivating");
172 if (showWithoutActivating.isValid() && showWithoutActivating.toBool())
176 if (window->type() != Qt::ToolTip && window->screen() == QGuiApplication::primaryScreen())
177 w->requestActivateWindow();
179 if (window->isTopLevel())
180 w->setBackingStore(
static_cast<QOpenGLCompositorBackingStore *>(m_bs));
186QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context)
const
188 EGLDisplay dpy = context->screen() ?
static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
189 QPlatformOpenGLContext *share = context->shareHandle();
192 QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());
193 EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
194 ctx =
new QEglFSContext(adjustedFormat, share, dpy, &config);
199QOpenGLContext *QEglFSIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext)
const
201 return QEGLPlatformContext::createFrom<QEglFSContext>(context, contextDisplay, display(), shareContext);
204QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface)
const
206 EGLDisplay dpy = surface->screen() ?
static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();
207 QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat());
208 if (qt_egl_device_integration()->supportsPBuffers()) {
209 QEGLPlatformContext::Flags flags;
210 if (!qt_egl_device_integration()->supportsSurfacelessContexts())
211 flags |= QEGLPlatformContext::NoSurfaceless;
212 return new QEGLPbuffer(dpy, fmt, surface, flags);
214 return new QEglFSOffscreenWindow(dpy, fmt, surface);
260 static const QByteArray names[] = {
261 QByteArrayLiteral(
"egldisplay"),
262 QByteArrayLiteral(
"eglwindow"),
263 QByteArrayLiteral(
"eglcontext"),
264 QByteArrayLiteral(
"eglconfig"),
265 QByteArrayLiteral(
"nativedisplay"),
266 QByteArrayLiteral(
"display"),
267 QByteArrayLiteral(
"server_wl_display"),
268 QByteArrayLiteral(
"eglsurface"),
269 QByteArrayLiteral(
"vksurface")
271 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
272 const QByteArray *result = std::find(names, end, key);
274 result = std::find(names, end, key.toLower());
275 return int(result - names);
300void *QEglFSIntegration::nativeResourceForScreen(
const QByteArray &resource, QScreen *screen)
302 void *result =
nullptr;
304 switch (resourceType(resource)) {
308 result =
reinterpret_cast<
void*>(nativeDisplay());
311 result = qt_egl_device_integration()->nativeResourceForScreen(resource, screen);
318void *QEglFSIntegration::nativeResourceForWindow(
const QByteArray &resource, QWindow *window)
320 void *result =
nullptr;
322 switch (resourceType(resource)) {
324 if (window && window->handle())
325 result =
static_cast<QEglFSScreen *>(window->handle()->screen())->display();
330 if (window && window->handle())
331 result =
reinterpret_cast<
void*>(
static_cast<QEglFSWindow *>(window->handle())->eglWindow());
334 if (window && window->handle())
335 result =
reinterpret_cast<
void*>(
static_cast<QEglFSWindow *>(window->handle())->surface());
345void *QEglFSIntegration::nativeResourceForContext(
const QByteArray &resource, QOpenGLContext *context)
347 void *result =
nullptr;
349 switch (resourceType(resource)) {
351 if (context->handle())
352 result =
static_cast<QEglFSContext *>(context->handle())->eglContext();
355 if (context->handle())
356 result =
static_cast<QEglFSContext *>(context->handle())->eglConfig();
359 if (context->handle())
360 result =
static_cast<QEglFSContext *>(context->handle())->eglDisplay();