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:
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "TextBackend.h"
|
||||
#include "InputMethodProtocol.h"
|
||||
|
||||
#include <QWaylandClientExtensionTemplate>
|
||||
#include <memory>
|
||||
|
||||
class KWinInputContext;
|
||||
|
||||
// Binds zwp_input_method_v1, which KWin only offers to the process it launched
|
||||
// as the virtual keyboard (see --inputmethod / System Settings → Virtual Keyboard).
|
||||
class KWinInputMethodGlobal
|
||||
: public QWaylandClientExtensionTemplate<KWinInputMethodGlobal>
|
||||
, public QtWayland::zwp_input_method_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KWinInputMethodGlobal();
|
||||
|
||||
Q_SIGNALS:
|
||||
void activated(::zwp_input_method_context_v1 *context);
|
||||
void deactivated();
|
||||
|
||||
protected:
|
||||
void zwp_input_method_v1_activate(::zwp_input_method_context_v1 *context) override;
|
||||
void zwp_input_method_v1_deactivate(::zwp_input_method_context_v1 *context) override;
|
||||
};
|
||||
|
||||
class KWinInputMethod : public TextBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KWinInputMethod(QObject *parent = nullptr);
|
||||
~KWinInputMethod() override;
|
||||
|
||||
// False when the compositor didn't hand us the input-method global.
|
||||
bool isAvailable() const;
|
||||
|
||||
bool isActive() const override;
|
||||
QString surroundingText() const override;
|
||||
int cursorPosition() const override;
|
||||
|
||||
void commitText(const QString &text) override;
|
||||
void setPreedit(const QString &text) override;
|
||||
void sendKeysym(quint32 keysym, Qt::KeyboardModifiers modifiers) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void availableChanged();
|
||||
|
||||
private:
|
||||
void activate(::zwp_input_method_context_v1 *context);
|
||||
void deactivate();
|
||||
|
||||
KWinInputMethodGlobal m_global;
|
||||
std::unique_ptr<KWinInputContext> m_context;
|
||||
};
|
||||
Reference in New Issue
Block a user