Type into any window: fake input when no text field is focused

- KWinFakeInput (org_kde_kwin_fake_input v6, offered by KWin to the
  input-method process): keysyms with real modifier keys held
- The KWin backend uses the input method in text fields and fake input
  everywhere else, so shortcuts, terminals and the desktop get keys
- Text rules (auto-capitalization, double-space) only apply in fields
- Always Show setting keeps the keyboard up without a text field

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 21:59:32 +02:00
co-authored by Claude Opus 5.5
parent ba2f17d665
commit f816135162
20 changed files with 303 additions and 23 deletions
+13 -1
View File
@@ -1,6 +1,8 @@
#include "KWinInputMethod.h"
#include "KWinInputContext.h"
#include <xkbcommon/xkbcommon-keysyms.h>
KWinInputMethodGlobal::KWinInputMethodGlobal()
: QWaylandClientExtensionTemplate(1)
{
@@ -46,12 +48,20 @@ void KWinInputMethod::commitText(const QString &text)
{
if (m_context)
m_context->commit(text);
else
m_fakeInput.typeText(text);
}
void KWinInputMethod::replaceBeforeCursor(const QString &before, const QString &text)
{
if (m_context)
if (m_context) {
m_context->replaceBeforeCursor(before, text);
return;
}
// Key events are one ordered stream, so plain Backspaces are safe here.
for (qsizetype i = 0; i < before.toUcs4().size(); ++i)
m_fakeInput.sendKeysym(XKB_KEY_BackSpace);
m_fakeInput.typeText(text);
}
void KWinInputMethod::setPreedit(const QString &text)
@@ -64,6 +74,8 @@ void KWinInputMethod::sendKeysym(quint32 keysym, Qt::KeyboardModifiers modifiers
{
if (m_context)
m_context->sendKeysym(keysym, modifiers);
else
m_fakeInput.sendKeysym(keysym, modifiers);
}
void KWinInputMethod::activate(::zwp_input_method_context_v1 *context)