diff --git a/src/kwin.kcfg b/src/kwin.kcfg
index ce9ee8f3ea..0a557b8950 100644
--- a/src/kwin.kcfg
+++ b/src/kwin.kcfg
@@ -318,6 +318,9 @@
true
+
+ true
+
diff --git a/src/main.cpp b/src/main.cpp
index 5e6126f1c4..3320790be3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -93,7 +93,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
: QApplication(argc, argv)
, m_eventFilter(new XcbEventFilter())
, m_configLock(false)
- , m_config()
+ , m_config(KSharedConfig::openConfig(QStringLiteral("kwinrc")))
, m_kxkbConfig()
, m_operationMode(mode)
{
@@ -134,9 +134,6 @@ void Application::start()
setQuitOnLastWindowClosed(false);
- if (!m_config) {
- m_config = KSharedConfig::openConfig();
- }
if (!m_config->isImmutable() && m_configLock) {
// TODO: This shouldn't be necessary
// config->setReadOnly( true );
diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp
index dfb44235bd..3725c9adf9 100644
--- a/src/main_wayland.cpp
+++ b/src/main_wayland.cpp
@@ -201,17 +201,21 @@ void ApplicationWayland::refreshSettings(const KConfigGroup &group, const QByteA
if (m_startXWayland && group.name() == "Xwayland" && names.contains("Scale")) {
setXwaylandScale(group.readEntry("Scale", 1.0));
}
+
+ if (group.name() == "Wayland" && names.contains("EnablePrimarySelection")) {
+ waylandServer()->setEnablePrimarySelection(group.readEntry("EnablePrimarySelection", true));
+ }
}
void ApplicationWayland::startSession()
{
+ KSharedConfig::Ptr kwinSettings = kwinApp()->config();
+ m_settingsWatcher = KConfigWatcher::create(kwinSettings);
+ connect(m_settingsWatcher.data(), &KConfigWatcher::configChanged, this, &ApplicationWayland::refreshSettings);
+
if (!m_inputMethodServerToStart.isEmpty()) {
InputMethod::self()->setInputMethodCommand(m_inputMethodServerToStart);
} else {
- KSharedConfig::Ptr kwinSettings = kwinApp()->config();
- m_settingsWatcher = KConfigWatcher::create(kwinSettings);
- connect(m_settingsWatcher.data(), &KConfigWatcher::configChanged, this, &ApplicationWayland::refreshSettings);
-
refreshSettings(kwinSettings->group("Wayland"), {"InputMethod"});
}
diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp
index 68a3f584d7..ea741ae886 100644
--- a/src/wayland_server.cpp
+++ b/src/wayland_server.cpp
@@ -327,6 +327,16 @@ void WaylandServer::handleOutputDisabled(Output *output)
}
}
+void WaylandServer::setEnablePrimarySelection(bool enable)
+{
+ if (!enable && m_primarySelectionDeviceManager != nullptr) {
+ delete m_primarySelectionDeviceManager;
+ m_primarySelectionDeviceManager = nullptr;
+ } else if (enable && m_primarySelectionDeviceManager == nullptr) {
+ m_primarySelectionDeviceManager = new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
+ }
+}
+
Output *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const
{
for (auto it = m_waylandOutputs.constBegin(); it != m_waylandOutputs.constEnd(); ++it) {
@@ -415,7 +425,10 @@ bool WaylandServer::init(InitializationFlags flags)
new RelativePointerManagerV1Interface(m_display, m_display);
m_dataDeviceManager = new DataDeviceManagerInterface(m_display, m_display);
new DataControlDeviceManagerV1Interface(m_display, m_display);
- new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
+
+ const auto kwinConfig = kwinApp()->config();
+ setEnablePrimarySelection(kwinConfig->group("Wayland").readEntry("EnablePrimarySelection", true));
+
m_idle = new IdleInterface(m_display, m_display);
auto idleInhibition = new IdleInhibition(m_idle);
connect(this, &WaylandServer::windowAdded, idleInhibition, &IdleInhibition::registerClient);
diff --git a/src/wayland_server.h b/src/wayland_server.h
index 58729a3dbc..14633ac156 100644
--- a/src/wayland_server.h
+++ b/src/wayland_server.h
@@ -47,6 +47,7 @@ class LinuxDmaBufV1ClientBuffer;
class TabletManagerV2Interface;
class KeyboardShortcutsInhibitManagerV1Interface;
class XdgDecorationManagerV1Interface;
+class PrimarySelectionDeviceManagerV1Interface;
}
namespace KWin
@@ -222,6 +223,7 @@ public:
{
m_linuxDmabufBuffers.remove(buffer);
}
+ void setEnablePrimarySelection(bool enable);
Output *findOutput(KWaylandServer::OutputInterface *output) const;
@@ -291,6 +293,7 @@ private:
KWaylandServer::XdgForeignV2Interface *m_XdgForeign = nullptr;
KWaylandServer::PrimaryOutputV1Interface *m_primary = nullptr;
XdgActivationV1Integration *m_xdgActivationIntegration = nullptr;
+ KWaylandServer::PrimarySelectionDeviceManagerV1Interface *m_primarySelectionDeviceManager = nullptr;
QList m_windows;
InitializationFlags m_initFlags;
QHash