backends/drm: consider escaped separators KWIN_DRM_DEVICES

':' conflicts with the file names in /dev/dri/by-path, so allow it to be
escaped with '\'

CCBUG: 453386
This commit is contained in:
Xaver Hugl 2022-05-07 21:23:17 +02:00 committed by Vlad Zahorodnii
parent 5ddcd0827b
commit a110aabbcc

View file

@ -55,12 +55,34 @@
namespace KWin
{
static QStringList splitPathList(const QString &input, const QChar delimiter)
{
QStringList ret;
QString tmp;
for (int i = 0; i < input.size(); i++) {
if (input[i] == delimiter) {
if (i > 0 && input[i - 1] == '\\') {
tmp[tmp.size() - 1] = delimiter;
} else if (!tmp.isEmpty()) {
ret.append(tmp);
tmp = QString();
}
} else {
tmp.append(input[i]);
}
}
if (!tmp.isEmpty()) {
ret.append(tmp);
}
return ret;
}
DrmBackend::DrmBackend(QObject *parent)
: Platform(parent)
, m_udev(new Udev)
, m_udevMonitor(m_udev->monitor())
, m_session(Session::create(this))
, m_explicitGpus(qEnvironmentVariable("KWIN_DRM_DEVICES").split(':', Qt::SkipEmptyParts))
, m_explicitGpus(splitPathList(qEnvironmentVariable("KWIN_DRM_DEVICES"), ':'))
, m_dpmsFilter()
{
setSupportsPointerWarping(true);