xwayland: Emit Xwayland::started() after WM_S0 is claimed

Xwayland starts listening to -listenfd file descriptors after the WM_S0
selection is claimed. At the moment, it is claimed asynchronously by
kwin. First, we create a dummy window and change one of its properties
to get the timestamp. After the timestamp has been received, we actually
call xcb_set_selection_owner().
This commit is contained in:
Vlad Zahorodnii 2021-02-09 10:17:48 +02:00
parent 9f0f452702
commit a2c7c66d8a
2 changed files with 27 additions and 2 deletions

View file

@ -345,6 +345,12 @@ void Xwayland::handleXwaylandReady()
// create selection owner for WM_S0 - magic X display number expected by XWayland
m_selectionOwner.reset(new KSelectionOwner("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow()));
connect(m_selectionOwner.data(), &KSelectionOwner::lostOwnership,
this, &Xwayland::handleSelectionLostOwnership);
connect(m_selectionOwner.data(), &KSelectionOwner::claimedOwnership,
this, &Xwayland::handleSelectionClaimedOwnership);
connect(m_selectionOwner.data(), &KSelectionOwner::failedToClaimOwnership,
this, &Xwayland::handleSelectionFailedToClaimOwnership);
m_selectionOwner->claim(true);
DataBridge::create(this);
@ -354,11 +360,26 @@ void Xwayland::handleXwaylandReady()
env.insert(QStringLiteral("XAUTHORITY"), m_authorityFile.fileName());
m_app->setProcessStartupEnvironment(env);
emit started();
Xcb::sync(); // Trigger possible errors, there's still a chance to abort
}
void Xwayland::handleSelectionLostOwnership()
{
qCWarning(KWIN_XWL) << "Somebody else claimed ownership of WM_S0. This should never happen!";
stop();
}
void Xwayland::handleSelectionFailedToClaimOwnership()
{
qCWarning(KWIN_XWL) << "Failed to claim ownership of WM_S0. This should never happen!";
stop();
}
void Xwayland::handleSelectionClaimedOwnership()
{
emit started();
}
void Xwayland::maybeDestroyReadyNotifier()
{
if (m_readyNotifier) {

View file

@ -90,6 +90,10 @@ private Q_SLOTS:
void handleXwaylandError(QProcess::ProcessError error);
void handleXwaylandReady();
void handleSelectionLostOwnership();
void handleSelectionFailedToClaimOwnership();
void handleSelectionClaimedOwnership();
private:
void installSocketNotifier();
void uninstallSocketNotifier();