Diagnostics collects what this session doesn't allow, logs it, and lists it in the settings panel (with a dot on the gear): KWin not launching sloposk as its keyboard (detected by WAYLAND_SOCKET, since KWin offers the input-method global to every client), fake input missing or too old, org.kde.keyboard unreachable, and the D-Bus control name taken. Modifier combos go through fake input even in text fields: KWin drops the input method's modifier mask for most clients, so Ctrl+A typed "a". The desktop file is generated with an absolute Exec, which KWin needs to match it: one for the installed binary, one for the build's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include "KWinFakeInput.h"
|
|
#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(::zwp_input_method_context_v1 *context);
|
|
|
|
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;
|
|
};
|
|
|
|
// Types into the focused text field through the input method; with none
|
|
// focused, sends key events to the focused window through fake input, so the
|
|
// keyboard works everywhere (shortcuts, terminals, the desktop).
|
|
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;
|
|
// Key events outside text fields, held keys and modifier combos.
|
|
const KWinFakeInput &fakeInput() const { return m_fakeInput; }
|
|
|
|
bool isActive() const override;
|
|
TextContext context() const override;
|
|
|
|
void commitText(const QString &text) override;
|
|
void replaceBeforeCursor(const QString &before, const QString &text) override;
|
|
void setPreedit(const QString &text) override;
|
|
void sendKeysym(quint32 keysym, Qt::KeyboardModifiers modifiers) override;
|
|
void setKeyPressed(quint32 keysym, bool pressed) override;
|
|
|
|
Q_SIGNALS:
|
|
void availableChanged();
|
|
|
|
private:
|
|
void activate(::zwp_input_method_context_v1 *context);
|
|
void deactivate(::zwp_input_method_context_v1 *context);
|
|
|
|
KWinInputMethodGlobal m_global;
|
|
KWinFakeInput m_fakeInput;
|
|
std::unique_ptr<KWinInputContext> m_context;
|
|
// Replaced by an activate before KWin deactivated it; kept until it does.
|
|
std::unique_ptr<KWinInputContext> m_previous;
|
|
};
|