Commit 222b558b authored by Bhushan Shah's avatar Bhushan Shah 📱

virtualkeyboard: rename class to InputMethod

VirtualKeyboard class does not implement the relevant VirtualKeyboard
protocol but rather implements the InputMethod protcol and can in theory
be used by other input method like e.g. ibus.

Make class name consistent with what it does to avoid confusion in
future.

For now only rename of main class is done and dbus service is kept as-is
to provide retro-compatibility, when input method protocol is
implemented fully, we can think of what to do wrt the dbus interface
later when we fully implement zwp_input_method_unstable_v1 protocol.
parent f558115d
......@@ -114,7 +114,7 @@ add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation"
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "A QtQuick based components set"
PURPOSE "Required at runtime for Virtual desktop KCM and the virtual keyboard"
PURPOSE "Required at runtime for Virtual desktop KCM"
TYPE RUNTIME
)
......@@ -322,7 +322,6 @@ include(ECMQMLModules)
ecm_find_qmlmodule(QtQuick 2.3)
ecm_find_qmlmodule(QtQuick.Controls 1.2)
ecm_find_qmlmodule(QtQuick.Layouts 1.3)
ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1)
ecm_find_qmlmodule(QtQuick.Window 2.1)
ecm_find_qmlmodule(QtMultimedia 5.0)
ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0)
......@@ -532,7 +531,7 @@ set(kwin_SRCS
utils.cpp
virtualdesktops.cpp
virtualdesktopsdbustypes.cpp
virtualkeyboard.cpp
inputmethod.cpp
virtualkeyboard_dbus.cpp
was_user_interaction_x11_filter.cpp
wayland_server.cpp
......
......@@ -14,7 +14,7 @@
#include "../../workspace.h"
#include "../../xcbutils.h"
#include "../../xwl/xwayland.h"
#include "../../virtualkeyboard.h"
#include "../../inputmethod.h"
#include <KPluginMetaData>
......@@ -87,7 +87,7 @@ WaylandTestApplication::~WaylandTestApplication()
void WaylandTestApplication::performStartup()
{
if (!m_inputMethodServerToStart.isEmpty()) {
VirtualKeyboard::create();
InputMethod::create();
if (m_inputMethodServerToStart != QStringLiteral("internal")) {
int socket = dup(waylandServer()->createInputMethodConnection());
if (socket >= 0) {
......
......@@ -12,7 +12,7 @@
#include "wayland_server.h"
#include "workspace.h"
#include "qwayland-input-method-unstable-v1.h"
#include "virtualkeyboard.h"
#include "inputmethod.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
......
......@@ -15,7 +15,7 @@
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "virtualkeyboard.h"
#include "inputmethod.h"
#include "virtualkeyboard_dbus.h"
#include "qwayland-input-method-unstable-v1.h"
#include "qwayland-text-input-unstable-v3.h"
......
......@@ -6,7 +6,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "virtualkeyboard.h"
#include "inputmethod.h"
#include "virtualkeyboard_dbus.h"
#include "input.h"
#include "keyboard_input.h"
......@@ -38,29 +38,29 @@ using namespace KWaylandServer;
namespace KWin
{
KWIN_SINGLETON_FACTORY(VirtualKeyboard)
KWIN_SINGLETON_FACTORY(InputMethod)
VirtualKeyboard::VirtualKeyboard(QObject *parent)
InputMethod::InputMethod(QObject *parent)
: QObject(parent)
{
// this is actually too late. Other processes are started before init,
// so might miss the availability of text input
// but without Workspace we don't have the window listed at all
connect(kwinApp(), &Application::workspaceCreated, this, &VirtualKeyboard::init);
connect(kwinApp(), &Application::workspaceCreated, this, &InputMethod::init);
}
VirtualKeyboard::~VirtualKeyboard() = default;
InputMethod::~InputMethod() = default;
void VirtualKeyboard::init()
void InputMethod::init()
{
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &VirtualKeyboard::hide);
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &InputMethod::hide);
if (waylandServer()) {
m_enabled = !input()->hasAlphaNumericKeyboard();
qCDebug(KWIN_VIRTUALKEYBOARD) << "enabled by default: " << m_enabled;
connect(input(), &InputRedirection::hasAlphaNumericKeyboardChanged, this,
[this] (bool set) {
qCDebug(KWIN_VIRTUALKEYBOARD) << "AlphaNumeric Keyboard changed:" << set << "toggling VirtualKeyboard.";
qCDebug(KWIN_VIRTUALKEYBOARD) << "AlphaNumeric Keyboard changed:" << set << "toggling virtual keyboard.";
setEnabled(!set);
}
);
......@@ -78,40 +78,40 @@ void VirtualKeyboard::init()
setEnabled(!m_enabled);
}
);
connect(this, &VirtualKeyboard::enabledChanged, this, &VirtualKeyboard::updateSni);
connect(this, &InputMethod::enabledChanged, this, &InputMethod::updateSni);
auto dbus = new VirtualKeyboardDBus(this);
qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the DBus interface";
dbus->setEnabled(m_enabled);
connect(dbus, &VirtualKeyboardDBus::activateRequested, this, &VirtualKeyboard::setEnabled);
connect(this, &VirtualKeyboard::enabledChanged, dbus, &VirtualKeyboardDBus::setEnabled);
connect(input(), &InputRedirection::keyStateChanged, this, &VirtualKeyboard::hide);
connect(dbus, &VirtualKeyboardDBus::activateRequested, this, &InputMethod::setEnabled);
connect(this, &InputMethod::enabledChanged, dbus, &VirtualKeyboardDBus::setEnabled);
connect(input(), &InputRedirection::keyStateChanged, this, &InputMethod::hide);
if (waylandServer()) {
waylandServer()->display()->createTextInputManagerV2();
waylandServer()->display()->createTextInputManagerV3();
connect(workspace(), &Workspace::clientAdded, this, &VirtualKeyboard::clientAdded);
connect(waylandServer()->seat(), &SeatInterface::focusedTextInputSurfaceChanged, this, &VirtualKeyboard::handleFocusedSurfaceChanged);
connect(workspace(), &Workspace::clientAdded, this, &InputMethod::clientAdded);
connect(waylandServer()->seat(), &SeatInterface::focusedTextInputSurfaceChanged, this, &InputMethod::handleFocusedSurfaceChanged);
TextInputV2Interface *textInputV2 = waylandServer()->seat()->textInputV2();
connect(textInputV2, &TextInputV2Interface::requestShowInputPanel, this, &VirtualKeyboard::show);
connect(textInputV2, &TextInputV2Interface::requestHideInputPanel, this, &VirtualKeyboard::hide);
connect(textInputV2, &TextInputV2Interface::surroundingTextChanged, this, &VirtualKeyboard::surroundingTextChanged);
connect(textInputV2, &TextInputV2Interface::contentTypeChanged, this, &VirtualKeyboard::contentTypeChanged);
connect(textInputV2, &TextInputV2Interface::requestReset, this, &VirtualKeyboard::requestReset);
connect(textInputV2, &TextInputV2Interface::enabledChanged, this, &VirtualKeyboard::textInputInterfaceV2EnabledChanged);
connect(textInputV2, &TextInputV2Interface::stateCommitted, this, &VirtualKeyboard::stateCommitted);
connect(textInputV2, &TextInputV2Interface::requestShowInputPanel, this, &InputMethod::show);
connect(textInputV2, &TextInputV2Interface::requestHideInputPanel, this, &InputMethod::hide);
connect(textInputV2, &TextInputV2Interface::surroundingTextChanged, this, &InputMethod::surroundingTextChanged);
connect(textInputV2, &TextInputV2Interface::contentTypeChanged, this, &InputMethod::contentTypeChanged);
connect(textInputV2, &TextInputV2Interface::requestReset, this, &InputMethod::requestReset);
connect(textInputV2, &TextInputV2Interface::enabledChanged, this, &InputMethod::textInputInterfaceV2EnabledChanged);
connect(textInputV2, &TextInputV2Interface::stateCommitted, this, &InputMethod::stateCommitted);
TextInputV3Interface *textInputV3 = waylandServer()->seat()->textInputV3();
connect(textInputV3, &TextInputV3Interface::enabledChanged, this, &VirtualKeyboard::textInputInterfaceV3EnabledChanged);
connect(textInputV3, &TextInputV3Interface::surroundingTextChanged, this, &VirtualKeyboard::surroundingTextChanged);
connect(textInputV3, &TextInputV3Interface::contentTypeChanged, this, &VirtualKeyboard::contentTypeChanged);
connect(textInputV3, &TextInputV3Interface::stateCommitted, this, &VirtualKeyboard::stateCommitted);
connect(textInputV3, &TextInputV3Interface::enabledChanged, this, &InputMethod::textInputInterfaceV3EnabledChanged);
connect(textInputV3, &TextInputV3Interface::surroundingTextChanged, this, &InputMethod::surroundingTextChanged);
connect(textInputV3, &TextInputV3Interface::contentTypeChanged, this, &InputMethod::contentTypeChanged);
connect(textInputV3, &TextInputV3Interface::stateCommitted, this, &InputMethod::stateCommitted);
}
}
void VirtualKeyboard::show()
void InputMethod::show()
{
auto t = waylandServer()->seat()->textInputV2();
if (t) {
......@@ -120,13 +120,13 @@ void VirtualKeyboard::show()
}
}
void VirtualKeyboard::hide()
void InputMethod::hide()
{
waylandServer()->inputMethod()->sendDeactivate();
updateInputPanelState();
}
void VirtualKeyboard::clientAdded(AbstractClient* client)
void InputMethod::clientAdded(AbstractClient* client)
{
if (!client->isInputMethod()) {
return;
......@@ -150,7 +150,7 @@ void VirtualKeyboard::clientAdded(AbstractClient* client)
connect(m_inputClient, &AbstractClient::frameGeometryChanged, this, refreshFrame);
}
void VirtualKeyboard::handleFocusedSurfaceChanged()
void InputMethod::handleFocusedSurfaceChanged()
{
SurfaceInterface *focusedSurface = waylandServer()->seat()->focusedTextInputSurface();
if (focusedSurface) {
......@@ -169,7 +169,7 @@ void VirtualKeyboard::handleFocusedSurfaceChanged()
updateInputPanelState();
}
void VirtualKeyboard::surroundingTextChanged()
void InputMethod::surroundingTextChanged()
{
auto t2 = waylandServer()->seat()->textInputV2();
auto t3 = waylandServer()->seat()->textInputV3();
......@@ -187,7 +187,7 @@ void VirtualKeyboard::surroundingTextChanged()
}
}
void VirtualKeyboard::contentTypeChanged()
void InputMethod::contentTypeChanged()
{
auto t2 = waylandServer()->seat()->textInputV2();
auto t3 = waylandServer()->seat()->textInputV3();
......@@ -203,7 +203,7 @@ void VirtualKeyboard::contentTypeChanged()
}
}
void VirtualKeyboard::requestReset()
void InputMethod::requestReset()
{
auto t2 = waylandServer()->seat()->textInputV2();
auto inputContext = waylandServer()->inputMethod()->context();
......@@ -218,7 +218,7 @@ void VirtualKeyboard::requestReset()
}
}
void VirtualKeyboard::textInputInterfaceV2EnabledChanged()
void InputMethod::textInputInterfaceV2EnabledChanged()
{
auto t = waylandServer()->seat()->textInputV2();
if (t->isEnabled()) {
......@@ -232,7 +232,7 @@ void VirtualKeyboard::textInputInterfaceV2EnabledChanged()
}
}
void VirtualKeyboard::textInputInterfaceV3EnabledChanged()
void InputMethod::textInputInterfaceV3EnabledChanged()
{
auto t3 = waylandServer()->seat()->textInputV3();
if (t3->isEnabled()) {
......@@ -247,7 +247,7 @@ void VirtualKeyboard::textInputInterfaceV3EnabledChanged()
}
}
void VirtualKeyboard::stateCommitted(uint32_t serial)
void InputMethod::stateCommitted(uint32_t serial)
{
auto inputContext = waylandServer()->inputMethod()->context();
if (!inputContext) {
......@@ -256,7 +256,7 @@ void VirtualKeyboard::stateCommitted(uint32_t serial)
inputContext->sendCommitState(serial);
}
void VirtualKeyboard::setEnabled(bool enabled)
void InputMethod::setEnabled(bool enabled)
{
if (m_enabled == enabled) {
return;
......@@ -374,7 +374,7 @@ static void setTextDirection(uint32_t serial, Qt::LayoutDirection direction)
}
}
void VirtualKeyboard::setPreeditCursor(qint32 index)
void InputMethod::setPreeditCursor(qint32 index)
{
auto t2 = waylandServer()->seat()->textInputV2();
if (t2 && t2->isEnabled()) {
......@@ -389,7 +389,7 @@ void VirtualKeyboard::setPreeditCursor(qint32 index)
}
void VirtualKeyboard::setPreeditString(uint32_t serial, const QString &text, const QString &commit)
void InputMethod::setPreeditString(uint32_t serial, const QString &text, const QString &commit)
{
Q_UNUSED(serial)
auto t2 = waylandServer()->seat()->textInputV2();
......@@ -403,7 +403,7 @@ void VirtualKeyboard::setPreeditString(uint32_t serial, const QString &text, con
}
}
void VirtualKeyboard::adoptInputMethodContext()
void InputMethod::adoptInputMethodContext()
{
auto inputContext = waylandServer()->inputMethod()->context();
......@@ -427,11 +427,11 @@ void VirtualKeyboard::adoptInputMethodContext()
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::commitString, waylandServer(), &commitString);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::deleteSurroundingText, waylandServer(), &deleteSurroundingText);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::cursorPosition, waylandServer(), &setCursorPosition);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditString, this, &VirtualKeyboard::setPreeditString);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditCursor, this, &VirtualKeyboard::setPreeditCursor);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditString, this, &InputMethod::setPreeditString);
connect(inputContext, &KWaylandServer::InputMethodContextV1Interface::preeditCursor, this, &InputMethod::setPreeditCursor);
}
void VirtualKeyboard::updateSni()
void InputMethod::updateSni()
{
if (!m_sni) {
return;
......@@ -446,7 +446,7 @@ void VirtualKeyboard::updateSni()
m_sni->setToolTipTitle(i18n("Whether to show the virtual keyboard on demand."));
}
void VirtualKeyboard::updateInputPanelState()
void InputMethod::updateInputPanelState()
{
if (!waylandServer()) {
return;
......
......@@ -21,11 +21,15 @@ class KStatusNotifierItem;
namespace KWin
{
class KWIN_EXPORT VirtualKeyboard : public QObject
/**
* This class implements the zwp_input_method_unstable_v1, which is currently used to provide
* the Virtual Keyboard using supported input method client (maliit-keyboard e.g.)
**/
class KWIN_EXPORT InputMethod : public QObject
{
Q_OBJECT
public:
~VirtualKeyboard() override;
~InputMethod() override;
void init();
void hide();
......@@ -67,7 +71,7 @@ private:
QPointer<AbstractClient> m_inputClient;
QPointer<AbstractClient> m_trackedClient;
KWIN_SINGLETON(VirtualKeyboard)
KWIN_SINGLETON(InputMethod)
};
}
......
......@@ -8,7 +8,7 @@
*/
#include "main_wayland.h"
#include "composite.h"
#include "virtualkeyboard.h"
#include "inputmethod.h"
#include "workspace.h"
#include <config-kwin.h>
// kwin
......@@ -149,7 +149,7 @@ void ApplicationWayland::performStartup()
// now libinput thread has been created, adjust scheduler to not leak into other processes
gainRealTime(RealTimeFlags::ResetOnFork);
VirtualKeyboard::create(this);
InputMethod::create(this);
createBackend();
TabletModeManager::create(this);
#ifdef PipeWire_FOUND
......
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