aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Grulich <[email protected]>2018-10-11 13:58:48 +0200
committerJan Grulich <[email protected]>2018-10-11 13:58:48 +0200
commit20b720ec6243c529453de11e8b811b249a3aaff7 (patch)
tree15e2779afebcba547cbf0b72df41b8f00459106a
parent06531b2c1b5437cf1bc2b3f84cb83656dcf52c5b (diff)
Make initialization of drm and egl non-fatal
-rw-r--r--src/screencast.cpp7
-rw-r--r--src/waylandintegration.cpp44
-rw-r--r--src/waylandintegration.h2
-rw-r--r--src/waylandintegration_p.h3
4 files changed, 45 insertions, 11 deletions
diff --git a/src/screencast.cpp b/src/screencast.cpp
index 0de2692..26a9b3f 100644
--- a/src/screencast.cpp
+++ b/src/screencast.cpp
@@ -31,7 +31,6 @@ Q_LOGGING_CATEGORY(XdgDesktopPortalKdeScreenCast, "xdp-kde-screencast")
ScreenCastPortal::ScreenCastPortal(QObject *parent)
: QDBusAbstractAdaptor(parent)
, m_screenCastCommon(new ScreenCastCommon())
-
{
}
@@ -141,12 +140,16 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
return 2;
}
- // TODO check whether we got some outputs?
if (WaylandIntegration::screens().isEmpty()) {
qCWarning(XdgDesktopPortalKdeScreenCast) << "Failed to show dialog as there is no screen to select";
return 2;
}
+ if (!WaylandIntegration::isEGLInitialized()) {
+ qCWarning(XdgDesktopPortalKdeScreenCast) << "EGL is not properly initialized";
+ return 2;
+ }
+
QScopedPointer<ScreenChooserDialog, QScopedPointerDeleteLater> screenDialog(new ScreenChooserDialog(app_id, session->multipleSources()));
if (screenDialog->exec()) {
diff --git a/src/waylandintegration.cpp b/src/waylandintegration.cpp
index e08443e..5a702b9 100644
--- a/src/waylandintegration.cpp
+++ b/src/waylandintegration.cpp
@@ -46,10 +46,14 @@ Q_GLOBAL_STATIC(WaylandIntegration::WaylandIntegrationPrivate, globalWaylandInte
void WaylandIntegration::init()
{
globalWaylandIntegration->initDrm();
- globalWaylandIntegration->initEGL();
globalWaylandIntegration->initWayland();
}
+bool WaylandIntegration::isEGLInitialized()
+{
+ return globalWaylandIntegration->isEGLInitialized();
+}
+
void WaylandIntegration::bindOutput(int outputName, int outputVersion)
{
globalWaylandIntegration->bindOutput(outputName, outputVersion);
@@ -124,6 +128,7 @@ void WaylandIntegration::WaylandOutput::setOutputType(const QString &type)
WaylandIntegration::WaylandIntegrationPrivate::WaylandIntegrationPrivate()
: WaylandIntegration()
+ , m_eglInitialized(false)
, m_registryInitialized(false)
, m_connection(nullptr)
, m_queue(nullptr)
@@ -143,6 +148,11 @@ WaylandIntegration::WaylandIntegrationPrivate::~WaylandIntegrationPrivate()
}
}
+bool WaylandIntegration::WaylandIntegrationPrivate::isEGLInitialized() const
+{
+ return m_eglInitialized;
+}
+
void WaylandIntegration::WaylandIntegrationPrivate::bindOutput(int outputName, int outputVersion)
{
KWayland::Client::Output *output = new KWayland::Client::Output(this);
@@ -195,22 +205,31 @@ QMap<quint32, WaylandIntegration::WaylandOutput> WaylandIntegration::WaylandInte
void WaylandIntegration::WaylandIntegrationPrivate::initDrm()
{
m_drmFd = open("/dev/dri/renderD128", O_RDWR);
+
+ if (m_drmFd == -1) {
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "Cannot open render node: " << strerror(errno);
+ return;
+ }
+
m_gbmDevice = gbm_create_device(m_drmFd);
if (!m_gbmDevice) {
- qFatal("Cannot create GBM device: %s", strerror(errno));
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "Cannot create GBM device: " << strerror(errno);
}
+
+ initEGL();
}
void WaylandIntegration::WaylandIntegrationPrivate::initEGL()
{
- // Get the list of client extensions
+ // Get the list of client extensions
const char* clientExtensionsCString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
const QByteArray clientExtensionsString = QByteArray::fromRawData(clientExtensionsCString, qstrlen(clientExtensionsCString));
if (clientExtensionsString.isEmpty()) {
// If eglQueryString() returned NULL, the implementation doesn't support
// EGL_EXT_client_extensions. Expect an EGL_BAD_DISPLAY error.
- qFatal("No client extensions defined! %s", formatGLError(eglGetError()));
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "No client extensions defined! " << formatGLError(eglGetError());
+ return;
}
m_egl.extensions = clientExtensionsString.split(' ');
@@ -219,32 +238,39 @@ void WaylandIntegration::WaylandIntegrationPrivate::initEGL()
// if the implementation supports it.
if (!m_egl.extensions.contains(QByteArrayLiteral("EGL_EXT_platform_base")) ||
!m_egl.extensions.contains(QByteArrayLiteral("EGL_MESA_platform_gbm"))) {
- qFatal("One of required EGL extensions is missing");
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "One of required EGL extensions is missing";
+ return;
}
m_egl.display = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, m_gbmDevice, nullptr);
if (m_egl.display == EGL_NO_DISPLAY) {
- qFatal("Error during obtaining EGL display: %s", formatGLError(eglGetError()));
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "Error during obtaining EGL display: " << formatGLError(eglGetError());
+ return;
}
EGLint major, minor;
if (eglInitialize(m_egl.display, &major, &minor) == EGL_FALSE) {
- qFatal("Error during eglInitialize: %s", formatGLError(eglGetError()));
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "Error during eglInitialize: " << formatGLError(eglGetError());
+ return;
}
if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE) {
- qFatal("bind OpenGL API failed");
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "bind OpenGL API failed";
+ return;
}
m_egl.context = eglCreateContext(m_egl.display, nullptr, EGL_NO_CONTEXT, nullptr);
if (m_egl.context == EGL_NO_CONTEXT) {
- qFatal("Couldn't create EGL context: %s", formatGLError(eglGetError()));
+ qCWarning(XdgDesktopPortalKdeWaylandIntegration) << "Couldn't create EGL context: " << formatGLError(eglGetError());
+ return;
}
qCDebug(XdgDesktopPortalKdeWaylandIntegration) << "Egl initialization succeeded";
qCDebug(XdgDesktopPortalKdeWaylandIntegration) << QStringLiteral("EGL version: %1.%2").arg(major).arg(minor);
+
+ m_eglInitialized = true;
}
void WaylandIntegration::WaylandIntegrationPrivate::initWayland()
diff --git a/src/waylandintegration.h b/src/waylandintegration.h
index c94beee..1395f5e 100644
--- a/src/waylandintegration.h
+++ b/src/waylandintegration.h
@@ -75,6 +75,8 @@ Q_SIGNALS:
void init();
+ bool isEGLInitialized();
+
void bindOutput(int outputName, int outputVersion);
void startStreaming();
void stopStreaming();
diff --git a/src/waylandintegration_p.h b/src/waylandintegration_p.h
index d2e00b5..afc14fc 100644
--- a/src/waylandintegration_p.h
+++ b/src/waylandintegration_p.h
@@ -57,6 +57,8 @@ public:
void initEGL();
void initWayland();
+ bool isEGLInitialized() const;
+
void bindOutput(int outputName, int outputVersion);
void startStreaming();
void stopStreaming();
@@ -69,6 +71,7 @@ protected Q_SLOTS:
void setupRegistry();
private:
+ bool m_eglInitialized;
bool m_streamingEnabled;
bool m_registryInitialized;