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.
This commit is contained in:
parent
0c67eb983c
commit
e28e4cb189
9 changed files with 42 additions and 23 deletions
|
@ -1,6 +1,6 @@
|
||||||
add_subdirectory(helper)
|
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)
|
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test)
|
||||||
|
|
||||||
function(integrationTest)
|
function(integrationTest)
|
||||||
|
|
|
@ -82,7 +82,7 @@ void KeyboardLayoutTest::initTestCase()
|
||||||
|
|
||||||
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
||||||
kwinApp()->setKxkbConfig(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();
|
kwinApp()->start();
|
||||||
QVERIFY(workspaceCreatedSpy.wait());
|
QVERIFY(workspaceCreatedSpy.wait());
|
||||||
|
@ -482,7 +482,7 @@ void KeyboardLayoutTest::testNumLock()
|
||||||
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
|
|
||||||
// let's reconfigure to enable through config
|
// 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.writeEntry("NumLock", 0);
|
||||||
group.sync();
|
group.sync();
|
||||||
xkb->reconfigure();
|
xkb->reconfigure();
|
||||||
|
|
18
cursor.cpp
18
cursor.cpp
|
@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// KDE
|
// KDE
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KSharedConfig>
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
@ -127,7 +126,7 @@ void Cursor::loadThemeSettings()
|
||||||
|
|
||||||
void Cursor::loadThemeFromKConfig()
|
void Cursor::loadThemeFromKConfig()
|
||||||
{
|
{
|
||||||
KConfigGroup mousecfg(kwinApp()->inputConfig(), "Mouse");
|
KConfigGroup mousecfg(InputConfig::self()->inputConfig(), "Mouse");
|
||||||
const QString themeName = mousecfg.readEntry("cursorTheme", defaultThemeName());
|
const QString themeName = mousecfg.readEntry("cursorTheme", defaultThemeName());
|
||||||
const uint themeSize = mousecfg.readEntry("cursorSize", defaultThemeSize());
|
const uint themeSize = mousecfg.readEntry("cursorSize", defaultThemeSize());
|
||||||
updateTheme(themeName, themeSize);
|
updateTheme(themeName, themeSize);
|
||||||
|
@ -144,9 +143,10 @@ void Cursor::updateTheme(const QString &name, int size)
|
||||||
|
|
||||||
void Cursor::slotKGlobalSettingsNotifyChange(int type, int arg)
|
void Cursor::slotKGlobalSettingsNotifyChange(int type, int arg)
|
||||||
{
|
{
|
||||||
|
// #endif
|
||||||
Q_UNUSED(arg)
|
Q_UNUSED(arg)
|
||||||
if (type == 5 /*CursorChanged*/) {
|
if (type == 5 /*CursorChanged*/) {
|
||||||
kwinApp()->inputConfig()->reparseConfiguration();
|
InputConfig::self()->inputConfig()->reparseConfiguration();
|
||||||
loadThemeFromKConfig();
|
loadThemeFromKConfig();
|
||||||
// sync to environment
|
// sync to environment
|
||||||
qputenv("XCURSOR_THEME", m_themeName.toUtf8());
|
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
|
} // namespace
|
||||||
|
|
20
cursor.h
20
cursor.h
|
@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
// KF
|
||||||
|
#include <KSharedConfig>
|
||||||
// xcb
|
// xcb
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
@ -311,6 +313,24 @@ private:
|
||||||
QVector<Cursor*> m_cursors;
|
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
|
inline const QPoint &Cursor::currentPos() const
|
||||||
{
|
{
|
||||||
return m_pos;
|
return m_pos;
|
||||||
|
|
|
@ -1684,7 +1684,7 @@ KSharedConfigPtr EffectsHandlerImpl::config() const
|
||||||
|
|
||||||
KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
|
KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
|
||||||
{
|
{
|
||||||
return kwinApp()->inputConfig();
|
return InputConfig::self()->inputConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect *EffectsHandlerImpl::findEffect(const QString &name) const
|
Effect *EffectsHandlerImpl::findEffect(const QString &name) const
|
||||||
|
|
|
@ -2150,7 +2150,7 @@ void InputRedirection::setupInputFilters()
|
||||||
void InputRedirection::reconfigure()
|
void InputRedirection::reconfigure()
|
||||||
{
|
{
|
||||||
if (Application::usesLibinput()) {
|
if (Application::usesLibinput()) {
|
||||||
auto inputConfig = kwinApp()->inputConfig();
|
auto inputConfig = InputConfig::self()->inputConfig();
|
||||||
inputConfig->reparseConfiguration();
|
inputConfig->reparseConfiguration();
|
||||||
const auto config = inputConfig->group(QStringLiteral("Keyboard"));
|
const auto config = inputConfig->group(QStringLiteral("Keyboard"));
|
||||||
const int delay = config.readEntry("RepeatDelay", 660);
|
const int delay = config.readEntry("RepeatDelay", 660);
|
||||||
|
@ -2178,7 +2178,7 @@ void InputRedirection::setupLibInput()
|
||||||
waylandServer()->display()->createRelativePointerManager(KWaylandServer::RelativePointerInterfaceVersion::UnstableV1, waylandServer()->display())->create();
|
waylandServer()->display()->createRelativePointerManager(KWaylandServer::RelativePointerInterfaceVersion::UnstableV1, waylandServer()->display())->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->setInputConfig(kwinApp()->inputConfig());
|
conn->setInputConfig(InputConfig::self()->inputConfig());
|
||||||
conn->updateLEDs(m_keyboard->xkb()->leds());
|
conn->updateLEDs(m_keyboard->xkb()->leds());
|
||||||
waylandServer()->updateKeyState(m_keyboard->xkb()->leds());
|
waylandServer()->updateKeyState(m_keyboard->xkb()->leds());
|
||||||
connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, waylandServer(), &WaylandServer::updateKeyState);
|
connect(m_keyboard, &KeyboardInputRedirection::ledsChanged, waylandServer(), &WaylandServer::updateKeyState);
|
||||||
|
|
|
@ -111,7 +111,7 @@ void KeyboardInputRedirection::init()
|
||||||
Q_ASSERT(!m_inited);
|
Q_ASSERT(!m_inited);
|
||||||
m_inited = true;
|
m_inited = true;
|
||||||
const auto config = kwinApp()->kxkbConfig();
|
const auto config = kwinApp()->kxkbConfig();
|
||||||
m_xkb->setNumLockConfig(kwinApp()->inputConfig());
|
m_xkb->setNumLockConfig(InputConfig::self()->inputConfig());
|
||||||
m_xkb->setConfig(config);
|
m_xkb->setConfig(config);
|
||||||
|
|
||||||
m_input->installInputEventSpy(new KeyStateChangedSpy(m_input));
|
m_input->installInputEventSpy(new KeyStateChangedSpy(m_input));
|
||||||
|
|
4
main.cpp
4
main.cpp
|
@ -106,7 +106,6 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
|
||||||
, m_configLock(false)
|
, m_configLock(false)
|
||||||
, m_config()
|
, m_config()
|
||||||
, m_kxkbConfig()
|
, m_kxkbConfig()
|
||||||
, m_inputConfig()
|
|
||||||
, m_operationMode(mode)
|
, m_operationMode(mode)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
|
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
|
||||||
|
@ -150,9 +149,6 @@ void Application::start()
|
||||||
if (!m_kxkbConfig) {
|
if (!m_kxkbConfig) {
|
||||||
m_kxkbConfig = KSharedConfig::openConfig(QStringLiteral("kxkbrc"), KConfig::NoGlobals);
|
m_kxkbConfig = KSharedConfig::openConfig(QStringLiteral("kxkbrc"), KConfig::NoGlobals);
|
||||||
}
|
}
|
||||||
if (!m_inputConfig) {
|
|
||||||
m_inputConfig = KSharedConfig::openConfig(QStringLiteral("kcminputrc"), KConfig::NoGlobals);
|
|
||||||
}
|
|
||||||
|
|
||||||
performStartup();
|
performStartup();
|
||||||
}
|
}
|
||||||
|
|
9
main.h
9
main.h
|
@ -54,7 +54,6 @@ class KWIN_EXPORT Application : public QApplication
|
||||||
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
|
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
|
||||||
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
|
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
|
||||||
Q_PROPERTY(KSharedConfigPtr kxkbConfig READ kxkbConfig WRITE setKxkbConfig)
|
Q_PROPERTY(KSharedConfigPtr kxkbConfig READ kxkbConfig WRITE setKxkbConfig)
|
||||||
Q_PROPERTY(KSharedConfigPtr inputConfig READ inputConfig WRITE setInputConfig)
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief This enum provides the various operation modes of KWin depending on the available
|
* @brief This enum provides the various operation modes of KWin depending on the available
|
||||||
|
@ -94,13 +93,6 @@ public:
|
||||||
m_kxkbConfig = std::move(config);
|
m_kxkbConfig = std::move(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
KSharedConfigPtr inputConfig() const {
|
|
||||||
return m_inputConfig;
|
|
||||||
}
|
|
||||||
void setInputConfig(KSharedConfigPtr config) {
|
|
||||||
m_inputConfig = std::move(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
/**
|
/**
|
||||||
* @brief The operation mode used by KWin.
|
* @brief The operation mode used by KWin.
|
||||||
|
@ -248,7 +240,6 @@ private:
|
||||||
bool m_configLock;
|
bool m_configLock;
|
||||||
KSharedConfigPtr m_config;
|
KSharedConfigPtr m_config;
|
||||||
KSharedConfigPtr m_kxkbConfig;
|
KSharedConfigPtr m_kxkbConfig;
|
||||||
KSharedConfigPtr m_inputConfig;
|
|
||||||
OperationMode m_operationMode;
|
OperationMode m_operationMode;
|
||||||
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
|
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
|
||||||
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;
|
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;
|
||||||
|
|
Loading…
Reference in a new issue