diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt
index 39b6261507..59bc3e132a 100644
--- a/autotests/integration/CMakeLists.txt
+++ b/autotests/integration/CMakeLists.txt
@@ -1,6 +1,6 @@
add_subdirectory(helper)
-add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp test_helpers.cpp generic_scene_opengl_test.cpp ${kwin_XWAYLAND_SRCS})
+add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp test_helpers.cpp generic_scene_opengl_test.cpp ../../cursor.cpp ${kwin_XWAYLAND_SRCS})
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test)
function(integrationTest)
diff --git a/autotests/integration/keyboard_layout_test.cpp b/autotests/integration/keyboard_layout_test.cpp
index 147122ba2b..396c710eb4 100644
--- a/autotests/integration/keyboard_layout_test.cpp
+++ b/autotests/integration/keyboard_layout_test.cpp
@@ -82,7 +82,7 @@ void KeyboardLayoutTest::initTestCase()
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
kwinApp()->setKxkbConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
- kwinApp()->setInputConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
+ InputConfig::self()->setInputConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
kwinApp()->start();
QVERIFY(workspaceCreatedSpy.wait());
@@ -482,7 +482,7 @@ void KeyboardLayoutTest::testNumLock()
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
// let's reconfigure to enable through config
- auto group = kwinApp()->inputConfig()->group("Keyboard");
+ auto group = InputConfig::self()->inputConfig()->group("Keyboard");
group.writeEntry("NumLock", 0);
group.sync();
xkb->reconfigure();
diff --git a/cursor.cpp b/cursor.cpp
index e6e01792e6..293fcef6b8 100644
--- a/cursor.cpp
+++ b/cursor.cpp
@@ -30,7 +30,6 @@ along with this program. If not, see .
// KDE
#include
#include
-#include
// Qt
#include
#include
@@ -127,7 +126,7 @@ void Cursor::loadThemeSettings()
void Cursor::loadThemeFromKConfig()
{
- KConfigGroup mousecfg(kwinApp()->inputConfig(), "Mouse");
+ KConfigGroup mousecfg(InputConfig::self()->inputConfig(), "Mouse");
const QString themeName = mousecfg.readEntry("cursorTheme", defaultThemeName());
const uint themeSize = mousecfg.readEntry("cursorSize", defaultThemeSize());
updateTheme(themeName, themeSize);
@@ -144,9 +143,10 @@ void Cursor::updateTheme(const QString &name, int size)
void Cursor::slotKGlobalSettingsNotifyChange(int type, int arg)
{
+// #endif
Q_UNUSED(arg)
if (type == 5 /*CursorChanged*/) {
- kwinApp()->inputConfig()->reparseConfiguration();
+ InputConfig::self()->inputConfig()->reparseConfiguration();
loadThemeFromKConfig();
// sync to environment
qputenv("XCURSOR_THEME", m_themeName.toUtf8());
@@ -485,4 +485,16 @@ QByteArray CursorShape::name() const
}
}
+InputConfig *InputConfig::s_self = nullptr;
+InputConfig *InputConfig::self() {
+ if (!s_self)
+ s_self = new InputConfig;
+ return s_self;
+}
+
+InputConfig::InputConfig()
+ : m_inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"), KConfig::NoGlobals))
+{
+}
+
} // namespace
diff --git a/cursor.h b/cursor.h
index b140a24323..1bbee447d6 100644
--- a/cursor.h
+++ b/cursor.h
@@ -25,6 +25,8 @@ along with this program. If not, see .
#include
#include
#include
+// KF
+#include
// xcb
#include
@@ -311,6 +313,24 @@ private:
QVector m_cursors;
};
+class InputConfig
+{
+public:
+ KSharedConfigPtr inputConfig() const {
+ return m_inputConfig;
+ }
+ void setInputConfig(KSharedConfigPtr config) {
+ m_inputConfig = std::move(config);
+ }
+
+ static InputConfig *self();
+private:
+ InputConfig();
+
+ KSharedConfigPtr m_inputConfig;
+ static InputConfig *s_self;
+};
+
inline const QPoint &Cursor::currentPos() const
{
return m_pos;
diff --git a/effects.cpp b/effects.cpp
index 4b38c86296..78adbc316d 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -1684,7 +1684,7 @@ KSharedConfigPtr EffectsHandlerImpl::config() const
KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
{
- return kwinApp()->inputConfig();
+ return InputConfig::self()->inputConfig();
}
Effect *EffectsHandlerImpl::findEffect(const QString &name) const
diff --git a/input.cpp b/input.cpp
index 0c7cbce92b..4867caa4ba 100644
--- a/input.cpp
+++ b/input.cpp
@@ -2150,7 +2150,7 @@ void InputRedirection::setupInputFilters()
void InputRedirection::reconfigure()
{
if (Application::usesLibinput()) {
- auto inputConfig = kwinApp()->inputConfig();
+ auto inputConfig = InputConfig::self()->inputConfig();
inputConfig->reparseConfiguration();
const auto config = inputConfig->group(QStringLiteral("Keyboard"));
const int delay = config.readEntry("RepeatDelay", 660);
@@ -2178,7 +2178,7 @@ void InputRedirection::setupLibInput()
waylandServer()->display()->createRelativePointerManager(KWaylandServer::RelativePointerInterfaceVersion::UnstableV1, waylandServer()->display())->create();
}
- conn->setInputConfig(kwinApp()->inputConfig());
+ conn->setInputConfig(InputConfig::self()->inputConfig());
conn->updateLEDs(m_keyboard->xkb()->leds());
waylandServer()->updateKeyState(m_keyboard->xkb()->leds());
connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, waylandServer(), &WaylandServer::updateKeyState);
diff --git a/keyboard_input.cpp b/keyboard_input.cpp
index 005a827157..4d3c3f48e9 100644
--- a/keyboard_input.cpp
+++ b/keyboard_input.cpp
@@ -111,7 +111,7 @@ void KeyboardInputRedirection::init()
Q_ASSERT(!m_inited);
m_inited = true;
const auto config = kwinApp()->kxkbConfig();
- m_xkb->setNumLockConfig(kwinApp()->inputConfig());
+ m_xkb->setNumLockConfig(InputConfig::self()->inputConfig());
m_xkb->setConfig(config);
m_input->installInputEventSpy(new KeyStateChangedSpy(m_input));
diff --git a/main.cpp b/main.cpp
index 46cdc693d2..fcd0338032 100644
--- a/main.cpp
+++ b/main.cpp
@@ -106,7 +106,6 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
, m_configLock(false)
, m_config()
, m_kxkbConfig()
- , m_inputConfig()
, m_operationMode(mode)
{
qRegisterMetaType("Options::WindowOperation");
@@ -150,9 +149,6 @@ void Application::start()
if (!m_kxkbConfig) {
m_kxkbConfig = KSharedConfig::openConfig(QStringLiteral("kxkbrc"), KConfig::NoGlobals);
}
- if (!m_inputConfig) {
- m_inputConfig = KSharedConfig::openConfig(QStringLiteral("kcminputrc"), KConfig::NoGlobals);
- }
performStartup();
}
diff --git a/main.h b/main.h
index 367f4c7dca..a1b10af5d5 100644
--- a/main.h
+++ b/main.h
@@ -54,7 +54,6 @@ class KWIN_EXPORT Application : public QApplication
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
Q_PROPERTY(KSharedConfigPtr kxkbConfig READ kxkbConfig WRITE setKxkbConfig)
- Q_PROPERTY(KSharedConfigPtr inputConfig READ inputConfig WRITE setInputConfig)
public:
/**
* @brief This enum provides the various operation modes of KWin depending on the available
@@ -94,13 +93,6 @@ public:
m_kxkbConfig = std::move(config);
}
- KSharedConfigPtr inputConfig() const {
- return m_inputConfig;
- }
- void setInputConfig(KSharedConfigPtr config) {
- m_inputConfig = std::move(config);
- }
-
void start();
/**
* @brief The operation mode used by KWin.
@@ -248,7 +240,6 @@ private:
bool m_configLock;
KSharedConfigPtr m_config;
KSharedConfigPtr m_kxkbConfig;
- KSharedConfigPtr m_inputConfig;
OperationMode m_operationMode;
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;