Commit a2c7c66d authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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().
parent 9f0f4527
......@@ -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) {
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment