You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
6.4 KiB
156 lines
6.4 KiB
From df564d59533f9556d20f1141bf01de705cce3bf4 Mon Sep 17 00:00:00 2001
|
|
From: Aleksei Bavshin <alebastr89@gmail.com>
|
|
Date: Wed, 2 Feb 2022 23:08:59 -0800
|
|
Subject: [PATCH] WaylandHelper: support non-default display names
|
|
|
|
Weston v10[1] and some wlroots-based compositors[2][3] decided to stop
|
|
using `wayland-0`.
|
|
Extend WaylandSocketWatcher to look for any socket matching the
|
|
`wayland-?` pattern and pass the `WAYLAND_DISPLAY` to the greeter.
|
|
|
|
[1]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486
|
|
[2]: https://github.com/swaywm/sway/commit/65a751a21f61b30808b7e703257c6ca3b71f50eb
|
|
[3]: https://github.com/WayfireWM/wayfire/commit/4ee4f3f259be00fd9a3c26960e8fce91ec526290
|
|
---
|
|
src/helper/waylandhelper.cpp | 5 +++-
|
|
src/helper/waylandsocketwatcher.cpp | 37 +++++++++++++++++------------
|
|
src/helper/waylandsocketwatcher.h | 4 ++--
|
|
3 files changed, 28 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/src/helper/waylandhelper.cpp b/src/helper/waylandhelper.cpp
|
|
index 39952cb99..66d6b0796 100644
|
|
--- a/src/helper/waylandhelper.cpp
|
|
+++ b/src/helper/waylandhelper.cpp
|
|
@@ -119,7 +119,6 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
m_greeterProcess = new QProcess(this);
|
|
m_greeterProcess->setProgram(args.takeFirst());
|
|
m_greeterProcess->setArguments(args);
|
|
- m_greeterProcess->setProcessEnvironment(m_environment);
|
|
connect(m_greeterProcess, &QProcess::readyReadStandardError, this, [this] {
|
|
qWarning() << m_greeterProcess->readAllStandardError();
|
|
});
|
|
@@ -132,6 +131,8 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
QCoreApplication::instance()->quit();
|
|
});
|
|
if (m_watcher->status() == WaylandSocketWatcher::Started) {
|
|
+ m_environment.insert(QStringLiteral("WAYLAND_DISPLAY"), m_watcher->socketName());
|
|
+ m_greeterProcess->setProcessEnvironment(m_environment);
|
|
m_greeterProcess->start();
|
|
} else if (m_watcher->status() == WaylandSocketWatcher::Failed) {
|
|
Q_EMIT failed();
|
|
@@ -139,6 +140,8 @@ void WaylandHelper::startGreeter(const QString &cmd)
|
|
connect(m_watcher, &WaylandSocketWatcher::failed, this, &WaylandHelper::failed);
|
|
connect(m_watcher, &WaylandSocketWatcher::started, this, [this] {
|
|
m_watcher->stop();
|
|
+ m_environment.insert(QStringLiteral("WAYLAND_DISPLAY"), m_watcher->socketName());
|
|
+ m_greeterProcess->setProcessEnvironment(m_environment);
|
|
m_greeterProcess->start();
|
|
});
|
|
}
|
|
diff --git a/src/helper/waylandsocketwatcher.cpp b/src/helper/waylandsocketwatcher.cpp
|
|
index 316690935..837bb189d 100644
|
|
--- a/src/helper/waylandsocketwatcher.cpp
|
|
+++ b/src/helper/waylandsocketwatcher.cpp
|
|
@@ -18,6 +18,7 @@
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
***************************************************************************/
|
|
|
|
+#include <unistd.h>
|
|
#include <QDebug>
|
|
#include <QStandardPaths>
|
|
|
|
@@ -28,8 +29,9 @@ namespace SDDM {
|
|
WaylandSocketWatcher::WaylandSocketWatcher(QObject *parent )
|
|
: QObject(parent)
|
|
, m_runtimeDir(QDir(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)))
|
|
- , m_socketPath(m_runtimeDir.absoluteFilePath(QLatin1String("wayland-0")))
|
|
{
|
|
+ m_runtimeDir.setFilter(QDir::Files | QDir::System);
|
|
+ m_runtimeDir.setNameFilters(QStringList() << QLatin1String("wayland-?"));
|
|
}
|
|
|
|
WaylandSocketWatcher::Status WaylandSocketWatcher::status() const
|
|
@@ -37,9 +39,9 @@ WaylandSocketWatcher::Status WaylandSocketWatcher::status() const
|
|
return m_status;
|
|
}
|
|
|
|
-QString WaylandSocketWatcher::socketPath() const
|
|
+QString WaylandSocketWatcher::socketName() const
|
|
{
|
|
- return m_socketPath;
|
|
+ return m_socketName;
|
|
}
|
|
|
|
void WaylandSocketWatcher::start()
|
|
@@ -53,8 +55,7 @@ void WaylandSocketWatcher::start()
|
|
// Time is up and a socket was not found
|
|
if (!m_watcher.isNull())
|
|
m_watcher->deleteLater();
|
|
- qWarning("Wayland socket watcher for \"%s\" timed out",
|
|
- qPrintable(m_socketPath));
|
|
+ qWarning("Wayland socket watcher timed out");
|
|
m_status = Failed;
|
|
Q_EMIT failed();
|
|
});
|
|
@@ -62,22 +63,28 @@ void WaylandSocketWatcher::start()
|
|
// Check if the socket exists
|
|
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this,
|
|
[this](const QString &path) {
|
|
- qDebug() << "Directory" << path << "has changed, checking for" << m_socketPath;
|
|
+ qDebug() << "Directory" << path << "has changed, checking for Wayland socket";
|
|
|
|
- if (QFile::exists(m_socketPath)) {
|
|
- m_timer.stop();
|
|
- if (!m_watcher.isNull())
|
|
- m_watcher->deleteLater();
|
|
- m_status = Started;
|
|
- Q_EMIT started();
|
|
+ m_runtimeDir.refresh();
|
|
+ const QFileInfoList fileInfoList = m_runtimeDir.entryInfoList();
|
|
+ for (const QFileInfo &fileInfo : fileInfoList) {
|
|
+ if (fileInfo.ownerId() == ::getuid()) {
|
|
+ qDebug() << "Found Wayland socket" << fileInfo.absoluteFilePath();
|
|
+ m_timer.stop();
|
|
+ if (!m_watcher.isNull())
|
|
+ m_watcher->deleteLater();
|
|
+ m_socketName = fileInfo.fileName();
|
|
+ m_status = Started;
|
|
+ Q_EMIT started();
|
|
+ break;
|
|
+ }
|
|
}
|
|
});
|
|
|
|
// Watch for runtime directory changes
|
|
if (!m_runtimeDir.exists() || !m_watcher->addPath(m_runtimeDir.absolutePath())) {
|
|
- qWarning("Cannot watch directory \"%s\" for Wayland socket \"%s\"",
|
|
- qPrintable(m_runtimeDir.absolutePath()),
|
|
- qPrintable(m_socketPath));
|
|
+ qWarning("Cannot watch directory \"%s\" for Wayland socket",
|
|
+ qPrintable(m_runtimeDir.absolutePath()));
|
|
m_watcher->deleteLater();
|
|
m_status = Failed;
|
|
Q_EMIT failed();
|
|
diff --git a/src/helper/waylandsocketwatcher.h b/src/helper/waylandsocketwatcher.h
|
|
index dfc5d214a..0032c1866 100644
|
|
--- a/src/helper/waylandsocketwatcher.h
|
|
+++ b/src/helper/waylandsocketwatcher.h
|
|
@@ -41,7 +41,7 @@ class WaylandSocketWatcher : public QObject
|
|
explicit WaylandSocketWatcher(QObject *parent = nullptr);
|
|
|
|
Status status() const;
|
|
- QString socketPath() const;
|
|
+ QString socketName() const;
|
|
|
|
void start();
|
|
void stop();
|
|
@@ -54,7 +54,7 @@ class WaylandSocketWatcher : public QObject
|
|
private:
|
|
Status m_status = Stopped;
|
|
QDir m_runtimeDir;
|
|
- QString m_socketPath;
|
|
+ QString m_socketName;
|
|
QTimer m_timer;
|
|
QPointer<QFileSystemWatcher> m_watcher;
|
|
};
|