Commit e28e4cb1 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Move inputConfig away from KWin::Application

We were calling it from tests that were not running a KWin::Application
and not even including the symbols from main.cpp and main.h. The only
reason they linked was that it was static_casting up the QCoreApplication.
parent 0c67eb98
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)
......
......@@ -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();
......
......@@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// KDE
#include <KConfig>
#include <KConfigGroup>
#include <KSharedConfig>
// Qt
#include <QAbstractEventDispatcher>
#include <QDBusConnection>
......@@ -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
......@@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QHash>
#include <QObject>
#include <QPoint>
// KF
#include <KSharedConfig>
// xcb
#include <xcb/xcb.h>
......@@ -311,6 +313,24 @@ private:
QVector<Cursor*> 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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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));
......
......@@ -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>("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();
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment