aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2017-04-19 17:00:02 +0200
committerMartin Gräßlin <[email protected]>2017-04-24 21:01:03 +0200
commit857d8a9c37c6a177dc546944349ad8d28c52d874 (patch)
tree2da25e38419d91a8b7b2e3ba403ce7e53434251e
parenta039c2760f6458059dfc91b035a5e03022a31d12 (diff)
Add a KSharedConfigPtr for kcminputrc to KWin::Application
Summary: There are a few places where KWin needs to read values from kcminputrc. As I need to add yet another one it makes more sense to properly structure it like in other cases and have only one kcminputrc hold in the application. This also allows to better mock the config values in the integration tests. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D5540
-rw-r--r--autotests/mock_effectshandler.cpp6
-rw-r--r--autotests/mock_effectshandler.h1
-rw-r--r--cursor.cpp2
-rw-r--r--effects.cpp5
-rw-r--r--effects.h1
-rw-r--r--effects/startupfeedback/startupfeedback.cpp2
-rw-r--r--input.cpp8
-rw-r--r--input.h1
-rw-r--r--libkwineffects/kwineffects.h6
-rw-r--r--main.cpp4
-rw-r--r--main.h9
11 files changed, 38 insertions, 7 deletions
diff --git a/autotests/mock_effectshandler.cpp b/autotests/mock_effectshandler.cpp
index 95d8b72..be4b1ff 100644
--- a/autotests/mock_effectshandler.cpp
+++ b/autotests/mock_effectshandler.cpp
@@ -30,3 +30,9 @@ KSharedConfigPtr MockEffectsHandler::config() const
static const KSharedConfigPtr s_config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
return s_config;
}
+
+KSharedConfigPtr MockEffectsHandler::inputConfig() const
+{
+ static const KSharedConfigPtr s_inputConfig = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
+ return s_inputConfig;
+}
diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h
index 024455b..72351f2 100644
--- a/autotests/mock_effectshandler.h
+++ b/autotests/mock_effectshandler.h
@@ -261,6 +261,7 @@ public:
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override { Q_UNUSED(flags)}
KSharedConfigPtr config() const override;
+ KSharedConfigPtr inputConfig() const override;
private:
bool m_animationsSuported = true;
diff --git a/cursor.cpp b/cursor.cpp
index e8f9646..47b5590 100644
--- a/cursor.cpp
+++ b/cursor.cpp
@@ -86,7 +86,7 @@ void Cursor::loadThemeSettings()
void Cursor::loadThemeFromKConfig()
{
- KConfigGroup mousecfg(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Mouse");
+ KConfigGroup mousecfg(kwinApp()->inputConfig(), "Mouse");
const QString themeName = mousecfg.readEntry("cursorTheme", "default");
bool ok = false;
uint themeSize = mousecfg.readEntry("cursorSize", QString("24")).toUInt(&ok);
diff --git a/effects.cpp b/effects.cpp
index 7dda141..d2c4768 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -1626,6 +1626,11 @@ KSharedConfigPtr EffectsHandlerImpl::config() const
return kwinApp()->config();
}
+KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
+{
+ return kwinApp()->inputConfig();
+}
+
//****************************************
// EffectWindowImpl
//****************************************
diff --git a/effects.h b/effects.h
index 041afbd..ba24902 100644
--- a/effects.h
+++ b/effects.h
@@ -242,6 +242,7 @@ public:
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override;
KSharedConfigPtr config() const override;
+ KSharedConfigPtr inputConfig() const override;
Scene *scene() const {
return m_scene;
diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp
index 14b5f13..02d9cd6 100644
--- a/effects/startupfeedback/startupfeedback.cpp
+++ b/effects/startupfeedback/startupfeedback.cpp
@@ -283,7 +283,7 @@ void StartupFeedbackEffect::start(const QString& icon)
prepareTextures(iconPixmap);
auto readCursorSize = []() -> int {
// read details about the mouse-cursor theme define per default
- KConfigGroup mousecfg(KSharedConfig::openConfig(QStringLiteral("kcminputrc")), "Mouse");
+ KConfigGroup mousecfg(effects->inputConfig(), "Mouse");
QString size = mousecfg.readEntry("cursorSize", QString());
// fetch a reasonable size for the cursor-theme image
diff --git a/input.cpp b/input.cpp
index 6b3bdb9..2ffa053 100644
--- a/input.cpp
+++ b/input.cpp
@@ -1458,7 +1458,6 @@ InputRedirection::InputRedirection(QObject *parent)
}
);
}
- m_inputConfig = KSharedConfig::openConfig(QStringLiteral("kcminputrc"));
}
#endif
connect(kwinApp(), &Application::workspaceCreated, this, &InputRedirection::setupWorkspace);
@@ -1632,8 +1631,9 @@ void InputRedirection::reconfigure()
{
#if HAVE_INPUT
if (Application::usesLibinput()) {
- m_inputConfig->reparseConfiguration();
- const auto config = m_inputConfig->group(QStringLiteral("keyboard"));
+ auto inputConfig = kwinApp()->inputConfig();
+ inputConfig->reparseConfiguration();
+ const auto config = inputConfig->group(QStringLiteral("keyboard"));
const int delay = config.readEntry("RepeatDelay", 660);
const int rate = config.readEntry("RepeatRate", 25);
const bool enabled = config.readEntry("KeyboardRepeating", 0) == 0;
@@ -1670,7 +1670,7 @@ void InputRedirection::setupLibInput()
waylandServer()->display()->createRelativePointerManager(KWayland::Server::RelativePointerInterfaceVersion::UnstableV1, waylandServer()->display())->create();
}
- conn->setInputConfig(m_inputConfig);
+ conn->setInputConfig(kwinApp()->inputConfig());
conn->updateLEDs(m_keyboard->xkb()->leds());
conn->setup();
connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, conn, &LibInput::Connection::updateLEDs);
diff --git a/input.h b/input.h
index 3d16b97..d44513d 100644
--- a/input.h
+++ b/input.h
@@ -285,7 +285,6 @@ private:
QVector<InputEventFilter*> m_filters;
QVector<InputEventSpy*> m_spies;
- KSharedConfigPtr m_inputConfig;
KWIN_SINGLETON(InputRedirection)
friend InputRedirection *input();
diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h
index a417f71..91cf1b2 100644
--- a/libkwineffects/kwineffects.h
+++ b/libkwineffects/kwineffects.h
@@ -1306,6 +1306,12 @@ public:
**/
virtual KSharedConfigPtr config() const = 0;
+ /**
+ * @returns The global input configuration (kcminputrc)
+ * @since 5.10
+ **/
+ virtual KSharedConfigPtr inputConfig() const = 0;
+
Q_SIGNALS:
/**
* Signal emitted when the current desktop changed.
diff --git a/main.cpp b/main.cpp
index 6e045ef..7e15528 100644
--- a/main.cpp
+++ b/main.cpp
@@ -105,6 +105,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
, m_configLock(false)
, m_config()
, m_kxkbConfig()
+ , m_inputConfig()
, m_operationMode(mode)
{
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
@@ -148,6 +149,9 @@ 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 e9150be..c6df3b6 100644
--- a/main.h
+++ b/main.h
@@ -56,6 +56,7 @@ 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
@@ -96,6 +97,13 @@ public:
m_kxkbConfig = config;
}
+ KSharedConfigPtr inputConfig() const {
+ return m_inputConfig;
+ }
+ void setInputConfig(KSharedConfigPtr config) {
+ m_inputConfig = config;
+ }
+
void start();
/**
* @brief The operation mode used by KWin.
@@ -232,6 +240,7 @@ 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;