77QEglFSIntegration::QEglFSIntegration()
78 : m_display(EGL_NO_DISPLAY),
79 m_inputContext(
nullptr),
80 m_fontDb(
new QGenericUnixFontDatabase),
81 m_disableInputHandlers(
false)
83 m_disableInputHandlers = qEnvironmentVariableIntValue(
"QT_QPA_EGLFS_DISABLE_INPUT");
88void QEglFSIntegration::initialize()
90 qt_egl_device_integration()->platformInit();
92 m_display = qt_egl_device_integration()->createDisplay(nativeDisplay());
93 if (Q_UNLIKELY(m_display == EGL_NO_DISPLAY))
94 qFatal(
"Could not open egl display");
97 if (Q_UNLIKELY(!eglInitialize(m_display, &major, &minor)))
98 qFatal(
"Could not initialize egl display");
100 m_inputContext = QPlatformInputContextFactory::create();
102 m_vtHandler.reset(
new QFbVtHandler);
104 if (qt_egl_device_integration()->usesDefaultScreen())
105 QWindowSystemInterface::handleScreenAdded(
new QEglFSScreen(display()));
107 qt_egl_device_integration()->screenInit();
110 if (!m_disableInputHandlers)
111 createInputHandlers();
114void QEglFSIntegration::destroy()
116 const auto toplevels = qGuiApp->topLevelWindows();
117 for (QWindow *w : toplevels)
120 qt_egl_device_integration()->screenDestroy();
122 if (m_display != EGL_NO_DISPLAY)
123 eglTerminate(m_display);
125 qt_egl_device_integration()->platformDestroy();
166QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window)
const
168 QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
169 QEglFSWindow *w = qt_egl_device_integration()->createWindow(window);
172 const auto showWithoutActivating = window->property(
"_q_showWithoutActivating");
173 if (showWithoutActivating.isValid() && showWithoutActivating.toBool())
177 if (window->type() != Qt::ToolTip && window->screen() == QGuiApplication::primaryScreen())
178 w->requestActivateWindow();
180 if (window->isTopLevel())
181 w->setBackingStore(
static_cast<QOpenGLCompositorBackingStore *>(m_bs));
187QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context)
const
189 EGLDisplay dpy = context->screen() ?
static_cast<QEglFSScreen *>(context->screen()->handle())->display() : display();
190 QPlatformOpenGLContext *share = context->shareHandle();
193 QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());
194 EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
195 ctx =
new QEglFSContext(adjustedFormat, share, dpy, &config);
200QOpenGLContext *QEglFSIntegration::createOpenGLContext(EGLContext context, EGLDisplay contextDisplay, QOpenGLContext *shareContext)
const
202 return QEGLPlatformContext::createFrom<QEglFSContext>(context, contextDisplay, display(), shareContext);
205QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface)
const
207 EGLDisplay dpy = surface->screen() ?
static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();
208 QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat());
209 if (qt_egl_device_integration()->supportsPBuffers()) {
210 QEGLPlatformContext::Flags flags;
211 if (!qt_egl_device_integration()->supportsSurfacelessContexts())
212 flags |= QEGLPlatformContext::NoSurfaceless;
213 return new QEGLPbuffer(dpy, fmt, surface, flags);
215 return new QEglFSOffscreenWindow(dpy, fmt, surface);
262 static const QByteArray names[] = {
263 QByteArrayLiteral(
"egldisplay"),
264 QByteArrayLiteral(
"eglwindow"),
265 QByteArrayLiteral(
"eglcontext"),
266 QByteArrayLiteral(
"eglconfig"),
267 QByteArrayLiteral(
"nativedisplay"),
268 QByteArrayLiteral(
"display"),
269 QByteArrayLiteral(
"server_wl_display"),
270 QByteArrayLiteral(
"eglsurface"),
271 QByteArrayLiteral(
"vksurface")
273 const QByteArray *end = names +
sizeof(names) /
sizeof(names[0]);
274 const QByteArray *result = std::find(names, end, key);
276 result = std::find(names, end, key.toLower());
277 return int(result - names);
302void *QEglFSIntegration::nativeResourceForScreen(
const QByteArray &resource, QScreen *screen)
304 void *result =
nullptr;
306 switch (resourceType(resource)) {
310 result =
reinterpret_cast<
void*>(nativeDisplay());
313 result = qt_egl_device_integration()->nativeResourceForScreen(resource, screen);
320void *QEglFSIntegration::nativeResourceForWindow(
const QByteArray &resource, QWindow *window)
322 void *result =
nullptr;
324 switch (resourceType(resource)) {
326 if (window && window->handle())
327 result =
static_cast<QEglFSScreen *>(window->handle()->screen())->display();
332 if (window && window->handle())
333 result =
reinterpret_cast<
void*>(
static_cast<QEglFSWindow *>(window->handle())->eglWindow());
336 if (window && window->handle())
337 result =
reinterpret_cast<
void*>(
static_cast<QEglFSWindow *>(window->handle())->surface());
347void *QEglFSIntegration::nativeResourceForContext(
const QByteArray &resource, QOpenGLContext *context)
349 void *result =
nullptr;
351 switch (resourceType(resource)) {
353 if (context->handle())
354 result =
static_cast<QEglFSContext *>(context->handle())->eglContext();
357 if (context->handle())
358 result =
static_cast<QEglFSContext *>(context->handle())->eglConfig();
361 if (context->handle())
362 result =
static_cast<QEglFSContext *>(context->handle())->eglDisplay();