xwayland: Fix initialization of WM_S0 selection owner

The selection owner must live as long as the X11 connection is valid;
otherwise Xwayland won't catch the corresponding selection ownership
change event, and the initialization sequence will be incomplete.
This commit is contained in:
Vlad Zahorodnii 2021-02-09 00:00:08 +02:00
parent 3c63750f6e
commit 8137b8a3ab
2 changed files with 6 additions and 2 deletions

View file

@ -158,6 +158,7 @@ void Xwayland::stop()
uninstallSocketNotifier(); uninstallSocketNotifier();
DataBridge::destroy(); DataBridge::destroy();
m_selectionOwner.reset();
destroyX11Connection(); destroyX11Connection();
@ -318,8 +319,8 @@ void Xwayland::handleXwaylandReady()
qputenv("DISPLAY", m_displayName); qputenv("DISPLAY", m_displayName);
// create selection owner for WM_S0 - magic X display number expected by XWayland // create selection owner for WM_S0 - magic X display number expected by XWayland
KSelectionOwner owner("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow()); m_selectionOwner.reset(new KSelectionOwner("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow()));
owner.claim(true); m_selectionOwner->claim(true);
DataBridge::create(this); DataBridge::create(this);

View file

@ -16,6 +16,8 @@
#include <QProcess> #include <QProcess>
#include <QSocketNotifier> #include <QSocketNotifier>
class KSelectionOwner;
namespace KWin namespace KWin
{ {
class ApplicationWaylandAbstract; class ApplicationWaylandAbstract;
@ -105,6 +107,7 @@ private:
QByteArray m_displayName; QByteArray m_displayName;
QFutureWatcher<QByteArray> *m_watcher = nullptr; QFutureWatcher<QByteArray> *m_watcher = nullptr;
ApplicationWaylandAbstract *m_app; ApplicationWaylandAbstract *m_app;
QScopedPointer<KSelectionOwner> m_selectionOwner;
int m_crashCount = 0; int m_crashCount = 0;
Q_DISABLE_COPY(Xwayland) Q_DISABLE_COPY(Xwayland)