diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index b4f7327dd9..bc586537f7 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -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) { diff --git a/src/xwl/xwayland.h b/src/xwl/xwayland.h index e18e3e2330..630c0cb3b6 100644 --- a/src/xwl/xwayland.h +++ b/src/xwl/xwayland.h @@ -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();