This is the first step in https://invent.kde.org/plasma/plasma-keyboard/-/merge_requests/109 (please see it for context and rationale), and introduces a basic input engine and layout framework. The virtual keyboard library and engine are in /virtualkeyboard: - /virtualkeyboard/components - QML components for building keyboard layouts and the keyboard itself - /virtualkeyboard/inputbackend.h - generic input "backend" for sending events from the vkbd, currently just for input-method-v1 but could be for xdg-remote-desktop? - /virtualkeyboard/inputengine.h - internal input method "state" - /virtualkeyboard/keyboardcontroller.h - internal virtual keyboard panel "state" - /virtualkeyboard/keyboardpackageresolver.h - utilities to find and parse keyboard "layout packages" - /virtualkeyboard/textcomposers/abstracttextcomposer.h - abstract interface that implements event handling from the keyboard layout and talks to InputEngine for the final "text" (needed for CJK, text prediction) - /virtualkeyboard/textcomposers/directtextcomposer.h - directly enters text (enough for most layouts) For an example keyboard package (not included in this MR), please see https://invent.kde.org/plasma/plasma-keyboard/-/tree/e8e33ef2103c545decaed556a43907349e789fb8/layouts/en (shared layouts in https://invent.kde.org/plasma/plasma-keyboard/-/tree/e8e33ef2103c545decaed556a43907349e789fb8/layouts/defaultplugin) - Metadata is in metadata.json, which lists the locales the package is meant for, and what layouts it provides - Each keyboard layout has predefined "required" layouts: main, symbols, digits, numbers and dialpad - Each keyboard layout can define which form factors to show up for (ex. desktop ones won't show up in the mobile kcm keyboard selector by default)
Plasma Keyboard
The plasma-keyboard is a virtual keyboard based on Qt Virtual Keyboard designed to integrate in Plasma.
It wraps Qt Virtual Keyboard in a window, and uses the input-method-v1 Wayland protocol to communicate with the compositor to function as an input method.
Install using the flatpak nightly repository
https://cdn.kde.org/flatpak/plasma-keyboard-nightly/org.kde.plasma.keyboard.flatpakref
See also: https://userbase.kde.org/Tutorials/Flatpak#Nightly_KDE_apps
Development
Recommended methods for development are to either use KDE Linux (as your OS or in a VM), or to build the Flatpak version of plasma-keyboard.
KDE Linux (recommended)
Follow the instructions to set up a development environment for KDE software.
Build plasma-keyboard once to clone the source locally:
kde-builder plasma-keyboard
After making changes to the code the workflow is: rebuild, refresh sysext, and restart plasma-keyboard. This script can be used to do that:
#!/usr/bin/env bash
set -e
# Rebuild plasma-keyboard and refresh the sysext
kde-builder --no-src plasma-keyboard && systemctl --user daemon-reload && sudo systemd-sysext refresh --always-refresh=yes && systemctl restart --user plasma-plasmashell.service
# Disable plasma-keyboard
kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod ''
# Enable plasma-keyboard with the newly built changes
kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod '/usr/share/applications/org.kde.plasma.keyboard.desktop'
Flatpak
It is also possible to build plasma-keyboard as a Flatpak. This is the recommended method for development on distributions other than KDE Linux, as we don't want to install the development version of plasma-keyboard on a traditional Linux distribution (which may break the system).
Clone the repository and make changes to the code, then build and install the development version of the Flatpak with your changes by running the following from the repository root (or save as a script and run it):
#!/usr/bin/env bash
# Build and install the flatpak
flatpak-builder --user --install --force-clean build-flatpak .flatpak-manifest.json
# Disable plasma-keyboard if it is already running
killall plasma-keyboard; kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod ''
# Enable plasma-keyboard with the newly built changes
kwriteconfig6 --notify --file kwinrc --group Wayland --key InputMethod '$HOME/.local/share/flatpak/exports/share/applications/org.kde.plasma.keyboard.desktop'
Building from source manually
mkdir build && cd build
cmake ..
make && make install
Troubleshooting
Join the KDE Matrix chat so we can help you get started with development! We have a room specifically for input handling: #kde-input:kde.org
Layouts
The keyboard layouts are located in the src/layouts folder.
They are forked from Qt's layouts, with modifications that we want for Plasma. Please view the official Qt documentation for a guide on how to create and modify keyboard layouts.
To use Qt's built-in keyboard layouts rather than the ones we supply in plasma-keyboard, set PLASMA_KEYBOARD_USE_QT_LAYOUTS=1 when starting KWin (or the login session).
Troubleshooting
KWin by default only shows the keyboard when a text field is interacted with by touch. Set KWIN_IM_SHOW_ALWAYS=1 when starting KWin (or the login session) in order to force the keyboard to always pop up.