xwayland: Rename updateXauthorityFile and add error handling

This renames updateXauthorityFile to writeXauthorityEntries as it doesn't
actually update (i.e. change) anything, it just writes new ones.

Error handling is introduced, to avoid that it continues silently without
entries, which would cause all connections to fail.
This commit is contained in:
Fabian Vogt 2021-02-10 14:09:02 +01:00 committed by Vlad Zahorodnii
parent d51703e335
commit 06d2a31bd3
2 changed files with 4 additions and 6 deletions

View file

@ -317,14 +317,12 @@ void Xwayland::handleXwaylandReady()
m_watcher->deleteLater();
m_watcher = nullptr;
if (!createX11Connection()) {
if (!createX11Connection() || !writeXauthorityEntries()) {
emit errorOccurred();
return;
}
const QByteArray displayName = ':' + QByteArray::number(m_display);
updateXauthorityFile();
qCInfo(KWIN_XWL) << "Xwayland server started on display" << displayName;
qputenv("DISPLAY", displayName);
qputenv("XAUTHORITY", m_authorityFile.fileName().toUtf8());
@ -435,7 +433,7 @@ static QByteArray generateXauthorityCookie()
return cookie;
}
void Xwayland::updateXauthorityFile()
bool Xwayland::writeXauthorityEntries()
{
const quint16 family = 256; // FamilyLocal
@ -449,7 +447,7 @@ void Xwayland::updateXauthorityFile()
writeXauthorityEntry(stream, family, address, display, name, cookie);
m_authorityFile->flush();
return stream.status() == QDataStream::Ok && m_authorityFile.flush();
}
DragEventReply Xwayland::dragMoveFilter(Toplevel *target, const QPoint &pos)

View file

@ -99,7 +99,7 @@ private:
void destroyX11Connection();
bool createXauthorityFile();
void updateXauthorityFile();
bool writeXauthorityEntries();
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) override;