Spike: KWin input-method backend with floating layer-shell window

Registers as KWin's virtual keyboard (input-method-unstable-v1), shows a
non-focusable layer-shell overlay, and commits Unicode text. Verified in a
nested headless KWin with the textprobe tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 14:43:44 +02:00
co-authored by Claude Opus 5.5
commit cdef9b4ad0
15 changed files with 612 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <QObject>
#include <QString>
// Delivers text produced by the keyboard to the focused application.
// Implementations hide the transport (KWin input method, uinput, XTest, ...).
// Keys are identified by XKB keysyms so every backend speaks the same language.
class TextBackend : public QObject
{
Q_OBJECT
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
Q_PROPERTY(QString surroundingText READ surroundingText NOTIFY surroundingChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition NOTIFY surroundingChanged)
public:
using QObject::QObject;
// True while a text field is focused and accepts input.
virtual bool isActive() const = 0;
// Text around the cursor, if the backend knows it (empty otherwise).
virtual QString surroundingText() const { return {}; }
virtual int cursorPosition() const { return -1; }
Q_INVOKABLE virtual void commitText(const QString &text) = 0;
Q_INVOKABLE virtual void setPreedit(const QString &text) = 0;
Q_INVOKABLE virtual void sendKeysym(quint32 keysym, Qt::KeyboardModifiers modifiers = Qt::NoModifier) = 0;
Q_SIGNALS:
void activeChanged();
void surroundingChanged();
};