move InputMethod singleton to Application

This commit is contained in:
Xaver Hugl 2022-07-20 12:14:27 +02:00
parent 45d4677973
commit 9337f145d5
12 changed files with 65 additions and 64 deletions

View file

@ -104,7 +104,7 @@ void InputMethodTest::init()
workspace()->setActiveOutput(QPoint(640, 512)); workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512)); KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
InputMethod::self()->setEnabled(true); kwinApp()->inputMethod()->setEnabled(true);
} }
void InputMethodTest::cleanup() void InputMethodTest::cleanup()
@ -181,29 +181,29 @@ void InputMethodTest::testEnableDisableV3()
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat()))); textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
textInputV3->enable(); textInputV3->enable();
QSignalSpy inputMethodActiveSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
// just enabling the text-input should not show it but rather on commit // just enabling the text-input should not show it but rather on commit
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit(); textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
// disable text input and ensure that it is not hiding input panel without commit // disable text input and ensure that it is not hiding input panel without commit
inputMethodActiveSpy.clear(); inputMethodActiveSpy.clear();
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
textInputV3->disable(); textInputV3->disable();
textInputV3->commit(); textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
} }
void InputMethodTest::testEnableActive() void InputMethodTest::testEnableActive()
{ {
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved); QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QSignalSpy activateSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
// Create an xdg_toplevel surface and wait for the compositor to catch up. // Create an xdg_toplevel surface and wait for the compositor to catch up.
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface()); QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
@ -235,12 +235,12 @@ void InputMethodTest::testEnableActive()
textInput->showInputPanel(); textInput->showInputPanel();
activateSpy.wait(200); activateSpy.wait(200);
QVERIFY(activateSpy.isEmpty()); QVERIFY(activateSpy.isEmpty());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
auto keyboardWindow = Test::inputPanelWindow(); auto keyboardWindow = Test::inputPanelWindow();
QVERIFY(keyboardWindow); QVERIFY(keyboardWindow);
textInput->enable(surface.get()); textInput->enable(surface.get());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
// Destroy the test window. // Destroy the test window.
shellSurface.reset(); shellSurface.reset();
@ -249,14 +249,14 @@ void InputMethodTest::testEnableActive()
void InputMethodTest::testHidePanel() void InputMethodTest::testHidePanel()
{ {
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
touchNow(); touchNow();
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved); QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QVERIFY(windowAddedSpy.isValid()); QVERIFY(windowAddedSpy.isValid());
QSignalSpy activateSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QScopedPointer<TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat())); QScopedPointer<TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
// Create an xdg_toplevel surface and wait for the compositor to catch up. // Create an xdg_toplevel surface and wait for the compositor to catch up.
@ -273,16 +273,16 @@ void InputMethodTest::testHidePanel()
QCOMPARE(windowAddedSpy.count(), 2); QCOMPARE(windowAddedSpy.count(), 2);
QVERIFY(activateSpy.count() || activateSpy.wait()); QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
auto keyboardWindow = Test::inputPanelWindow(); auto keyboardWindow = Test::inputPanelWindow();
auto ipsurface = Test::inputPanelSurface(); auto ipsurface = Test::inputPanelSurface();
QVERIFY(keyboardWindow); QVERIFY(keyboardWindow);
windowRemovedSpy.clear(); windowRemovedSpy.clear();
delete ipsurface; delete ipsurface;
QVERIFY(InputMethod::self()->isVisible()); QVERIFY(kwinApp()->inputMethod()->isVisible());
QVERIFY(windowRemovedSpy.count() || windowRemovedSpy.wait()); QVERIFY(windowRemovedSpy.count() || windowRemovedSpy.wait());
QVERIFY(!InputMethod::self()->isVisible()); QVERIFY(!kwinApp()->inputMethod()->isVisible());
// Destroy the test window. // Destroy the test window.
shellSurface.reset(); shellSurface.reset();
@ -292,13 +292,13 @@ void InputMethodTest::testHidePanel()
void InputMethodTest::testSwitchFocusedSurfaces() void InputMethodTest::testSwitchFocusedSurfaces()
{ {
touchNow(); touchNow();
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved); QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QVERIFY(windowAddedSpy.isValid()); QVERIFY(windowAddedSpy.isValid());
QSignalSpy activateSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QScopedPointer<TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat())); QScopedPointer<TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
QVector<Window *> windows; QVector<Window *> windows;
@ -316,20 +316,20 @@ void InputMethodTest::testSwitchFocusedSurfaces()
QCOMPARE(windowAddedSpy.count(), 3); QCOMPARE(windowAddedSpy.count(), 3);
waylandServer()->seat()->setFocusedTextInputSurface(windows.constFirst()->surface()); waylandServer()->seat()->setFocusedTextInputSurface(windows.constFirst()->surface());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
textInput->enable(surfaces.last()); textInput->enable(surfaces.last());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface()); waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
activateSpy.clear(); activateSpy.clear();
waylandServer()->seat()->setFocusedTextInputSurface(windows.last()->surface()); waylandServer()->seat()->setFocusedTextInputSurface(windows.last()->surface());
QVERIFY(activateSpy.count() || activateSpy.wait()); QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
activateSpy.clear(); activateSpy.clear();
waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface()); waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface());
QVERIFY(activateSpy.count() || activateSpy.wait()); QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
// Destroy the test window. // Destroy the test window.
for (int i = 0; i < windows.count(); ++i) { for (int i = 0; i < windows.count(); ++i) {
@ -352,13 +352,13 @@ void InputMethodTest::testV3Styling()
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat()))); textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
textInputV3->enable(); textInputV3->enable();
QSignalSpy inputMethodActiveSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate); QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate);
// just enabling the text-input should not show it but rather on commit // just enabling the text-input should not show it but rather on commit
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit(); textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
QVERIFY(inputMethodActivateSpy.wait()); QVERIFY(inputMethodActivateSpy.wait());
auto context = Test::inputMethod()->context(); auto context = Test::inputMethod()->context();
QSignalSpy textInputPreeditSpy(textInputV3, &Test::TextInputV3::preeditString); QSignalSpy textInputPreeditSpy(textInputV3, &Test::TextInputV3::preeditString);
@ -440,24 +440,24 @@ void InputMethodTest::testDisableShowInputPanel()
QScopedPointer<KWayland::Client::TextInput> textInputV2(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat())); QScopedPointer<KWayland::Client::TextInput> textInputV2(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
QSignalSpy inputMethodActiveSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
// just enabling the text-input should not show it but rather on commit // just enabling the text-input should not show it but rather on commit
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV2->enable(surface.get()); textInputV2->enable(surface.get());
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
// disable text input and ensure that it is not hiding input panel without commit // disable text input and ensure that it is not hiding input panel without commit
inputMethodActiveSpy.clear(); inputMethodActiveSpy.clear();
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
textInputV2->disable(surface.get()); textInputV2->disable(surface.get());
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy requestShowInputPanelSpy(waylandServer()->seat()->textInputV2(), &KWaylandServer::TextInputV2Interface::requestShowInputPanel); QSignalSpy requestShowInputPanelSpy(waylandServer()->seat()->textInputV2(), &KWaylandServer::TextInputV2Interface::requestShowInputPanel);
textInputV2->showInputPanel(); textInputV2->showInputPanel();
QVERIFY(requestShowInputPanelSpy.count() || requestShowInputPanelSpy.wait()); QVERIFY(requestShowInputPanelSpy.count() || requestShowInputPanelSpy.wait());
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
} }
void InputMethodTest::testModifierForwarding() void InputMethodTest::testModifierForwarding()
@ -474,13 +474,13 @@ void InputMethodTest::testModifierForwarding()
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat()))); textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
textInputV3->enable(); textInputV3->enable();
QSignalSpy inputMethodActiveSpy(InputMethod::self(), &InputMethod::activeChanged); QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate); QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate);
// just enabling the text-input should not show it but rather on commit // just enabling the text-input should not show it but rather on commit
QVERIFY(!InputMethod::self()->isActive()); QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit(); textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait()); QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(InputMethod::self()->isActive()); QVERIFY(kwinApp()->inputMethod()->isActive());
QVERIFY(inputMethodActivateSpy.wait()); QVERIFY(inputMethodActivateSpy.wait());
auto context = Test::inputMethod()->context(); auto context = Test::inputMethod()->context();
QScopedPointer<KWayland::Client::Keyboard> keyboardGrab(new KWayland::Client::Keyboard); QScopedPointer<KWayland::Client::Keyboard> keyboardGrab(new KWayland::Client::Keyboard);

View file

@ -123,10 +123,10 @@ void WaylandTestApplication::destroyVirtualInputDevices()
void WaylandTestApplication::performStartup() void WaylandTestApplication::performStartup()
{ {
if (!m_inputMethodServerToStart.isEmpty()) { if (!m_inputMethodServerToStart.isEmpty()) {
InputMethod::create(); createInputMethod();
if (m_inputMethodServerToStart != QStringLiteral("internal")) { if (m_inputMethodServerToStart != QStringLiteral("internal")) {
InputMethod::self()->setInputMethodCommand(m_inputMethodServerToStart); inputMethod()->setInputMethodCommand(m_inputMethodServerToStart);
InputMethod::self()->setEnabled(true); inputMethod()->setEnabled(true);
} }
} }

View file

@ -59,7 +59,7 @@ void VirtualKeyboardDBusTest::initTestCase()
void VirtualKeyboardDBusTest::init() void VirtualKeyboardDBusTest::init()
{ {
InputMethod::self()->setEnabled(false); kwinApp()->inputMethod()->setEnabled(false);
} }
void VirtualKeyboardDBusTest::cleanup() void VirtualKeyboardDBusTest::cleanup()
@ -69,7 +69,7 @@ void VirtualKeyboardDBusTest::cleanup()
void VirtualKeyboardDBusTest::testEnabled() void VirtualKeyboardDBusTest::testEnabled()
{ {
VirtualKeyboardDBus dbus(KWin::InputMethod::self()); VirtualKeyboardDBus dbus(KWin::kwinApp()->inputMethod());
OrgKdeKwinVirtualKeyboardInterface iface(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()); OrgKdeKwinVirtualKeyboardInterface iface(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus());
QSignalSpy helperChangedSpy(&iface, &OrgKdeKwinVirtualKeyboardInterface::enabledChanged); QSignalSpy helperChangedSpy(&iface, &OrgKdeKwinVirtualKeyboardInterface::enabledChanged);
QVERIFY(helperChangedSpy.isValid()); QVERIFY(helperChangedSpy.isValid());
@ -118,7 +118,7 @@ void VirtualKeyboardDBusTest::testRequestEnabled()
QFETCH(QString, method); QFETCH(QString, method);
QFETCH(bool, expectedResult); QFETCH(bool, expectedResult);
VirtualKeyboardDBus dbus(KWin::InputMethod::self()); VirtualKeyboardDBus dbus(KWin::kwinApp()->inputMethod());
OrgKdeKwinVirtualKeyboardInterface iface(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus()); OrgKdeKwinVirtualKeyboardInterface iface(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus());
iface.setEnabled(expectedResult); iface.setEnabled(expectedResult);

View file

@ -263,7 +263,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
slotOutputAdded(output); slotOutputAdded(output);
} }
connect(InputMethod::self(), &InputMethod::panelChanged, this, &EffectsHandlerImpl::inputPanelChanged); connect(kwinApp()->inputMethod(), &InputMethod::panelChanged, this, &EffectsHandlerImpl::inputPanelChanged);
reconfigure(); reconfigure();
} }
@ -1821,11 +1821,11 @@ qreal EffectsHandlerImpl::renderTargetScale() const
KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const
{ {
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) { if (!kwinApp()->inputMethod() || !kwinApp()->inputMethod()->isEnabled()) {
return nullptr; return nullptr;
} }
auto panel = InputMethod::self()->panel(); auto panel = kwinApp()->inputMethod()->panel();
if (panel) { if (panel) {
return panel->effectWindow(); return panel->effectWindow();
} }
@ -1834,11 +1834,11 @@ KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const
bool EffectsHandlerImpl::isInputPanelOverlay() const bool EffectsHandlerImpl::isInputPanelOverlay() const
{ {
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) { if (!kwinApp()->inputMethod() || !kwinApp()->inputMethod()->isEnabled()) {
return true; return true;
} }
auto panel = InputMethod::self()->panel(); auto panel = kwinApp()->inputMethod()->panel();
if (panel) { if (panel) {
return panel->mode() == InputPanelV1Window::Overlay; return panel->mode() == InputPanelV1Window::Overlay;
} }

View file

@ -292,21 +292,19 @@ void InputEventFilter::passToWaylandServer(QKeyEvent *event)
bool InputEventFilter::passToInputMethod(QKeyEvent *event) bool InputEventFilter::passToInputMethod(QKeyEvent *event)
{ {
auto *inputmethod = InputMethod::self(); if (!kwinApp()->inputMethod()) {
if (!inputmethod) {
return false; return false;
} }
if (auto keyboardGrab = kwinApp()->inputMethod()->keyboardGrab()) {
if (auto keyboardGrab = inputmethod->keyboardGrab()) {
if (event->isAutoRepeat()) { if (event->isAutoRepeat()) {
return true; return true;
} }
auto newState = event->type() == QEvent::KeyPress ? KWaylandServer::KeyboardKeyState::Pressed : KWaylandServer::KeyboardKeyState::Released; auto newState = event->type() == QEvent::KeyPress ? KWaylandServer::KeyboardKeyState::Pressed : KWaylandServer::KeyboardKeyState::Released;
keyboardGrab->sendKey(waylandServer()->display()->nextSerial(), event->timestamp(), event->nativeScanCode(), newState); keyboardGrab->sendKey(waylandServer()->display()->nextSerial(), event->timestamp(), event->nativeScanCode(), newState);
return true; return true;
} else {
return false;
} }
return false;
} }
class VirtualTerminalFilter : public InputEventFilter class VirtualTerminalFilter : public InputEventFilter

View file

@ -49,10 +49,7 @@ using namespace KWaylandServer;
namespace KWin namespace KWin
{ {
KWIN_SINGLETON_FACTORY(InputMethod) InputMethod::InputMethod()
InputMethod::InputMethod(QObject *parent)
: QObject(parent)
{ {
m_enabled = kwinApp()->config()->group("Wayland").readEntry("VirtualKeyboardEnabled", true); m_enabled = kwinApp()->config()->group("Wayland").readEntry("VirtualKeyboardEnabled", true);
// this is actually too late. Other processes are started before init, // this is actually too late. Other processes are started before init,
@ -68,7 +65,6 @@ InputMethod::InputMethod(QObject *parent)
InputMethod::~InputMethod() InputMethod::~InputMethod()
{ {
stopInputMethod(); stopInputMethod();
s_self = nullptr;
} }
void InputMethod::init() void InputMethod::init()

View file

@ -48,6 +48,7 @@ public:
Force = 1, Force = 1,
}; };
InputMethod();
~InputMethod() override; ~InputMethod() override;
void init(); void init();
@ -133,8 +134,6 @@ private:
QString m_inputMethodCommand; QString m_inputMethodCommand;
bool m_hasPendingModifiers = false; bool m_hasPendingModifiers = false;
KWIN_SINGLETON(InputMethod)
}; };
} }

View file

@ -41,7 +41,7 @@ InputPanelV1Window::InputPanelV1Window(InputPanelSurfaceV1Interface *panelSurfac
connect(panelSurface, &InputPanelSurfaceV1Interface::overlayPanel, this, &InputPanelV1Window::showOverlayPanel); connect(panelSurface, &InputPanelSurfaceV1Interface::overlayPanel, this, &InputPanelV1Window::showOverlayPanel);
connect(panelSurface, &InputPanelSurfaceV1Interface::destroyed, this, &InputPanelV1Window::destroyWindow); connect(panelSurface, &InputPanelSurfaceV1Interface::destroyed, this, &InputPanelV1Window::destroyWindow);
InputMethod::self()->setPanel(this); kwinApp()->inputMethod()->setPanel(this);
} }
void InputPanelV1Window::showOverlayPanel() void InputPanelV1Window::showOverlayPanel()

View file

@ -254,7 +254,7 @@ void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::Keyboa
m_input->processFilters(std::bind(&InputEventFilter::keyEvent, std::placeholders::_1, &event)); m_input->processFilters(std::bind(&InputEventFilter::keyEvent, std::placeholders::_1, &event));
m_xkb->forwardModifiers(); m_xkb->forwardModifiers();
if (auto *inputmethod = InputMethod::self()) { if (auto *inputmethod = kwinApp()->inputMethod()) {
inputmethod->forwardModifiers(InputMethod::NoForce); inputmethod->forwardModifiers(InputMethod::NoForce);
} }

View file

@ -276,7 +276,7 @@ void Application::createColorManager()
void Application::createInputMethod() void Application::createInputMethod()
{ {
InputMethod::create(this); m_inputMethod = std::make_unique<InputMethod>();
} }
void Application::installNativeX11EventFilter() void Application::installNativeX11EventFilter()
@ -316,7 +316,7 @@ void Application::destroyColorManager()
void Application::destroyInputMethod() void Application::destroyInputMethod()
{ {
delete InputMethod::self(); m_inputMethod.reset();
} }
void Application::registerEventFilter(X11EventFilter *filter) void Application::registerEventFilter(X11EventFilter *filter)
@ -567,4 +567,9 @@ PluginManager *Application::pluginManager() const
return m_pluginManager.get(); return m_pluginManager.get();
} }
InputMethod *Application::inputMethod() const
{
return m_inputMethod.get();
}
} // namespace } // namespace

View file

@ -30,6 +30,7 @@ namespace KWin
class Platform; class Platform;
class X11EventFilter; class X11EventFilter;
class PluginManager; class PluginManager;
class InputMethod;
class XcbEventFilter : public QAbstractNativeEventFilter class XcbEventFilter : public QAbstractNativeEventFilter
{ {
@ -241,6 +242,7 @@ public:
static void setupLocalizedString(); static void setupLocalizedString();
PluginManager *pluginManager() const; PluginManager *pluginManager() const;
InputMethod *inputMethod() const;
Q_SIGNALS: Q_SIGNALS:
void x11ConnectionChanged(); void x11ConnectionChanged();
@ -298,6 +300,7 @@ private:
qreal m_xwaylandScale = 1; qreal m_xwaylandScale = 1;
QProcessEnvironment m_processEnvironment; QProcessEnvironment m_processEnvironment;
std::unique_ptr<PluginManager> m_pluginManager; std::unique_ptr<PluginManager> m_pluginManager;
std::unique_ptr<InputMethod> m_inputMethod;
}; };
inline static Application *kwinApp() inline static Application *kwinApp()

View file

@ -193,7 +193,7 @@ void ApplicationWayland::refreshSettings(const KConfigGroup &group, const QByteA
{ {
if (group.name() == "Wayland" && names.contains("InputMethod")) { if (group.name() == "Wayland" && names.contains("InputMethod")) {
KDesktopFile file(group.readPathEntry("InputMethod", QString())); KDesktopFile file(group.readPathEntry("InputMethod", QString()));
InputMethod::self()->setInputMethodCommand(file.desktopGroup().readEntry("Exec", QString())); kwinApp()->inputMethod()->setInputMethodCommand(file.desktopGroup().readEntry("Exec", QString()));
} }
if (m_startXWayland && group.name() == "Xwayland" && names.contains("Scale")) { if (m_startXWayland && group.name() == "Xwayland" && names.contains("Scale")) {
@ -212,7 +212,7 @@ void ApplicationWayland::startSession()
connect(m_settingsWatcher.data(), &KConfigWatcher::configChanged, this, &ApplicationWayland::refreshSettings); connect(m_settingsWatcher.data(), &KConfigWatcher::configChanged, this, &ApplicationWayland::refreshSettings);
if (!m_inputMethodServerToStart.isEmpty()) { if (!m_inputMethodServerToStart.isEmpty()) {
InputMethod::self()->setInputMethodCommand(m_inputMethodServerToStart); kwinApp()->inputMethod()->setInputMethodCommand(m_inputMethodServerToStart);
} else { } else {
refreshSettings(kwinSettings->group("Wayland"), {"InputMethod"}); refreshSettings(kwinSettings->group("Wayland"), {"InputMethod"});
} }