Willow Barraco 9cc8931b46 Fix the initial output geometry guessing
wvkbd adapt its height, and layout depending on if the screen
is in landscape mode or not.

The only realiable way to know which outputs our surface is
rendered on is the wl_surface->enter(wl_output) event. But we receive
this event very late in the flow. After the first frame rendering, and
commit to the surface.

There already is some code to guess the best initial tentative, on the
most simple situations, to try to avoid an immediate re-creation of the
Wayland objects, buffer, and re-rendering of the layout.

But two issues was present:

First, we need a second roundtrip of the events, after the global
handle. This make the compositor to send the wl_outputs events earlier,
giving their geometry before our first show().

Then, the code that loop on them, if we don't already know the
current_output, was wrong. Because we changed the default state to
landscaped a while ago.

We also change how this code behave, we use the very first wl_output we
know about. Every behaviors are somehow wrong at this point, this one is
the simplest.

Now when starting wvkbd with only one screen, we don't need a second
loop anymore.

On situation where multiple screens are present, it will eventually need
a second one.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2024-11-05 10:14:12 +01:00
2023-08-31 11:59:17 +02:00
2023-09-08 21:17:31 +02:00
2023-09-08 23:26:42 +02:00
2023-09-08 23:14:40 +02:00
2022-10-29 17:22:35 +02:00
2024-09-01 18:23:07 +02:00
2020-09-13 04:44:15 -07:00
2020-09-13 04:44:15 -07:00
2024-10-26 20:49:11 +02:00
2024-04-14 18:18:34 +02:00
2024-04-14 18:18:34 +02:00
2020-09-13 04:44:15 -07:00
2020-09-13 04:44:15 -07:00
2023-09-08 23:14:40 +02:00

wvkbd - On-screen keyboard for wlroots that sucks less

This project aims to deliver a minimal but practically usable implementation of a wlroots on-screen keyboard in legible C. This will only be a keyboard, not a feedback buzzer, led blinker, or anything that requires more than what's needed to input text quickly. The end product should be a static codebase that can be patched to add new features.

Features

  • Typing, modifier locking, layout switching
  • Positive visual feedback on key presses
  • Custom layouts and underlying keymaps
  • On-the-fly layout and keymap switching
  • Custom color schemes
  • Proper font drawing
  • Intuitive layouts
  • International layouts (cyrillic, arabic, persian, greek, georgian)
  • Support for 'Copy' keys which are not on the keymap
  • Emoji support
  • Compose key for character variants (e.g. diacritics)
  • Show/hide keyboard on signals (SIGUSR1 = hide, SIGUSR2 = show, SIGRTMIN = toggle)
  • Automatic portrait/landscape detection and subsequent layout switching

There are some areas that still need work:

  • Make sure the virtual input method in wayland is working as best as it can
  • Support for input method protocol in wayland, ability to respond to text fields

Install

You'll need the following developer packages

  • cairo
  • pango
  • wayland-client
  • xkbcommon

Make any customizations you would like in config.def.h and run make

The default set of layouts is called mobintl (mobile international), which groups various layouts aimed at mobile devices and also attempts to accommodate various international users. The resulting binary is called wvkbd-mobintl.

You can, however, define your own layouts by copying and modifying layout.mobintl.h and keymap.mobintl.h (replace mobintl for something like yourlayout). Then make your layout set using make LAYOUT=yourlayout, and the resulting binary will be wvkbd-yourlayout

Usage

Run wvkbd-mobintl (or the binary for your custom layout set).

You can switch between the layouts/layers of the keyboard by pressing the ⌨ key (little keyboard) the bottom-left (press shift to iterate back instead of forward). If you only want a subset of the available layers, you can define which you want and in what order you want to cycle through them using the -l parameter (or --landscape-layers for landscape mode). This takes takes a ordered comma separated list of layout names that are defined in your layout set.

The keyboard can be hidden by sending it a SIGUSR1 signal, shown again by sending it SIGUSR2 or toggled by sending it SIGRTMIN. This saves some start up time and may be appropriate in some low-resource environments.

Wvkbd has an output mode -o that will echo its output to standard output. This facility can be used if users want audio/haptic feedback, a feature explicitly out of scope for wvkbd. To achieve this, simply pipe wvkbd's output through the external tool clickclack:

$ wvkbd-mobintl -l simple,special,emoji -o | clickclack -V -f keypress.wav

Another output mode, -O will let the keyboard output keys which are swiped over. It can be used by an external program, such as swipeGuess to get swipe-typing support.

$ wvkbd-mobintl -O | swipeGuess.sh words.txt | completelyTypeWord.sh

Compose button

The default mobile international layout features a Compose button (Cmp) which, when combined with another key, opens up a layout that offers variants for that key. This is similar to functionality that other keyboards implemented using a long press (wvkbd has no such notion, holding a key will repeat it like on a physical keyboard).

For example, press Cmp + a to access variants with diacritics like á,à,â,ä, etc..

Most layouts also feature the following that are less obvious:

  • Press Cmp + . to access more punctuation
  • Press Cmp + - or , to access 'mathematical' symbols (+,-,=,etc)
  • Press Cmp + ' or 0 or 9 to access more brackets and quotes
  • Press Cmp + q to access emojis

Last, but not least, pressing Cmp + space or Cmp + ⌨ or Cmp + Abc opens up an index that allows you to immediately jump to any layout by name, even layouts not explicitly added to your layers on startup.

Contribute

Any contributions are welcome, there are two ways to contribute, the first one is preferred:

  1. Sourcehut - Submit your patches using git mail to ~mil/sxmo-devel@lists.sr.ht, follow these contribution guidelines. Questions can also be asked on Sxmo's mailing lists.
  2. Github - Submit a pull request or open an issue (legacy method)

This project was started by John Sullivan and is currently being maintained by the Sxmo project, whose maintainers will ensure both git remotes are kept in sync at all times.

For code contributions, please run make format (requires clang-format) before sending a patch (opening a PR) and include as much relevant detail as possible.

  • clickclack - Audio/haptic feedback (standalone)
  • swipeGuess - Word-completion for swipe-typing
  • Sxmo - A hackable mobile interface environment for Linux phones that adopted wvkbd as its keyboard
  • svkbd - A similar project as wvkbd but for X11 rather than Wayland
  • squeekboard - The virtual keyboard developed for the Librem5 (used by Phosh)
Description
On-screen keyboard for wlroots
Readme GPL-3.0 2.2 MiB
Languages
C 99.7%
Makefile 0.3%