Compare commits
	
		
			52 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 523caa99c5 | |||
| 20c44476a3 | |||
| e6c136918c | |||
| 24adba44be | |||
| 5e43a31051 | |||
| 40850267d4 | |||
| c686cf7e81 | |||
| ec5570a547 | |||
| 72bd265065 | |||
| 4357052fe7 | |||
| 2959d27ea3 | |||
| 88d3a45083 | |||
| edc330d683 | |||
| 44e06bc0dc | |||
| 8e2e8b0f5f | |||
| 4b825c26a6 | |||
| 94bfa92c12 | |||
| 50fb124b26 | |||
| 7aa004ceff | |||
| fea4ea7392 | |||
| 60056dcf26 | |||
| 5580853f31 | |||
| d93e9c2b11 | |||
| 4ccf11f4fd | |||
| 6c5df02921 | |||
| b137e2e3a0 | |||
| 820a8b6ca1 | |||
| 8bdfb69dc1 | |||
| 1e6bcef055 | |||
| 07faf906d8 | |||
| 53f30324f0 | |||
| 3e212ddab4 | |||
| 966990ad65 | |||
| a8b81172fc | |||
| 97f51591b3 | |||
| 6756fb423a | |||
| eb7673d2c2 | |||
| 24b6a04903 | |||
| b197cd839e | |||
| 857a916402 | |||
| ca68fc2040 | |||
| bd661bd4f4 | |||
| 4228192bda | |||
| 0f7ab99da3 | |||
| e15d317488 | |||
| 93e9ce0dd7 | |||
| 9d63b505ec | |||
| 306c11f1fd | |||
| c26feed8b2 | |||
| 2f4a652f53 | |||
| e5796d0d7b | |||
| 9512fd8436 | 
@ -36,7 +36,7 @@ build_meson:
 | 
			
		||||
    expire_in: 3h
 | 
			
		||||
  script:
 | 
			
		||||
    - apt-get -y build-dep .
 | 
			
		||||
    - meson . _build/ -Ddepdatadir=/usr/share
 | 
			
		||||
    - meson . _build/ -Ddepdatadir=/usr/share --werror
 | 
			
		||||
    - ninja -C _build install
 | 
			
		||||
 | 
			
		||||
build_deb:
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ path = "@path@/examples/test_layout.rs"
 | 
			
		||||
[features]
 | 
			
		||||
gio_v0_5 = []
 | 
			
		||||
gtk_v0_5 = []
 | 
			
		||||
rustc_less_1_36 = []
 | 
			
		||||
 | 
			
		||||
# Dependencies which don't change based on build flags
 | 
			
		||||
[dependencies.cairo-sys-rs]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										29
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								README.md
									
									
									
									
									
								
							@ -30,29 +30,42 @@ Building
 | 
			
		||||
 | 
			
		||||
### Dependencies
 | 
			
		||||
 | 
			
		||||
See `.gitlab-ci.yml`.
 | 
			
		||||
See `.gitlab-ci.yml` or run `apt-get build-dep .`
 | 
			
		||||
 | 
			
		||||
### Build from git repo
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```bash
 | 
			
		||||
$ git clone https://source.puri.sm/Librem5/squeekboard.git
 | 
			
		||||
$ cd squeekboard
 | 
			
		||||
$ mkdir ../build
 | 
			
		||||
$ meson ../build/
 | 
			
		||||
$ cd ../build
 | 
			
		||||
$ ninja test
 | 
			
		||||
$ ninja install
 | 
			
		||||
$ mkdir _build
 | 
			
		||||
$ meson _build/
 | 
			
		||||
$ cd _build
 | 
			
		||||
$ ninja
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
To run tests use `ninja test`. To install squeekboard run `ninja install`.
 | 
			
		||||
 | 
			
		||||
Running
 | 
			
		||||
-------
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```bash
 | 
			
		||||
$ phoc # if no compatible Wayland compositor is running yet
 | 
			
		||||
$ cd ../build/
 | 
			
		||||
$ src/squeekboard
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Squeekboard honors the gnome "screen-keyboard-enabled" setting. Either enable this through gnome-settings under accessibility or run:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
$ gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
To make the keyboard show you can use either an application that does so automatically, like a text editor or `python3 ./tests/entry.py`, or you can manually trigger it with:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Developing
 | 
			
		||||
----------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										89
									
								
								data/keyboards/be.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								data/keyboards/be.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,89 @@
 | 
			
		||||
---
 | 
			
		||||
outlines:
 | 
			
		||||
    default:   { width: 35.33, height: 52 }
 | 
			
		||||
    altline:   { width: 52.67, height: 52 }
 | 
			
		||||
    wide:      { width: 59,    height: 52 }
 | 
			
		||||
    spaceline: { width: 140,   height: 52 }
 | 
			
		||||
    special:   { width: 44,    height: 52 }
 | 
			
		||||
 | 
			
		||||
views:
 | 
			
		||||
    base:
 | 
			
		||||
        - "a z e r t y u i o p"
 | 
			
		||||
        - "q s d f g h j k l m"
 | 
			
		||||
        - "Shift_L   w x c v b n .   BackSpace"
 | 
			
		||||
        - "show_numbers preferences         space        show_eschars Return"
 | 
			
		||||
    upper:
 | 
			
		||||
        - "A Z E R T Y U I O P"
 | 
			
		||||
        - "Q S D F G H J K L M"
 | 
			
		||||
        - "Shift_L   W X C V B N ,  BackSpace"
 | 
			
		||||
        - "show_numbers preferences         space        show_eschars Return"
 | 
			
		||||
    numbers:
 | 
			
		||||
        - "1 2 3 4 5 6 7 8 9 0"
 | 
			
		||||
        - "@ # € % & - _ + ( )"
 | 
			
		||||
        - "show_symbols   , \" ' colon ; ! ?  BackSpace"
 | 
			
		||||
        - "show_letters preferences         space        show_eschars Return"
 | 
			
		||||
    symbols:
 | 
			
		||||
        - "~ ` | · √ π τ ÷ × ¶"
 | 
			
		||||
        - "© ® £ $ ¥ ^ ° * { }"
 | 
			
		||||
        - "show_numbers_from_symbols   \\ / < > = [ ]  BackSpace"
 | 
			
		||||
        - "show_letters preferences         space        show_eschars Return"
 | 
			
		||||
    eschars:
 | 
			
		||||
        - "à â ç é è ê î ô ù û"
 | 
			
		||||
        - "À Â Ç É È Ê Î Ô Ù Û"
 | 
			
		||||
        - "show_numbers_from_symbols  æ œ ä ë ï ö ü  BackSpace"
 | 
			
		||||
        - "show_letters preferences         space        show_eschars Return"
 | 
			
		||||
 | 
			
		||||
buttons:
 | 
			
		||||
    Shift_L:
 | 
			
		||||
        action:
 | 
			
		||||
            locking:
 | 
			
		||||
                lock_view: "upper"
 | 
			
		||||
                unlock_view: "base"
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        icon: "key-shift"
 | 
			
		||||
    BackSpace:
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        icon: "edit-clear-symbolic"
 | 
			
		||||
        action: erase
 | 
			
		||||
    preferences:
 | 
			
		||||
        action: "show_prefs"
 | 
			
		||||
        outline: "special"
 | 
			
		||||
        icon: "keyboard-mode-symbolic"
 | 
			
		||||
    show_numbers:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "numbers"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "123"
 | 
			
		||||
    show_numbers_from_symbols:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "numbers"
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        label: "123"
 | 
			
		||||
    show_letters:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "base"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "abc"
 | 
			
		||||
    show_symbols:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "symbols"
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        label: "*/="
 | 
			
		||||
    show_eschars:
 | 
			
		||||
        action:
 | 
			
		||||
            locking:
 | 
			
		||||
                lock_view: "eschars"
 | 
			
		||||
                unlock_view: "base"
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        label: "âÂ"
 | 
			
		||||
    space:
 | 
			
		||||
        outline: "spaceline"
 | 
			
		||||
        text: " "
 | 
			
		||||
    Return:
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        icon: "key-enter"
 | 
			
		||||
        keysym: "Return"
 | 
			
		||||
    colon:
 | 
			
		||||
        text: ":"
 | 
			
		||||
    "\"":
 | 
			
		||||
        keysym: "quotedbl"
 | 
			
		||||
							
								
								
									
										94
									
								
								data/keyboards/ua.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								data/keyboards/ua.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,94 @@
 | 
			
		||||
---
 | 
			
		||||
outlines:
 | 
			
		||||
    default: { width: 32, height: 52 }
 | 
			
		||||
    altline: { width: 32, height: 52 }
 | 
			
		||||
    wide: { width: 57, height: 52 }
 | 
			
		||||
    narrow: { width: 26, height: 52 }
 | 
			
		||||
    spaceline: { width: 107, height: 52 }
 | 
			
		||||
    fill: { width: 159, height: 52 }
 | 
			
		||||
    special: { width: 42, height: 52 }
 | 
			
		||||
 | 
			
		||||
views:
 | 
			
		||||
    base:
 | 
			
		||||
        - "й ц у к е н г ш щ з х"
 | 
			
		||||
        - "ф і в а п р о л д ж є"
 | 
			
		||||
        - "Shift_L  я ч с м и т ь б ю  BackSpace"
 | 
			
		||||
        - "show_numbers preferences    ґ  space  ї  period Return"
 | 
			
		||||
    upper:
 | 
			
		||||
        - "Й Ц У К Е Н Г Ш Щ З Х"
 | 
			
		||||
        - "Ф І В А П Р О Л Д Ж Є"
 | 
			
		||||
        - "Shift_L   Я Ч С М И Т Ь Б Ю  BackSpace"
 | 
			
		||||
        - "show_numbers preferences    Ґ  space  Ї  comma Return"
 | 
			
		||||
    numbers:
 | 
			
		||||
        - "1 2 3 4 5 6 7 8 9 0"
 | 
			
		||||
        - "@ # $ % & - _ + ( )"
 | 
			
		||||
        - "show_symbols   , \" ' colon ; ! ?  BackSpace"
 | 
			
		||||
        - "show_letters preferences         space_fill   period Return"
 | 
			
		||||
    symbols:
 | 
			
		||||
        - "~ ` | · √ π τ ÷ × ¶"
 | 
			
		||||
        - "© ® £ € ¥ ^ ° * { }"
 | 
			
		||||
        - "show_numbers_from_symbols   \\ / < > = [ ]  BackSpace"
 | 
			
		||||
        - "show_letters preferences         space_fill   period Return"
 | 
			
		||||
 | 
			
		||||
buttons:
 | 
			
		||||
    Shift_L:
 | 
			
		||||
        action:
 | 
			
		||||
            locking:
 | 
			
		||||
                lock_view: "upper"
 | 
			
		||||
                unlock_view: "base"
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        icon: "key-shift"
 | 
			
		||||
    BackSpace:
 | 
			
		||||
        outline: "altline"
 | 
			
		||||
        icon: "edit-clear-symbolic"
 | 
			
		||||
        action: erase
 | 
			
		||||
    preferences:
 | 
			
		||||
        action: show_prefs
 | 
			
		||||
        outline: "special"
 | 
			
		||||
        icon: "keyboard-mode-symbolic"
 | 
			
		||||
    show_numbers:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "numbers"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "123"
 | 
			
		||||
    show_numbers_from_symbols:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "numbers"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "123"
 | 
			
		||||
    show_letters:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "base"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "АБВ"
 | 
			
		||||
    show_symbols:
 | 
			
		||||
        action:
 | 
			
		||||
            set_view: "symbols"
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        label: "*/="
 | 
			
		||||
    period:
 | 
			
		||||
        outline: "special"
 | 
			
		||||
        text: "."
 | 
			
		||||
    comma:
 | 
			
		||||
        outline: "special"
 | 
			
		||||
        text: ","
 | 
			
		||||
    space:
 | 
			
		||||
        outline: "spaceline"
 | 
			
		||||
        text: " "
 | 
			
		||||
    space_fill:
 | 
			
		||||
        outline: "fill"
 | 
			
		||||
        text: " "
 | 
			
		||||
    Return:
 | 
			
		||||
        outline: "wide"
 | 
			
		||||
        icon: "key-enter"
 | 
			
		||||
        keysym: "Return"
 | 
			
		||||
    colon:
 | 
			
		||||
        text: ":"
 | 
			
		||||
    ґ:
 | 
			
		||||
        outline: "narrow"
 | 
			
		||||
    Ґ:
 | 
			
		||||
        outline: "narrow"
 | 
			
		||||
    ї:
 | 
			
		||||
        outline: "narrow"
 | 
			
		||||
    Ї:
 | 
			
		||||
        outline: "narrow"
 | 
			
		||||
@ -13,16 +13,16 @@ The overarching principle of *squeekboard* is to empower users.
 | 
			
		||||
Software is primarily meant to solve problems of its users. Often in the quest to make software better, a hard distinction is made between the developer, who becomes the creator, and the user, who takes the role of the consumer, without direct influence on the software they use.
 | 
			
		||||
This project aims to give users the power to make the software work for them by blurring the lines between users and developers.
 | 
			
		||||
 | 
			
		||||
Nonwithstanding its current state, *squeekboard* must be structured in a way that provides users a gradual way to gain more experience and power to adjust it. It must be easy, in order of importance:
 | 
			
		||||
Notwithstanding its current state, *squeekboard* must be structured in a way that provides users a gradual way to gain more experience and power to adjust it. It must be easy, in order of importance:
 | 
			
		||||
 | 
			
		||||
- to use the software,
 | 
			
		||||
- to modify its resources,
 | 
			
		||||
- to change its behaviour,
 | 
			
		||||
- to change its behavior,
 | 
			
		||||
- to contribute upstream.
 | 
			
		||||
 | 
			
		||||
To give an idea of what it means in practice, those are some examples of what has been important for *squeekboard* so far:
 | 
			
		||||
 | 
			
		||||
- being quick and useable,
 | 
			
		||||
- being quick and usable,
 | 
			
		||||
- allowing local overrides of resources and config,
 | 
			
		||||
- storing resources and config as editable, standard files,
 | 
			
		||||
- having complete, up to date documentation of interfaces,
 | 
			
		||||
@ -33,7 +33,7 @@ To give an idea of what it means in practice, those are some examples of what ha
 | 
			
		||||
- having code that is [simple and obvious](https://www.python.org/dev/peps/pep-0020/),
 | 
			
		||||
- having an easy process of testing and accepting contributions.
 | 
			
		||||
 | 
			
		||||
You may notice that they are ordered roughly from "user-focused" to "maintainer-focused". While good properties are desired, sometimes they conflict, and maintainers should give additional weight to those benefitting the user compared to those benefitting regular contributors.
 | 
			
		||||
You may notice that they are ordered roughly from "user-focused" to "maintainer-focused". While good properties are desired, sometimes they conflict, and maintainers should give additional weight to those benefiting the user compared to those benefiting regular contributors.
 | 
			
		||||
 | 
			
		||||
Sending patches
 | 
			
		||||
---------------
 | 
			
		||||
@ -43,7 +43,7 @@ By submitting a change to this project, you agree to license it under the [GPL l
 | 
			
		||||
Development environment
 | 
			
		||||
-----------------------
 | 
			
		||||
 | 
			
		||||
*Squeekboard* is regularly built and tested on [the develpment environment](https://developer.puri.sm/Librem5/Development_Environment.html).
 | 
			
		||||
*Squeekboard* is regularly built and tested on [the development environment](https://developer.puri.sm/Librem5/Development_Environment.html).
 | 
			
		||||
 | 
			
		||||
Recent Fedora releases are likely to be tested as well.
 | 
			
		||||
 | 
			
		||||
@ -162,7 +162,7 @@ Maintenance
 | 
			
		||||
 | 
			
		||||
Squeekboard uses Rust & Cargo for some of its dependencies.
 | 
			
		||||
 | 
			
		||||
Use the `cargo.sh` script for maintaining the Cargo part of the build. The script takes the usual Cargo commands, after the first 2 positionsl arguments: source directory, and output artifact. So, `cargo test` becomes:
 | 
			
		||||
Use the `cargo.sh` script for maintaining the Cargo part of the build. The script takes the usual Cargo commands, after the first 2 positional arguments: source directory, and output artifact. So, `cargo test` becomes:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
cd build_dir
 | 
			
		||||
 | 
			
		||||
@ -38,8 +38,6 @@ struct _EekElementClass
 | 
			
		||||
    GObjectClass parent_class;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
GType        eek_element_get_type              (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
void         eek_element_set_name              (EekElement  *element,
 | 
			
		||||
                                                const gchar *name);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -126,8 +126,8 @@ eek_gtk_keyboard_real_size_allocate (GtkWidget     *self,
 | 
			
		||||
                (uint32_t)(allocation->height - allocation->y) * scale);
 | 
			
		||||
    if (priv->layout->arrangement != new_type) {
 | 
			
		||||
        priv->layout->arrangement = new_type;
 | 
			
		||||
 | 
			
		||||
        eekboard_context_service_use_layout(priv->eekboard_context, priv->layout);
 | 
			
		||||
        uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
        eekboard_context_service_use_layout(priv->eekboard_context, priv->layout, time);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (priv->renderer)
 | 
			
		||||
@ -360,6 +360,10 @@ eek_gtk_keyboard_init (EekGtkKeyboard *self)
 | 
			
		||||
        priv->event = lfb_event_new ("button-pressed");
 | 
			
		||||
    else
 | 
			
		||||
        g_warning ("Failed to init libfeedback: %s", err->message);
 | 
			
		||||
 | 
			
		||||
    GtkIconTheme *theme = gtk_icon_theme_get_default ();
 | 
			
		||||
 | 
			
		||||
    gtk_icon_theme_add_resource_path (theme, "/sm/puri/squeekboard/icons");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,6 @@ struct _EekGtkKeyboardClass
 | 
			
		||||
    gpointer pdummy[24];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
GType      eek_gtk_keyboard_get_type  (void) G_GNUC_CONST;
 | 
			
		||||
GtkWidget *eek_gtk_keyboard_new       (EekboardContextService *eekservice, struct submission *submission, struct squeek_layout_state *layout);
 | 
			
		||||
void       eek_gtk_keyboard_emit_feedback (EekGtkKeyboard *self);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#define _XOPEN_SOURCE 500
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/mman.h>
 | 
			
		||||
@ -30,30 +31,19 @@
 | 
			
		||||
 | 
			
		||||
#include "eek-keyboard.h"
 | 
			
		||||
 | 
			
		||||
void level_keyboard_free(LevelKeyboard *self) {
 | 
			
		||||
    xkb_keymap_unref(self->keymap);
 | 
			
		||||
    close(self->keymap_fd);
 | 
			
		||||
    squeek_layout_free(self->layout);
 | 
			
		||||
    g_free(self);
 | 
			
		||||
/// External linkage for Rust.
 | 
			
		||||
/// Don't call multiple times on the same copy, just in Drop.
 | 
			
		||||
void eek_key_map_deinit(struct KeyMap *self) {
 | 
			
		||||
    close(self->fd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
LevelKeyboard*
 | 
			
		||||
level_keyboard_new (struct squeek_layout *layout)
 | 
			
		||||
{
 | 
			
		||||
    LevelKeyboard *keyboard = g_new0(LevelKeyboard, 1);
 | 
			
		||||
 | 
			
		||||
    if (!keyboard) {
 | 
			
		||||
        g_error("Failed to create a keyboard");
 | 
			
		||||
    }
 | 
			
		||||
    keyboard->layout = layout;
 | 
			
		||||
 | 
			
		||||
/// External linkage for Rust.
 | 
			
		||||
struct KeyMap eek_key_map_from_str(char *keymap_str) {
 | 
			
		||||
    struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
 | 
			
		||||
    if (!context) {
 | 
			
		||||
        g_error("No context created");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const gchar *keymap_str = squeek_layout_get_keymap(keyboard->layout);
 | 
			
		||||
 | 
			
		||||
    struct xkb_keymap *keymap = xkb_keymap_new_from_string(context, keymap_str,
 | 
			
		||||
        XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
 | 
			
		||||
 | 
			
		||||
@ -61,14 +51,14 @@ level_keyboard_new (struct squeek_layout *layout)
 | 
			
		||||
        g_error("Bad keymap:\n%s", keymap_str);
 | 
			
		||||
 | 
			
		||||
    xkb_context_unref(context);
 | 
			
		||||
    keyboard->keymap = keymap;
 | 
			
		||||
 | 
			
		||||
    keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
 | 
			
		||||
    keyboard->keymap_len = strlen(keymap_str) + 1;
 | 
			
		||||
    char *xkb_keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
 | 
			
		||||
    size_t keymap_len = strlen(xkb_keymap_str) + 1;
 | 
			
		||||
 | 
			
		||||
    g_autofree char *path = strdup("/eek_keymap-XXXXXX");
 | 
			
		||||
    char *r = &path[strlen(path) - 6];
 | 
			
		||||
    getrandom(r, 6, GRND_NONBLOCK);
 | 
			
		||||
    if (getrandom(r, 6, GRND_NONBLOCK) < 0)
 | 
			
		||||
        g_error("Failed to get random numbers: %s", strerror(errno));
 | 
			
		||||
    for (unsigned i = 0; i < 6; i++) {
 | 
			
		||||
        r[i] = (r[i] & 0b1111111) | 0b1000000; // A-z
 | 
			
		||||
        r[i] = r[i] > 'z' ? '?' : r[i]; // The randomizer doesn't need to be good...
 | 
			
		||||
@ -77,17 +67,39 @@ level_keyboard_new (struct squeek_layout *layout)
 | 
			
		||||
    if (keymap_fd < 0) {
 | 
			
		||||
        g_error("Failed to set up keymap fd");
 | 
			
		||||
    }
 | 
			
		||||
    keyboard->keymap_fd = keymap_fd;
 | 
			
		||||
 | 
			
		||||
    shm_unlink(path);
 | 
			
		||||
    if (ftruncate(keymap_fd, (off_t)keyboard->keymap_len)) {
 | 
			
		||||
    if (ftruncate(keymap_fd, (off_t)keymap_len)) {
 | 
			
		||||
        g_error("Failed to increase keymap fd size");
 | 
			
		||||
    }
 | 
			
		||||
    char *ptr = mmap(NULL, keyboard->keymap_len, PROT_WRITE, MAP_SHARED,
 | 
			
		||||
    char *ptr = mmap(NULL, keymap_len, PROT_WRITE, MAP_SHARED,
 | 
			
		||||
        keymap_fd, 0);
 | 
			
		||||
    if ((void*)ptr == (void*)-1) {
 | 
			
		||||
        g_error("Failed to set up mmap");
 | 
			
		||||
    }
 | 
			
		||||
    strncpy(ptr, keymap_str, keyboard->keymap_len);
 | 
			
		||||
    munmap(ptr, keyboard->keymap_len);
 | 
			
		||||
    strncpy(ptr, xkb_keymap_str, keymap_len);
 | 
			
		||||
    munmap(ptr, keymap_len);
 | 
			
		||||
    free(xkb_keymap_str);
 | 
			
		||||
    xkb_keymap_unref(keymap);
 | 
			
		||||
    struct KeyMap km = {
 | 
			
		||||
        .fd = keymap_fd,
 | 
			
		||||
        .fd_len = keymap_len,
 | 
			
		||||
    };
 | 
			
		||||
    return km;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void level_keyboard_free(LevelKeyboard *self) {
 | 
			
		||||
    squeek_layout_free(self->layout);
 | 
			
		||||
    g_free(self);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
LevelKeyboard*
 | 
			
		||||
level_keyboard_new (struct squeek_layout *layout)
 | 
			
		||||
{
 | 
			
		||||
    LevelKeyboard *keyboard = g_new0(LevelKeyboard, 1);
 | 
			
		||||
    if (!keyboard) {
 | 
			
		||||
        g_error("Failed to create a keyboard");
 | 
			
		||||
    }
 | 
			
		||||
    keyboard->layout = layout;
 | 
			
		||||
    return keyboard;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -35,16 +35,18 @@ G_BEGIN_DECLS
 | 
			
		||||
/// Keyboard state holder
 | 
			
		||||
struct _LevelKeyboard {
 | 
			
		||||
    struct squeek_layout *layout; // owned
 | 
			
		||||
    struct xkb_keymap *keymap; // owned
 | 
			
		||||
    int keymap_fd; // keymap formatted as XKB string
 | 
			
		||||
    size_t keymap_len; // length of the data inside keymap_fd
 | 
			
		||||
 | 
			
		||||
// FIXME: This no longer needs to exist, keymap was folded into layout.
 | 
			
		||||
    guint id; // as a key to layout choices
 | 
			
		||||
};
 | 
			
		||||
typedef struct _LevelKeyboard LevelKeyboard;
 | 
			
		||||
 | 
			
		||||
gchar *             eek_keyboard_get_keymap
 | 
			
		||||
                                     (LevelKeyboard *keyboard);
 | 
			
		||||
/// Keymap container for Rust interoperability.
 | 
			
		||||
struct KeyMap {
 | 
			
		||||
    uint32_t fd; // keymap formatted as XKB string
 | 
			
		||||
    size_t fd_len; // length of the data inside keymap_fd
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
gchar *eek_keyboard_get_keymap(LevelKeyboard *keyboard);
 | 
			
		||||
 | 
			
		||||
LevelKeyboard*
 | 
			
		||||
level_keyboard_new (struct squeek_layout *layout);
 | 
			
		||||
 | 
			
		||||
@ -241,7 +241,7 @@ static GType new_type(char *name) {
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GType view_type() {
 | 
			
		||||
static GType view_type(void) {
 | 
			
		||||
    static GType type = 0;
 | 
			
		||||
    if (!type) {
 | 
			
		||||
        type = new_type("sq_view");
 | 
			
		||||
@ -249,7 +249,7 @@ static GType view_type() {
 | 
			
		||||
    return type;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GType button_type() {
 | 
			
		||||
static GType button_type(void) {
 | 
			
		||||
    static GType type = 0;
 | 
			
		||||
    if (!type) {
 | 
			
		||||
        type = new_type("sq_button");
 | 
			
		||||
@ -265,10 +265,6 @@ renderer_init (EekRenderer *self)
 | 
			
		||||
    self->allocation_height = 0.0;
 | 
			
		||||
    self->scale_factor = 1;
 | 
			
		||||
 | 
			
		||||
    GtkIconTheme *theme = gtk_icon_theme_get_default ();
 | 
			
		||||
 | 
			
		||||
    gtk_icon_theme_add_resource_path (theme, "/sm/puri/squeekboard/icons");
 | 
			
		||||
 | 
			
		||||
    self->css_provider = squeek_load_style();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -42,10 +42,21 @@ enum {
 | 
			
		||||
 | 
			
		||||
static guint signals[LAST_SIGNAL] = { 0, };
 | 
			
		||||
 | 
			
		||||
#define EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(obj)                       \
 | 
			
		||||
    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServicePrivate))
 | 
			
		||||
/**
 | 
			
		||||
 * EekboardContextService:
 | 
			
		||||
 *
 | 
			
		||||
 * Handles layout state, gsettings, and virtual-keyboard.
 | 
			
		||||
 *
 | 
			
		||||
 * TODO: Restrict to managing keyboard layouts, and maybe button repeats,
 | 
			
		||||
 * and the virtual keyboard protocol.
 | 
			
		||||
 *
 | 
			
		||||
 * The #EekboardContextService structure contains only private data
 | 
			
		||||
 * and should only be accessed using the provided API.
 | 
			
		||||
 */
 | 
			
		||||
struct _EekboardContextService {
 | 
			
		||||
    GObject parent;
 | 
			
		||||
    struct squeek_layout_state *layout; // Unowned
 | 
			
		||||
 | 
			
		||||
struct _EekboardContextServicePrivate {
 | 
			
		||||
    LevelKeyboard *keyboard; // currently used keyboard
 | 
			
		||||
    GSettings *settings; // Owned reference
 | 
			
		||||
 | 
			
		||||
@ -56,7 +67,7 @@ struct _EekboardContextServicePrivate {
 | 
			
		||||
    struct submission *submission; // unowned
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
 | 
			
		||||
G_DEFINE_TYPE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
eekboard_context_service_set_property (GObject      *object,
 | 
			
		||||
@ -82,7 +93,7 @@ eekboard_context_service_get_property (GObject    *object,
 | 
			
		||||
 | 
			
		||||
    switch (prop_id) {
 | 
			
		||||
    case PROP_KEYBOARD:
 | 
			
		||||
        g_value_set_object (value, context->priv->keyboard);
 | 
			
		||||
        g_value_set_object (value, context->keyboard);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 | 
			
		||||
@ -116,7 +127,7 @@ settings_get_layout(GSettings *settings, char **type, char **layout)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *state) {
 | 
			
		||||
eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *state, uint32_t timestamp) {
 | 
			
		||||
    gchar *layout_name = state->overlay_name;
 | 
			
		||||
 | 
			
		||||
    if (layout_name == NULL) {
 | 
			
		||||
@ -143,12 +154,12 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque
 | 
			
		||||
    struct squeek_layout *layout = squeek_load_layout(layout_name, state->arrangement);
 | 
			
		||||
    LevelKeyboard *keyboard = level_keyboard_new(layout);
 | 
			
		||||
    // set as current
 | 
			
		||||
    LevelKeyboard *previous_keyboard = context->priv->keyboard;
 | 
			
		||||
    context->priv->keyboard = keyboard;
 | 
			
		||||
    LevelKeyboard *previous_keyboard = context->keyboard;
 | 
			
		||||
    context->keyboard = keyboard;
 | 
			
		||||
    // Update the keymap if necessary.
 | 
			
		||||
    // TODO: Update submission on change event
 | 
			
		||||
    if (context->priv->submission) {
 | 
			
		||||
        submission_set_keyboard(context->priv->submission, keyboard);
 | 
			
		||||
    if (context->submission) {
 | 
			
		||||
        submission_use_layout(context->submission, keyboard->layout, timestamp);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Update UI
 | 
			
		||||
@ -163,7 +174,7 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque
 | 
			
		||||
static void eekboard_context_service_update_settings_layout(EekboardContextService *context) {
 | 
			
		||||
    g_autofree gchar *keyboard_layout = NULL;
 | 
			
		||||
    g_autofree gchar *keyboard_type = NULL;
 | 
			
		||||
    settings_get_layout(context->priv->settings,
 | 
			
		||||
    settings_get_layout(context->settings,
 | 
			
		||||
                        &keyboard_type, &keyboard_layout);
 | 
			
		||||
 | 
			
		||||
    if (g_strcmp0(context->layout->layout_name, keyboard_layout) != 0 || context->layout->overlay_name) {
 | 
			
		||||
@ -174,7 +185,8 @@ static void eekboard_context_service_update_settings_layout(EekboardContextServi
 | 
			
		||||
            context->layout->layout_name = g_strdup(keyboard_layout);
 | 
			
		||||
        }
 | 
			
		||||
        // This must actually update the UI.
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout);
 | 
			
		||||
        uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout, time);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -216,7 +228,7 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
 | 
			
		||||
        g_signal_new (I_("destroyed"),
 | 
			
		||||
                      G_TYPE_FROM_CLASS(gobject_class),
 | 
			
		||||
                      G_SIGNAL_RUN_LAST,
 | 
			
		||||
                      G_STRUCT_OFFSET(EekboardContextServiceClass, destroyed),
 | 
			
		||||
                      0,
 | 
			
		||||
                      NULL,
 | 
			
		||||
                      NULL,
 | 
			
		||||
                      g_cclosure_marshal_VOID__VOID,
 | 
			
		||||
@ -240,30 +252,30 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
 | 
			
		||||
static void
 | 
			
		||||
eekboard_context_service_init (EekboardContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self);
 | 
			
		||||
    const char *schema_name = "org.gnome.desktop.input-sources";
 | 
			
		||||
    GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
 | 
			
		||||
    if (ssrc) {
 | 
			
		||||
        GSettingsSchema *schema = g_settings_schema_source_lookup(ssrc,
 | 
			
		||||
                                                                  schema_name,
 | 
			
		||||
                                                                  TRUE);
 | 
			
		||||
        if (schema) {
 | 
			
		||||
            // Not referencing the found schema directly,
 | 
			
		||||
            // because it's not clear how...
 | 
			
		||||
            self->priv->settings = g_settings_new (schema_name);
 | 
			
		||||
            gulong conn_id = g_signal_connect(self->priv->settings, "change-event",
 | 
			
		||||
                                              G_CALLBACK(settings_handle_layout_changed),
 | 
			
		||||
                                              self);
 | 
			
		||||
            if (conn_id == 0) {
 | 
			
		||||
                g_warning ("Could not connect to gsettings updates, "
 | 
			
		||||
                           "automatic layout changing unavailable");
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            g_warning("Gsettings schema %s is not installed on the system. "
 | 
			
		||||
                      "Layout switching unavailable", schema_name);
 | 
			
		||||
    g_autoptr(GSettingsSchema) schema = NULL;
 | 
			
		||||
 | 
			
		||||
    if (!ssrc) {
 | 
			
		||||
        g_warning("No gsettings schemas installed. Layout switching unavailable.");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    schema = g_settings_schema_source_lookup(ssrc, schema_name, TRUE);
 | 
			
		||||
    if (schema) {
 | 
			
		||||
        // Not referencing the found schema directly,
 | 
			
		||||
        // because it's not clear how...
 | 
			
		||||
        self->settings = g_settings_new (schema_name);
 | 
			
		||||
        gulong conn_id = g_signal_connect(self->settings, "change-event",
 | 
			
		||||
                                          G_CALLBACK(settings_handle_layout_changed),
 | 
			
		||||
                                          self);
 | 
			
		||||
        if (conn_id == 0) {
 | 
			
		||||
            g_warning ("Could not connect to gsettings updates, "
 | 
			
		||||
                       "automatic layout changing unavailable");
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        g_warning("No gsettings schemas installed. Layout switching unavailable.");
 | 
			
		||||
        g_warning("Gsettings schema %s is not installed on the system. "
 | 
			
		||||
                  "Layout switching unavailable", schema_name);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -290,7 +302,7 @@ eekboard_context_service_destroy (EekboardContextService *context)
 | 
			
		||||
LevelKeyboard *
 | 
			
		||||
eekboard_context_service_get_keyboard (EekboardContextService *context)
 | 
			
		||||
{
 | 
			
		||||
    return context->priv->keyboard;
 | 
			
		||||
    return context->keyboard;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
 | 
			
		||||
@ -299,7 +311,8 @@ void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
 | 
			
		||||
    if (context->layout->hint != hint || context->layout->purpose != purpose) {
 | 
			
		||||
        context->layout->hint = hint;
 | 
			
		||||
        context->layout->purpose = purpose;
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout);
 | 
			
		||||
        uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout, time);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -308,7 +321,8 @@ eekboard_context_service_set_overlay(EekboardContextService *context, const char
 | 
			
		||||
    if (g_strcmp0(context->layout->overlay_name, name)) {
 | 
			
		||||
        g_free(context->layout->overlay_name);
 | 
			
		||||
        context->layout->overlay_name = g_strdup(name);
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout);
 | 
			
		||||
        uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
        eekboard_context_service_use_layout(context, context->layout, time);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -322,17 +336,19 @@ EekboardContextService *eekboard_context_service_new(struct squeek_layout_state
 | 
			
		||||
    EekboardContextService *context = g_object_new (EEKBOARD_TYPE_CONTEXT_SERVICE, NULL);
 | 
			
		||||
    context->layout = state;
 | 
			
		||||
    eekboard_context_service_update_settings_layout(context);
 | 
			
		||||
    eekboard_context_service_use_layout(context, context->layout);
 | 
			
		||||
    uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
    eekboard_context_service_use_layout(context, context->layout, time);
 | 
			
		||||
    return context;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) {
 | 
			
		||||
    context->priv->submission = submission;
 | 
			
		||||
    if (context->priv->submission) {
 | 
			
		||||
        submission_set_keyboard(context->priv->submission, context->priv->keyboard);
 | 
			
		||||
    context->submission = submission;
 | 
			
		||||
    if (context->submission) {
 | 
			
		||||
        uint32_t time = gdk_event_get_time(NULL);
 | 
			
		||||
        submission_use_layout(context->submission, context->keyboard->layout, time);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) {
 | 
			
		||||
    context->priv->ui = ui;
 | 
			
		||||
    context->ui = ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -34,54 +34,9 @@ G_BEGIN_DECLS
 | 
			
		||||
#define EEKBOARD_CONTEXT_SERVICE_INTERFACE "org.fedorahosted.Eekboard.Context"
 | 
			
		||||
 | 
			
		||||
#define EEKBOARD_TYPE_CONTEXT_SERVICE (eekboard_context_service_get_type())
 | 
			
		||||
#define EEKBOARD_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextService))
 | 
			
		||||
#define EEKBOARD_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
 | 
			
		||||
#define EEKBOARD_IS_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE))
 | 
			
		||||
#define EEKBOARD_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEKBOARD_TYPE_CONTEXT_SERVICE))
 | 
			
		||||
#define EEKBOARD_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEKBOARD_TYPE_CONTEXT_SERVICE, EekboardContextServiceClass))
 | 
			
		||||
 | 
			
		||||
G_DECLARE_FINAL_TYPE(EekboardContextService, eekboard_context_service, EEKBOARD, CONTEXT_SERVICE, GObject)
 | 
			
		||||
 | 
			
		||||
typedef struct _EekboardContextServiceClass EekboardContextServiceClass;
 | 
			
		||||
typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * EekboardContextService:
 | 
			
		||||
 *
 | 
			
		||||
 * Handles layout state, gsettings, and virtual-keyboard.
 | 
			
		||||
 *
 | 
			
		||||
 * TODO: Restrict to managing keyboard layouts, and maybe button repeats,
 | 
			
		||||
 * and the virtual keyboard protocol.
 | 
			
		||||
 *
 | 
			
		||||
 * The #EekboardContextService structure contains only private data
 | 
			
		||||
 * and should only be accessed using the provided API.
 | 
			
		||||
 */
 | 
			
		||||
struct _EekboardContextService {
 | 
			
		||||
    GObject parent;
 | 
			
		||||
    EekboardContextServicePrivate *priv;
 | 
			
		||||
    struct squeek_layout_state *layout; // Unowned
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * EekboardContextServiceClass:
 | 
			
		||||
 * @create_keyboard: virtual function for create a keyboard from string
 | 
			
		||||
 * @enabled: class handler for #EekboardContextService::enabled signal
 | 
			
		||||
 * @disabled: class handler for #EekboardContextService::disabled signal
 | 
			
		||||
 */
 | 
			
		||||
struct _EekboardContextServiceClass {
 | 
			
		||||
    /*< private >*/
 | 
			
		||||
    GObjectClass parent_class;
 | 
			
		||||
 | 
			
		||||
    /*< public >*/
 | 
			
		||||
    /* signals */
 | 
			
		||||
    void         (*destroyed)          (EekboardContextService *self);
 | 
			
		||||
 | 
			
		||||
    /*< private >*/
 | 
			
		||||
    /* padding */
 | 
			
		||||
    gpointer pdummy[24];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
GType         eekboard_context_service_get_type
 | 
			
		||||
                                              (void) G_GNUC_CONST;
 | 
			
		||||
EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state);
 | 
			
		||||
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission);
 | 
			
		||||
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui);
 | 
			
		||||
@ -95,6 +50,6 @@ void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
 | 
			
		||||
                                               uint32_t hint,
 | 
			
		||||
                                               uint32_t purpose);
 | 
			
		||||
void
 | 
			
		||||
eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *layout);
 | 
			
		||||
eekboard_context_service_use_layout(EekboardContextService *context, struct squeek_layout_state *layout, uint32_t timestamp);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
#endif  /* EEKBOARD_CONTEXT_SERVICE_H */
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ use std::env;
 | 
			
		||||
 | 
			
		||||
fn main() -> () {
 | 
			
		||||
    check_builtin_layout(
 | 
			
		||||
        env::args().nth(1).expect("No argument given").as_str()
 | 
			
		||||
        env::args().nth(1).expect("No argument given").as_str(),
 | 
			
		||||
        env::args().nth(2).map(|s| s == "allow_missing_return").unwrap_or(false),
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								meson.build
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								meson.build
									
									
									
									
									
								
							@ -19,6 +19,14 @@ add_project_arguments(
 | 
			
		||||
    '-Werror=missing-field-initializers',
 | 
			
		||||
    '-Werror=incompatible-pointer-types',
 | 
			
		||||
    '-Werror=int-conversion',
 | 
			
		||||
    '-Wformat-nonliteral',
 | 
			
		||||
    '-Wformat-security',
 | 
			
		||||
    '-Winit-self',
 | 
			
		||||
    '-Wmaybe-uninitialized',
 | 
			
		||||
    '-Wold-style-definition',
 | 
			
		||||
    '-Wredundant-decls',
 | 
			
		||||
    '-Wstrict-prototypes',
 | 
			
		||||
    '-Wunused-function',
 | 
			
		||||
  ],
 | 
			
		||||
  language: 'c'
 | 
			
		||||
)
 | 
			
		||||
@ -75,7 +83,7 @@ cargo_toml_base = configure_file(
 | 
			
		||||
cargo_deps = files('Cargo.deps')
 | 
			
		||||
 | 
			
		||||
if get_option('legacy') == true
 | 
			
		||||
    cargo_build_flags += ['--features', 'gtk_v0_5,gio_v0_5']
 | 
			
		||||
    cargo_build_flags += ['--features', 'gtk_v0_5,gio_v0_5,rustc_less_1_36']
 | 
			
		||||
    cargo_deps = files('Cargo.deps.legacy')
 | 
			
		||||
endif
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										158
									
								
								src/data.rs
									
									
									
									
									
								
							
							
						
						
									
										158
									
								
								src/data.rs
									
									
									
									
									
								
							@ -18,7 +18,7 @@ use xkbcommon::xkb;
 | 
			
		||||
use ::action;
 | 
			
		||||
use ::keyboard::{
 | 
			
		||||
    KeyState, PressType,
 | 
			
		||||
    generate_keymap, generate_keycodes, FormattingError
 | 
			
		||||
    generate_keymaps, generate_keycodes, KeyCode, FormattingError
 | 
			
		||||
};
 | 
			
		||||
use ::layout;
 | 
			
		||||
use ::layout::ArrangementKind;
 | 
			
		||||
@ -382,56 +382,45 @@ impl Layout {
 | 
			
		||||
                )
 | 
			
		||||
            )}).collect();
 | 
			
		||||
 | 
			
		||||
        let keymap: HashMap<String, u32> = generate_keycodes(
 | 
			
		||||
            button_actions.iter()
 | 
			
		||||
                .filter_map(|(_name, action)| {
 | 
			
		||||
                    match action {
 | 
			
		||||
                        ::action::Action::Submit {
 | 
			
		||||
                            text: _, keys,
 | 
			
		||||
                        } => Some(keys),
 | 
			
		||||
                        _ => None,
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
                .flatten()
 | 
			
		||||
                .map(|named_keysym| named_keysym.0.as_str())
 | 
			
		||||
        let symbolmap: HashMap<String, KeyCode> = generate_keycodes(
 | 
			
		||||
            extract_symbol_names(&button_actions)
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        let button_states = button_actions.into_iter().map(|(name, action)| {
 | 
			
		||||
            let keycodes = match &action {
 | 
			
		||||
                ::action::Action::Submit { text: _, keys } => {
 | 
			
		||||
                    keys.iter().map(|named_keycode| {
 | 
			
		||||
                        *keymap.get(named_keycode.0.as_str())
 | 
			
		||||
                            .expect(
 | 
			
		||||
                                format!(
 | 
			
		||||
                                    "keycode {} in key {} missing from keymap",
 | 
			
		||||
                                    named_keycode.0,
 | 
			
		||||
                                    name
 | 
			
		||||
                                ).as_str()
 | 
			
		||||
                            )
 | 
			
		||||
                    }).collect()
 | 
			
		||||
                },
 | 
			
		||||
                action::Action::Erase => vec![
 | 
			
		||||
                    *keymap.get("BackSpace")
 | 
			
		||||
                        .expect(&format!("BackSpace missing from keymap")),
 | 
			
		||||
                ],
 | 
			
		||||
                _ => Vec::new(),
 | 
			
		||||
            };
 | 
			
		||||
            (
 | 
			
		||||
                name.into(),
 | 
			
		||||
                KeyState {
 | 
			
		||||
                    pressed: PressType::Released,
 | 
			
		||||
                    keycodes,
 | 
			
		||||
                    action,
 | 
			
		||||
                }
 | 
			
		||||
            )
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        let button_states = HashMap::<String, KeyState>::from_iter(
 | 
			
		||||
            button_states
 | 
			
		||||
            button_actions.into_iter().map(|(name, action)| {
 | 
			
		||||
                let keycodes = match &action {
 | 
			
		||||
                    ::action::Action::Submit { text: _, keys } => {
 | 
			
		||||
                        keys.iter().map(|named_keysym| {
 | 
			
		||||
                            symbolmap.get(named_keysym.0.as_str())
 | 
			
		||||
                                .expect(
 | 
			
		||||
                                    format!(
 | 
			
		||||
                                        "keysym {} in key {} missing from symbol map",
 | 
			
		||||
                                        named_keysym.0,
 | 
			
		||||
                                        name
 | 
			
		||||
                                    ).as_str()
 | 
			
		||||
                                )
 | 
			
		||||
                                .clone()
 | 
			
		||||
                        }).collect()
 | 
			
		||||
                    },
 | 
			
		||||
                    action::Action::Erase => vec![
 | 
			
		||||
                        symbolmap.get("BackSpace")
 | 
			
		||||
                            .expect(&format!("BackSpace missing from symbol map"))
 | 
			
		||||
                            .clone(),
 | 
			
		||||
                    ],
 | 
			
		||||
                    _ => Vec::new(),
 | 
			
		||||
                };
 | 
			
		||||
                (
 | 
			
		||||
                    name.into(),
 | 
			
		||||
                    KeyState {
 | 
			
		||||
                        pressed: PressType::Released,
 | 
			
		||||
                        keycodes,
 | 
			
		||||
                        action,
 | 
			
		||||
                    }
 | 
			
		||||
                )
 | 
			
		||||
            })
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // TODO: generate from symbols
 | 
			
		||||
        let keymap_str = match generate_keymap(&button_states) {
 | 
			
		||||
        let keymaps = match generate_keymaps(symbolmap) {
 | 
			
		||||
            Err(e) => { return (Err(e), warning_handler) },
 | 
			
		||||
            Ok(v) => v,
 | 
			
		||||
        };
 | 
			
		||||
@ -495,10 +484,10 @@ impl Layout {
 | 
			
		||||
        (
 | 
			
		||||
            Ok(::layout::LayoutData {
 | 
			
		||||
                views: views,
 | 
			
		||||
                keymap_str: {
 | 
			
		||||
                keymaps: keymaps.into_iter().map(|keymap_str|
 | 
			
		||||
                    CString::new(keymap_str)
 | 
			
		||||
                        .expect("Invalid keymap string generated")
 | 
			
		||||
                },
 | 
			
		||||
                ).collect(),
 | 
			
		||||
                // FIXME: use a dedicated field
 | 
			
		||||
                margins: layout::Margins {
 | 
			
		||||
                    top: self.margins.top,
 | 
			
		||||
@ -734,11 +723,27 @@ fn create_button<H: logging::Handler>(
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn extract_symbol_names<'a>(actions: &'a [(&str, action::Action)])
 | 
			
		||||
    -> impl Iterator<Item=String> + 'a
 | 
			
		||||
{
 | 
			
		||||
    actions.iter()
 | 
			
		||||
        .filter_map(|(_name, act)| {
 | 
			
		||||
            match act {
 | 
			
		||||
                action::Action::Submit {
 | 
			
		||||
                    text: _, keys,
 | 
			
		||||
                } => Some(keys.clone()),
 | 
			
		||||
                action::Action::Erase => Some(vec!(action::KeySym("BackSpace".into()))),
 | 
			
		||||
                _ => None,
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
        .flatten()
 | 
			
		||||
        .map(|named_keysym| named_keysym.0)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod tests {
 | 
			
		||||
    use super::*;
 | 
			
		||||
    
 | 
			
		||||
    use std::error::Error as ErrorTrait;
 | 
			
		||||
 | 
			
		||||
    use ::logging::ProblemPanic;
 | 
			
		||||
 | 
			
		||||
    const THIS_FILE: &str = file!();
 | 
			
		||||
@ -786,7 +791,8 @@ mod tests {
 | 
			
		||||
            Err(e) => {
 | 
			
		||||
                let mut handled = false;
 | 
			
		||||
                if let Error::Yaml(ye) = &e {
 | 
			
		||||
                    handled = ye.description() == "missing field `views`";
 | 
			
		||||
                    handled = ye.to_string()
 | 
			
		||||
                        .starts_with("missing field `views`");
 | 
			
		||||
                };
 | 
			
		||||
                if !handled {
 | 
			
		||||
                    println!("Unexpected error {:?}", e);
 | 
			
		||||
@ -804,7 +810,7 @@ mod tests {
 | 
			
		||||
            Err(e) => {
 | 
			
		||||
                let mut handled = false;
 | 
			
		||||
                if let Error::Yaml(ye) = &e {
 | 
			
		||||
                    handled = ye.description()
 | 
			
		||||
                    handled = ye.to_string()
 | 
			
		||||
                        .starts_with("unknown field `bad_field`");
 | 
			
		||||
                };
 | 
			
		||||
                if !handled {
 | 
			
		||||
@ -862,6 +868,23 @@ mod tests {
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Test if erase yields a useable keycode
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_layout_erase() {
 | 
			
		||||
        let out = Layout::from_file(path_from_root("tests/layout_erase.yaml"))
 | 
			
		||||
            .unwrap()
 | 
			
		||||
            .build(ProblemPanic).0
 | 
			
		||||
            .unwrap();
 | 
			
		||||
        assert_eq!(
 | 
			
		||||
            out.views["base"].1
 | 
			
		||||
                .get_rows()[0].1
 | 
			
		||||
                .buttons[0].1
 | 
			
		||||
                .state.borrow()
 | 
			
		||||
                .keycodes.len(),
 | 
			
		||||
            1
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn parsing_fallback() {
 | 
			
		||||
        assert!(Layout::from_resource(FALLBACK_LAYOUT_NAME)
 | 
			
		||||
@ -939,4 +962,35 @@ mod tests {
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_extract_symbols() {
 | 
			
		||||
        let actions = [(
 | 
			
		||||
            "ac",
 | 
			
		||||
            action::Action::Submit {
 | 
			
		||||
                text: None,
 | 
			
		||||
                keys: vec![
 | 
			
		||||
                    action::KeySym("a".into()),
 | 
			
		||||
                    action::KeySym("c".into()),
 | 
			
		||||
                ],
 | 
			
		||||
            },
 | 
			
		||||
        )];
 | 
			
		||||
        assert_eq!(
 | 
			
		||||
            extract_symbol_names(&actions[..]).collect::<Vec<_>>(),
 | 
			
		||||
            vec!["a", "c"],
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_extract_symbols_erase() {
 | 
			
		||||
        let actions = [(
 | 
			
		||||
            "Erase",
 | 
			
		||||
            action::Action::Erase,
 | 
			
		||||
        )];
 | 
			
		||||
        assert_eq!(
 | 
			
		||||
            extract_symbol_names(&actions[..]).collect::<Vec<_>>(),
 | 
			
		||||
            vec!["BackSpace"],
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										254
									
								
								src/keyboard.rs
									
									
									
									
									
								
							
							
						
						
									
										254
									
								
								src/keyboard.rs
									
									
									
									
									
								
							@ -5,11 +5,13 @@ use std::cell::RefCell;
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
use std::fmt;
 | 
			
		||||
use std::io;
 | 
			
		||||
use std::mem;
 | 
			
		||||
use std::ptr;
 | 
			
		||||
use std::rc::Rc;
 | 
			
		||||
use std::string::FromUtf8Error;
 | 
			
		||||
 | 
			
		||||
use ::action::Action;
 | 
			
		||||
use ::logging;
 | 
			
		||||
use ::util;
 | 
			
		||||
 | 
			
		||||
// Traits
 | 
			
		||||
use std::io::Write;
 | 
			
		||||
@ -21,7 +23,12 @@ pub enum PressType {
 | 
			
		||||
    Pressed = 1,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub type KeyCode = u32;
 | 
			
		||||
/// The extended, unambiguous layout-keycode
 | 
			
		||||
#[derive(Debug, Clone)]
 | 
			
		||||
pub struct KeyCode {
 | 
			
		||||
    pub code: u32,
 | 
			
		||||
    pub keymap_idx: usize,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bitflags!{
 | 
			
		||||
    /// Map to `virtual_keyboard.modifiers` modifiers values
 | 
			
		||||
@ -43,7 +50,7 @@ bitflags!{
 | 
			
		||||
 | 
			
		||||
/// When the submitted actions of keys need to be tracked,
 | 
			
		||||
/// they need a stable, comparable ID
 | 
			
		||||
#[derive(PartialEq)]
 | 
			
		||||
#[derive(Clone, PartialEq)]
 | 
			
		||||
pub struct KeyStateId(*const KeyState);
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Clone)]
 | 
			
		||||
@ -80,10 +87,10 @@ impl KeyState {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Sorts an iterator by converting it to a Vector and back
 | 
			
		||||
fn sorted<'a, I: Iterator<Item=&'a str>>(
 | 
			
		||||
fn sorted<'a, I: Iterator<Item=String>>(
 | 
			
		||||
    iter: I
 | 
			
		||||
) -> impl Iterator<Item=&'a str> {
 | 
			
		||||
    let mut v: Vec<&'a str> = iter.collect();
 | 
			
		||||
) -> impl Iterator<Item=String> {
 | 
			
		||||
    let mut v: Vec<String> = iter.collect();
 | 
			
		||||
    v.sort();
 | 
			
		||||
    v.into_iter()
 | 
			
		||||
}
 | 
			
		||||
@ -91,15 +98,17 @@ fn sorted<'a, I: Iterator<Item=&'a str>>(
 | 
			
		||||
/// Generates a mapping where each key gets a keycode, starting from ~~8~~
 | 
			
		||||
/// HACK: starting from 9, because 8 results in keycode 0,
 | 
			
		||||
/// which the compositor likes to discard
 | 
			
		||||
pub fn generate_keycodes<'a, C: IntoIterator<Item=&'a str>>(
 | 
			
		||||
    key_names: C
 | 
			
		||||
) -> HashMap<String, u32> {
 | 
			
		||||
    let special_keysyms = ["BackSpace", "Return"].iter().map(|&s| s);
 | 
			
		||||
pub fn generate_keycodes<'a, C: IntoIterator<Item=String>>(
 | 
			
		||||
    key_names: C,
 | 
			
		||||
) -> HashMap<String, KeyCode> {
 | 
			
		||||
    HashMap::from_iter(
 | 
			
		||||
        // sort to remove a source of indeterminism in keycode assignment
 | 
			
		||||
        sorted(key_names.into_iter().chain(special_keysyms))
 | 
			
		||||
            .map(|name| String::from(name))
 | 
			
		||||
            .zip(9..)
 | 
			
		||||
        // Sort to remove a source of indeterminism in keycode assignment.
 | 
			
		||||
        sorted(key_names.into_iter())
 | 
			
		||||
            .zip(util::cycle_count(9..255))
 | 
			
		||||
            .map(|(name, (code, keymap_idx))| (
 | 
			
		||||
                String::from(name),
 | 
			
		||||
                KeyCode { code, keymap_idx },
 | 
			
		||||
            ))
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -124,12 +133,54 @@ impl From<io::Error> for FormattingError {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Index is the key code, String is the occupant.
 | 
			
		||||
/// Starts all empty.
 | 
			
		||||
/// https://gitlab.freedesktop.org/xorg/xserver/-/issues/260
 | 
			
		||||
type SingleKeyMap = [Option<String>; 256];
 | 
			
		||||
 | 
			
		||||
fn single_key_map_new() -> SingleKeyMap {
 | 
			
		||||
    // Why can't we just initialize arrays without tricks -_- ?
 | 
			
		||||
    unsafe {
 | 
			
		||||
        // Inspired by
 | 
			
		||||
        // https://www.reddit.com/r/rust/comments/5n7bh1/how_to_create_an_array_of_a_type_with_clone_but/
 | 
			
		||||
        #[cfg(feature = "rustc_less_1_36")]
 | 
			
		||||
        let mut array: SingleKeyMap = mem::uninitialized();
 | 
			
		||||
        #[cfg(not(feature = "rustc_less_1_36"))]
 | 
			
		||||
        let mut array: SingleKeyMap = mem::MaybeUninit::uninit().assume_init();
 | 
			
		||||
 | 
			
		||||
        for element in array.iter_mut() {
 | 
			
		||||
            ptr::write(element, None);
 | 
			
		||||
        }
 | 
			
		||||
        array
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn generate_keymaps(symbolmap: HashMap::<String, KeyCode>)
 | 
			
		||||
    -> Result<Vec<String>, FormattingError>
 | 
			
		||||
{
 | 
			
		||||
    let mut bins: Vec<SingleKeyMap> = Vec::new();
 | 
			
		||||
    
 | 
			
		||||
    for (name, KeyCode { code, keymap_idx }) in symbolmap.into_iter() {
 | 
			
		||||
        if keymap_idx >= bins.len() {
 | 
			
		||||
            bins.resize_with(
 | 
			
		||||
                keymap_idx + 1,
 | 
			
		||||
                || single_key_map_new(),
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        bins[keymap_idx][code as usize] = Some(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let mut out = Vec::new();
 | 
			
		||||
    for bin in bins {
 | 
			
		||||
        out.push(generate_keymap(&bin)?);
 | 
			
		||||
    }
 | 
			
		||||
    Ok(out)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Generates a de-facto single level keymap.
 | 
			
		||||
// TODO: don't rely on keys and their order,
 | 
			
		||||
// but rather on what keysyms and keycodes are in use.
 | 
			
		||||
// Iterating actions makes it hard to deduplicate keysyms.
 | 
			
		||||
pub fn generate_keymap(
 | 
			
		||||
    keystates: &HashMap::<String, KeyState>
 | 
			
		||||
/// Key codes must not repeat and must remain between 9 and 255.
 | 
			
		||||
fn generate_keymap(
 | 
			
		||||
    symbolmap: &SingleKeyMap,
 | 
			
		||||
) -> Result<String, FormattingError> {
 | 
			
		||||
    let mut buf: Vec<u8> = Vec::new();
 | 
			
		||||
    writeln!(
 | 
			
		||||
@ -140,86 +191,80 @@ pub fn generate_keymap(
 | 
			
		||||
        minimum = 8;
 | 
			
		||||
        maximum = 255;"
 | 
			
		||||
    )?;
 | 
			
		||||
 | 
			
		||||
    let pairs: Vec<(&String, usize)> = symbolmap.iter()
 | 
			
		||||
        // Attach a key code to each cell.
 | 
			
		||||
        .enumerate()
 | 
			
		||||
        // Get rid of empty keycodes.
 | 
			
		||||
        .filter_map(|(code, name)| name.as_ref().map(|n| (n, code)))
 | 
			
		||||
        .collect();
 | 
			
		||||
    
 | 
			
		||||
    for (name, state) in keystates.iter() {
 | 
			
		||||
        match &state.action {
 | 
			
		||||
            Action::Submit { text: _, keys } => {
 | 
			
		||||
                if let 0 = keys.len() {
 | 
			
		||||
                    log_print!(
 | 
			
		||||
                        logging::Level::Warning,
 | 
			
		||||
                        "Key {} has no keysyms", name,
 | 
			
		||||
                    );
 | 
			
		||||
                };
 | 
			
		||||
                for (named_keysym, keycode) in keys.iter().zip(&state.keycodes) {
 | 
			
		||||
                    write!(
 | 
			
		||||
                        buf,
 | 
			
		||||
                        "
 | 
			
		||||
        <{}> = {};",
 | 
			
		||||
                        named_keysym.0,
 | 
			
		||||
                        keycode,
 | 
			
		||||
                    )?;
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            Action::Erase => {
 | 
			
		||||
                let mut keycodes = state.keycodes.iter();
 | 
			
		||||
                write!(
 | 
			
		||||
                    buf,
 | 
			
		||||
                    "
 | 
			
		||||
        <BackSpace> = {};",
 | 
			
		||||
                    keycodes.next().expect("Erase key has no keycode"),
 | 
			
		||||
                )?;
 | 
			
		||||
                if let Some(_) = keycodes.next() {
 | 
			
		||||
                    log_print!(
 | 
			
		||||
                        logging::Level::Bug,
 | 
			
		||||
                        "Erase key has multiple keycodes",
 | 
			
		||||
                    );
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            _ => {},
 | 
			
		||||
        }
 | 
			
		||||
    // Xorg can only consume up to 255 keys, so this may not work in Xwayland.
 | 
			
		||||
    // Two possible solutions:
 | 
			
		||||
    // - use levels to cram multiple characters into one key
 | 
			
		||||
    // - swap layouts on key presses
 | 
			
		||||
    for (_name, keycode) in &pairs {
 | 
			
		||||
        write!(
 | 
			
		||||
            buf,
 | 
			
		||||
            "
 | 
			
		||||
        <I{}> = {0};",
 | 
			
		||||
            keycode,
 | 
			
		||||
        )?;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    writeln!(
 | 
			
		||||
        buf,
 | 
			
		||||
        "
 | 
			
		||||
        indicator 1 = \"Caps Lock\"; // Xwayland won't accept without it.
 | 
			
		||||
    }};
 | 
			
		||||
    
 | 
			
		||||
    xkb_symbols \"squeekboard\" {{
 | 
			
		||||
 | 
			
		||||
        name[Group1] = \"Letters\";
 | 
			
		||||
        name[Group2] = \"Numbers/Symbols\";
 | 
			
		||||
        
 | 
			
		||||
        key <BackSpace> {{ [ BackSpace ] }};"
 | 
			
		||||
"
 | 
			
		||||
    )?;
 | 
			
		||||
    
 | 
			
		||||
    for (name, state) in keystates.iter() {
 | 
			
		||||
        if let Action::Submit { text: _, keys } = &state.action {
 | 
			
		||||
            for keysym in keys.iter() {
 | 
			
		||||
                write!(
 | 
			
		||||
                    buf,
 | 
			
		||||
                    "
 | 
			
		||||
        key <{}> {{ [ {0} ] }};",
 | 
			
		||||
                    keysym.0,
 | 
			
		||||
                )?;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    for (name, keycode) in pairs {
 | 
			
		||||
        write!(
 | 
			
		||||
            buf,
 | 
			
		||||
            "
 | 
			
		||||
key <I{}> {{ [ {} ] }};",
 | 
			
		||||
            keycode,
 | 
			
		||||
            name,
 | 
			
		||||
        )?;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    writeln!(
 | 
			
		||||
        buf,
 | 
			
		||||
        "
 | 
			
		||||
    }};
 | 
			
		||||
 | 
			
		||||
    xkb_types \"squeekboard\" {{
 | 
			
		||||
        virtual_modifiers Squeekboard; // No modifiers! Needed for Xorg for some reason.
 | 
			
		||||
    
 | 
			
		||||
        // Those names are needed for Xwayland.
 | 
			
		||||
        type \"ONE_LEVEL\" {{
 | 
			
		||||
            modifiers= none;
 | 
			
		||||
            level_name[Level1]= \"Any\";
 | 
			
		||||
        }};
 | 
			
		||||
        type \"TWO_LEVEL\" {{
 | 
			
		||||
            level_name[Level1]= \"Base\";
 | 
			
		||||
        }};
 | 
			
		||||
        type \"ALPHABETIC\" {{
 | 
			
		||||
            level_name[Level1]= \"Base\";
 | 
			
		||||
        }};
 | 
			
		||||
        type \"KEYPAD\" {{
 | 
			
		||||
            level_name[Level1]= \"Base\";
 | 
			
		||||
        }};
 | 
			
		||||
        type \"SHIFT+ALT\" {{
 | 
			
		||||
            level_name[Level1]= \"Base\";
 | 
			
		||||
        }};
 | 
			
		||||
 | 
			
		||||
	type \"TWO_LEVEL\" {{
 | 
			
		||||
            modifiers = Shift;
 | 
			
		||||
            map[Shift] = Level2;
 | 
			
		||||
            level_name[Level1] = \"Base\";
 | 
			
		||||
            level_name[Level2] = \"Shift\";
 | 
			
		||||
	}};
 | 
			
		||||
    }};
 | 
			
		||||
 | 
			
		||||
    xkb_compatibility \"squeekboard\" {{
 | 
			
		||||
        // Needed for Xwayland again.
 | 
			
		||||
        interpret Any+AnyOf(all) {{
 | 
			
		||||
            action= SetMods(modifiers=modMapMods,clearLocks);
 | 
			
		||||
        }};
 | 
			
		||||
    }};
 | 
			
		||||
}};"
 | 
			
		||||
    )?;
 | 
			
		||||
@ -234,22 +279,15 @@ mod tests {
 | 
			
		||||
    
 | 
			
		||||
    use xkbcommon::xkb;
 | 
			
		||||
 | 
			
		||||
    use ::action::KeySym;
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_keymap_multi() {
 | 
			
		||||
        let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
 | 
			
		||||
    fn test_keymap_single_resolve() {
 | 
			
		||||
        let mut key_map = single_key_map_new();
 | 
			
		||||
        key_map[9] = Some("a".into());
 | 
			
		||||
        key_map[10] = Some("c".into());
 | 
			
		||||
 | 
			
		||||
        let keymap_str = generate_keymap(&hashmap!{
 | 
			
		||||
            "ac".into() => KeyState {
 | 
			
		||||
                action: Action::Submit {
 | 
			
		||||
                    text: None,
 | 
			
		||||
                    keys: vec!(KeySym("a".into()), KeySym("c".into())),
 | 
			
		||||
                },
 | 
			
		||||
                keycodes: vec!(9, 10),
 | 
			
		||||
                pressed: PressType::Released,
 | 
			
		||||
            },
 | 
			
		||||
        }).unwrap();
 | 
			
		||||
        let keymap_str = generate_keymap(&key_map).unwrap();
 | 
			
		||||
 | 
			
		||||
        let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
 | 
			
		||||
 | 
			
		||||
        let keymap = xkb::Keymap::new_from_string(
 | 
			
		||||
            &context,
 | 
			
		||||
@ -263,4 +301,36 @@ mod tests {
 | 
			
		||||
        assert_eq!(state.key_get_one_sym(9), xkb::KEY_a);
 | 
			
		||||
        assert_eq!(state.key_get_one_sym(10), xkb::KEY_c);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_keymap_second_resolve() {
 | 
			
		||||
        let keymaps = generate_keymaps(hashmap!(
 | 
			
		||||
            "a".into() => KeyCode { keymap_idx: 1, code: 9 },
 | 
			
		||||
        )).unwrap();
 | 
			
		||||
 | 
			
		||||
        let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
 | 
			
		||||
 | 
			
		||||
        let keymap = xkb::Keymap::new_from_string(
 | 
			
		||||
            &context,
 | 
			
		||||
            keymaps[1].clone(), // this index is part of the test
 | 
			
		||||
            xkb::KEYMAP_FORMAT_TEXT_V1,
 | 
			
		||||
            xkb::KEYMAP_COMPILE_NO_FLAGS,
 | 
			
		||||
        ).expect("Failed to create keymap");
 | 
			
		||||
 | 
			
		||||
        let state = xkb::State::new(&keymap);
 | 
			
		||||
 | 
			
		||||
        assert_eq!(state.key_get_one_sym(9), xkb::KEY_a);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn test_symbolmap_overflow() {
 | 
			
		||||
        // The 257th key (U1101) is interesting.
 | 
			
		||||
        // Use Unicode encoding for being able to use in xkb keymaps.
 | 
			
		||||
        let keynames = (0..258).map(|num| format!("U{:04X}", 0x1000 + num));
 | 
			
		||||
        let keycodes = generate_keycodes(keynames);
 | 
			
		||||
        
 | 
			
		||||
        // test now
 | 
			
		||||
        let code = keycodes.get("U1101").expect("Did not find the tested keysym");
 | 
			
		||||
        assert_eq!(code.keymap_idx, 1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,6 @@ struct transformation squeek_layout_calculate_transformation(
 | 
			
		||||
        double allocation_width, double allocation_size);
 | 
			
		||||
 | 
			
		||||
struct squeek_layout *squeek_load_layout(const char *name, uint32_t type);
 | 
			
		||||
const char *squeek_layout_get_keymap(const struct squeek_layout*);
 | 
			
		||||
enum squeek_arrangement_kind squeek_layout_get_kind(const struct squeek_layout *);
 | 
			
		||||
void squeek_layout_free(struct squeek_layout*);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -107,8 +107,8 @@ pub mod c {
 | 
			
		||||
 | 
			
		||||
    impl Bounds {
 | 
			
		||||
        pub fn contains(&self, point: &Point) -> bool {
 | 
			
		||||
            (point.x > self.x && point.x < self.x + self.width
 | 
			
		||||
                && point.y > self.y && point.y < self.y + self.height)
 | 
			
		||||
            point.x > self.x && point.x < self.x + self.width
 | 
			
		||||
                && point.y > self.y && point.y < self.y + self.height
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -236,13 +236,6 @@ pub mod c {
 | 
			
		||||
            height: allocation_height,
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
    fn squeek_layout_get_keymap(layout: *const Layout) -> *const c_char {
 | 
			
		||||
        let layout = unsafe { &*layout };
 | 
			
		||||
        layout.keymap_str.as_ptr()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
@ -632,8 +625,8 @@ pub struct Layout {
 | 
			
		||||
    pub views: HashMap<String, (c::Point, View)>,
 | 
			
		||||
 | 
			
		||||
    // Non-UI stuff
 | 
			
		||||
    /// xkb keymap applicable to the contained keys. Unchangeable
 | 
			
		||||
    pub keymap_str: CString,
 | 
			
		||||
    /// xkb keymaps applicable to the contained keys. Unchangeable
 | 
			
		||||
    pub keymaps: Vec<CString>,
 | 
			
		||||
    // Changeable state
 | 
			
		||||
    // a Vec would be enough, but who cares, this will be small & fast enough
 | 
			
		||||
    // TODO: turn those into per-input point *_buttons to track dragging.
 | 
			
		||||
@ -649,7 +642,7 @@ pub struct Layout {
 | 
			
		||||
pub struct LayoutData {
 | 
			
		||||
    /// Point is the offset within layout
 | 
			
		||||
    pub views: HashMap<String, (c::Point, View)>,
 | 
			
		||||
    pub keymap_str: CString,
 | 
			
		||||
    pub keymaps: Vec<CString>,
 | 
			
		||||
    pub margins: Margins,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -672,7 +665,7 @@ impl Layout {
 | 
			
		||||
            kind,
 | 
			
		||||
            current_view: "base".to_owned(),
 | 
			
		||||
            views: data.views,
 | 
			
		||||
            keymap_str: data.keymap_str,
 | 
			
		||||
            keymaps: data.keymaps,
 | 
			
		||||
            pressed_keys: HashSet::new(),
 | 
			
		||||
            margins: data.margins,
 | 
			
		||||
        }
 | 
			
		||||
@ -1135,7 +1128,7 @@ mod test {
 | 
			
		||||
        ]);
 | 
			
		||||
        let layout = Layout {
 | 
			
		||||
            current_view: String::new(),
 | 
			
		||||
            keymap_str: CString::new("").unwrap(),
 | 
			
		||||
            keymaps: Vec::new(),
 | 
			
		||||
            kind: ArrangementKind::Base,
 | 
			
		||||
            pressed_keys: HashSet::new(),
 | 
			
		||||
            // Lots of bottom margin
 | 
			
		||||
 | 
			
		||||
@ -31,22 +31,16 @@ pub enum Error {
 | 
			
		||||
 | 
			
		||||
impl ::std::fmt::Display for Error {
 | 
			
		||||
    fn fmt(&self, out: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
 | 
			
		||||
        use ::std::error::Error;
 | 
			
		||||
        out.write_str(self.description())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl ::std::error::Error for Error {
 | 
			
		||||
    fn description(&self) -> &str {
 | 
			
		||||
        match self {
 | 
			
		||||
        out.write_str(match self {
 | 
			
		||||
            &Error::NotWellFormed => "Language tag is not well-formed.",
 | 
			
		||||
            // this is exception: here we do want exhaustive match so we don't publish version with
 | 
			
		||||
            // missing descriptions by mistake.
 | 
			
		||||
            &Error::__NonExhaustive => panic!("Placeholder error must not be instantiated!"),
 | 
			
		||||
        }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/// Convenience Result alias.
 | 
			
		||||
type Result<T> = ::std::result::Result<T, Error>;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ struct squeek_output_handle {
 | 
			
		||||
    struct squeek_outputs *outputs;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct squeek_outputs *squeek_outputs_new();
 | 
			
		||||
struct squeek_outputs *squeek_outputs_new(void);
 | 
			
		||||
void squeek_outputs_free(struct squeek_outputs*);
 | 
			
		||||
void squeek_outputs_register(struct squeek_outputs*, struct wl_output *output);
 | 
			
		||||
struct squeek_output_handle squeek_outputs_get_current(struct squeek_outputs*);
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
 | 
			
		||||
    ("us_wide", include_str!("../data/keyboards/us_wide.yaml")),
 | 
			
		||||
    ("br", include_str!("../data/keyboards/br.yaml")),
 | 
			
		||||
    ("de", include_str!("../data/keyboards/de.yaml")),
 | 
			
		||||
    ("be", include_str!("../data/keyboards/be.yaml")),
 | 
			
		||||
    ("de_wide", include_str!("../data/keyboards/de_wide.yaml")),
 | 
			
		||||
    ("dk", include_str!("../data/keyboards/dk.yaml")),
 | 
			
		||||
    ("es", include_str!("../data/keyboards/es.yaml")),
 | 
			
		||||
@ -32,6 +33,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
 | 
			
		||||
    ("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")),
 | 
			
		||||
    ("ru", include_str!("../data/keyboards/ru.yaml")),
 | 
			
		||||
    ("se", include_str!("../data/keyboards/se.yaml")),
 | 
			
		||||
    ("ua", include_str!("../data/keyboards/ua.yaml")),
 | 
			
		||||
    // layout+overlay
 | 
			
		||||
    ("terminal", include_str!("../data/keyboards/terminal.yaml")),
 | 
			
		||||
    // Overlays
 | 
			
		||||
 | 
			
		||||
@ -31,11 +31,10 @@
 | 
			
		||||
enum {
 | 
			
		||||
    PROP_0,
 | 
			
		||||
    PROP_VISIBLE,
 | 
			
		||||
    PROP_ENABLED,
 | 
			
		||||
    PROP_LAST
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct _ServerContextServiceClass ServerContextServiceClass;
 | 
			
		||||
 | 
			
		||||
struct _ServerContextService {
 | 
			
		||||
    GObject parent;
 | 
			
		||||
 | 
			
		||||
@ -46,45 +45,43 @@ struct _ServerContextService {
 | 
			
		||||
    struct ui_manager *manager; // unowned
 | 
			
		||||
 | 
			
		||||
    gboolean visible;
 | 
			
		||||
    gboolean enabled;
 | 
			
		||||
    PhoshLayerSurface *window;
 | 
			
		||||
    GtkWidget *widget; // nullable
 | 
			
		||||
    guint hiding;
 | 
			
		||||
    guint last_requested_height;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct _ServerContextServiceClass {
 | 
			
		||||
    GObjectClass parent_class;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
G_DEFINE_TYPE(ServerContextService, server_context_service, G_TYPE_OBJECT);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_destroy (GtkWidget *widget, gpointer user_data)
 | 
			
		||||
on_destroy (ServerContextService *self, GtkWidget *widget)
 | 
			
		||||
{
 | 
			
		||||
    ServerContextService *context = user_data;
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
 | 
			
		||||
    g_assert (widget == GTK_WIDGET(context->window));
 | 
			
		||||
    g_assert (widget == GTK_WIDGET(self->window));
 | 
			
		||||
 | 
			
		||||
    context->window = NULL;
 | 
			
		||||
    context->widget = NULL;
 | 
			
		||||
    self->window = NULL;
 | 
			
		||||
    self->widget = NULL;
 | 
			
		||||
 | 
			
		||||
    //eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_notify_map (GObject    *object,
 | 
			
		||||
               ServerContextService *context)
 | 
			
		||||
on_notify_map (ServerContextService *self, GtkWidget *widget)
 | 
			
		||||
{
 | 
			
		||||
    g_object_set (context, "visible", TRUE, NULL);
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
 | 
			
		||||
    g_object_set (self, "visible", TRUE, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_notify_unmap (GObject    *object,
 | 
			
		||||
                 ServerContextService *context)
 | 
			
		||||
on_notify_unmap (ServerContextService *self, GtkWidget *widget)
 | 
			
		||||
{
 | 
			
		||||
    (void)object;
 | 
			
		||||
    g_object_set (context, "visible", FALSE, NULL);
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
 | 
			
		||||
    g_object_set (self, "visible", FALSE, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t
 | 
			
		||||
@ -100,10 +97,14 @@ calculate_height(int32_t width)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
 | 
			
		||||
on_surface_configure(ServerContextService *self, PhoshLayerSurface *surface)
 | 
			
		||||
{
 | 
			
		||||
    gint width;
 | 
			
		||||
    gint height;
 | 
			
		||||
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
    g_return_if_fail (PHOSH_IS_LAYER_SURFACE (surface));
 | 
			
		||||
 | 
			
		||||
    g_object_get(G_OBJECT(surface),
 | 
			
		||||
                 "configured-width", &width,
 | 
			
		||||
                 "configured-height", &height,
 | 
			
		||||
@ -122,8 +123,8 @@ on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
 | 
			
		||||
    // as it's likely to create pointless loops
 | 
			
		||||
    // of request->reject->request_again->...
 | 
			
		||||
    if (desired_height != configured_height
 | 
			
		||||
            && context->last_requested_height != desired_height) {
 | 
			
		||||
        context->last_requested_height = desired_height;
 | 
			
		||||
            && self->last_requested_height != desired_height) {
 | 
			
		||||
        self->last_requested_height = desired_height;
 | 
			
		||||
        phosh_layer_surface_set_size(surface, 0,
 | 
			
		||||
                                     (gint)desired_height);
 | 
			
		||||
        phosh_layer_surface_set_exclusive_zone(surface, (gint)desired_height);
 | 
			
		||||
@ -132,16 +133,16 @@ on_surface_configure(PhoshLayerSurface *surface, ServerContextService *context)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
make_window (ServerContextService *context)
 | 
			
		||||
make_window (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (context->window)
 | 
			
		||||
    if (self->window)
 | 
			
		||||
        g_error("Window already present");
 | 
			
		||||
 | 
			
		||||
    struct squeek_output_handle output = squeek_outputs_get_current(squeek_wayland->outputs);
 | 
			
		||||
    squeek_uiman_set_output(context->manager, output);
 | 
			
		||||
    uint32_t height = squeek_uiman_get_perceptual_height(context->manager);
 | 
			
		||||
    squeek_uiman_set_output(self->manager, output);
 | 
			
		||||
    uint32_t height = squeek_uiman_get_perceptual_height(self->manager);
 | 
			
		||||
 | 
			
		||||
    context->window = g_object_new (
 | 
			
		||||
    self->window = g_object_new (
 | 
			
		||||
        PHOSH_TYPE_LAYER_SURFACE,
 | 
			
		||||
        "layer-shell", squeek_wayland->layer_shell,
 | 
			
		||||
        "wl-output", output.output,
 | 
			
		||||
@ -156,11 +157,11 @@ make_window (ServerContextService *context)
 | 
			
		||||
        NULL
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    g_object_connect (context->window,
 | 
			
		||||
                      "signal::destroy", G_CALLBACK(on_destroy), context,
 | 
			
		||||
                      "signal::map", G_CALLBACK(on_notify_map), context,
 | 
			
		||||
                      "signal::unmap", G_CALLBACK(on_notify_unmap), context,
 | 
			
		||||
                      "signal::configured", G_CALLBACK(on_surface_configure), context,
 | 
			
		||||
    g_object_connect (self->window,
 | 
			
		||||
                      "swapped-signal::destroy", G_CALLBACK(on_destroy), self,
 | 
			
		||||
                      "swapped-signal::map", G_CALLBACK(on_notify_map), self,
 | 
			
		||||
                      "swapped-signal::unmap", G_CALLBACK(on_notify_unmap), self,
 | 
			
		||||
                      "swapped-signal::configured", G_CALLBACK(on_surface_configure), self,
 | 
			
		||||
                      NULL);
 | 
			
		||||
 | 
			
		||||
    // The properties below are just to make hacking easier.
 | 
			
		||||
@ -168,87 +169,90 @@ make_window (ServerContextService *context)
 | 
			
		||||
    // and there's no space in the protocol for others.
 | 
			
		||||
    // Those may still be useful in the future,
 | 
			
		||||
    // or for hacks with regular windows.
 | 
			
		||||
    gtk_widget_set_can_focus (GTK_WIDGET(context->window), FALSE);
 | 
			
		||||
    g_object_set (G_OBJECT(context->window), "accept_focus", FALSE, NULL);
 | 
			
		||||
    gtk_window_set_title (GTK_WINDOW(context->window),
 | 
			
		||||
    gtk_widget_set_can_focus (GTK_WIDGET(self->window), FALSE);
 | 
			
		||||
    g_object_set (G_OBJECT(self->window), "accept_focus", FALSE, NULL);
 | 
			
		||||
    gtk_window_set_title (GTK_WINDOW(self->window),
 | 
			
		||||
                          _("Squeekboard"));
 | 
			
		||||
    gtk_window_set_icon_name (GTK_WINDOW(context->window), "squeekboard");
 | 
			
		||||
    gtk_window_set_keep_above (GTK_WINDOW(context->window), TRUE);
 | 
			
		||||
    gtk_window_set_icon_name (GTK_WINDOW(self->window), "squeekboard");
 | 
			
		||||
    gtk_window_set_keep_above (GTK_WINDOW(self->window), TRUE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
destroy_window (ServerContextService *context)
 | 
			
		||||
destroy_window (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    gtk_widget_destroy (GTK_WIDGET (context->window));
 | 
			
		||||
    context->window = NULL;
 | 
			
		||||
    gtk_widget_destroy (GTK_WIDGET (self->window));
 | 
			
		||||
    self->window = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
make_widget (ServerContextService *context)
 | 
			
		||||
make_widget (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (context->widget) {
 | 
			
		||||
        gtk_widget_destroy(context->widget);
 | 
			
		||||
        context->widget = NULL;
 | 
			
		||||
    if (self->widget) {
 | 
			
		||||
        gtk_widget_destroy(self->widget);
 | 
			
		||||
        self->widget = NULL;
 | 
			
		||||
    }
 | 
			
		||||
    context->widget = eek_gtk_keyboard_new (context->state, context->submission, context->layout);
 | 
			
		||||
    self->widget = eek_gtk_keyboard_new (self->state, self->submission, self->layout);
 | 
			
		||||
 | 
			
		||||
    gtk_widget_set_has_tooltip (context->widget, TRUE);
 | 
			
		||||
    gtk_container_add (GTK_CONTAINER(context->window), context->widget);
 | 
			
		||||
    gtk_widget_show_all(context->widget);
 | 
			
		||||
    gtk_widget_set_has_tooltip (self->widget, TRUE);
 | 
			
		||||
    gtk_container_add (GTK_CONTAINER(self->window), self->widget);
 | 
			
		||||
    gtk_widget_show_all(self->widget);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
on_hide (ServerContextService *context)
 | 
			
		||||
on_hide (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    gtk_widget_hide (GTK_WIDGET(context->window));
 | 
			
		||||
    context->hiding = 0;
 | 
			
		||||
    gtk_widget_hide (GTK_WIDGET(self->window));
 | 
			
		||||
    self->hiding = 0;
 | 
			
		||||
 | 
			
		||||
    return G_SOURCE_REMOVE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_real_show_keyboard (ServerContextService *context)
 | 
			
		||||
server_context_service_real_show_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (context->hiding) {
 | 
			
		||||
	    g_source_remove (context->hiding);
 | 
			
		||||
	    context->hiding = 0;
 | 
			
		||||
    if (!self->enabled)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    if (self->hiding) {
 | 
			
		||||
	    g_source_remove (self->hiding);
 | 
			
		||||
	    self->hiding = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!context->window)
 | 
			
		||||
        make_window (context);
 | 
			
		||||
    if (!context->widget)
 | 
			
		||||
        make_widget (context);
 | 
			
		||||
    if (!self->window)
 | 
			
		||||
        make_window (self);
 | 
			
		||||
    if (!self->widget)
 | 
			
		||||
        make_widget (self);
 | 
			
		||||
 | 
			
		||||
    context->visible = TRUE;
 | 
			
		||||
    gtk_widget_show (GTK_WIDGET(context->window));
 | 
			
		||||
    self->visible = TRUE;
 | 
			
		||||
    gtk_widget_show (GTK_WIDGET(self->window));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_real_hide_keyboard (ServerContextService *context)
 | 
			
		||||
server_context_service_real_hide_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (!context->hiding)
 | 
			
		||||
        context->hiding = g_timeout_add (200, (GSourceFunc) on_hide, context);
 | 
			
		||||
    if (!self->hiding)
 | 
			
		||||
        self->hiding = g_timeout_add (200, (GSourceFunc) on_hide, self);
 | 
			
		||||
 | 
			
		||||
    context->visible = FALSE;
 | 
			
		||||
    self->visible = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
server_context_service_show_keyboard (ServerContextService *context)
 | 
			
		||||
server_context_service_show_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(context));
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
 | 
			
		||||
 | 
			
		||||
    if (!context->visible) {
 | 
			
		||||
        server_context_service_real_show_keyboard (context);
 | 
			
		||||
    if (!self->visible) {
 | 
			
		||||
        server_context_service_real_show_keyboard (self);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
server_context_service_hide_keyboard (ServerContextService *context)
 | 
			
		||||
server_context_service_hide_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(context));
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
 | 
			
		||||
 | 
			
		||||
    if (context->visible) {
 | 
			
		||||
        server_context_service_real_hide_keyboard (context);
 | 
			
		||||
    if (self->visible) {
 | 
			
		||||
        server_context_service_real_hide_keyboard (self);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -258,13 +262,15 @@ server_context_service_set_property (GObject      *object,
 | 
			
		||||
                                     const GValue *value,
 | 
			
		||||
                                     GParamSpec   *pspec)
 | 
			
		||||
{
 | 
			
		||||
    ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
    ServerContextService *self = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
 | 
			
		||||
    switch (prop_id) {
 | 
			
		||||
    case PROP_VISIBLE:
 | 
			
		||||
        context->visible = g_value_get_boolean (value);
 | 
			
		||||
        self->visible = g_value_get_boolean (value);
 | 
			
		||||
        break;
 | 
			
		||||
    case PROP_ENABLED:
 | 
			
		||||
        server_context_service_set_enabled (self, g_value_get_boolean (value));
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 | 
			
		||||
        break;
 | 
			
		||||
@ -277,10 +283,10 @@ server_context_service_get_property (GObject    *object,
 | 
			
		||||
                                       GValue     *value,
 | 
			
		||||
                                       GParamSpec *pspec)
 | 
			
		||||
{
 | 
			
		||||
    ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
    ServerContextService *self = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
    switch (prop_id) {
 | 
			
		||||
    case PROP_VISIBLE:
 | 
			
		||||
        g_value_set_boolean (value, context->visible);
 | 
			
		||||
        g_value_set_boolean (value, self->visible);
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 | 
			
		||||
@ -291,10 +297,10 @@ server_context_service_get_property (GObject    *object,
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_dispose (GObject *object)
 | 
			
		||||
{
 | 
			
		||||
    ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
    ServerContextService *self = SERVER_CONTEXT_SERVICE(object);
 | 
			
		||||
 | 
			
		||||
    destroy_window (context);
 | 
			
		||||
    context->widget = NULL;
 | 
			
		||||
    destroy_window (self);
 | 
			
		||||
    self->widget = NULL;
 | 
			
		||||
 | 
			
		||||
    G_OBJECT_CLASS (server_context_service_parent_class)->dispose (object);
 | 
			
		||||
}
 | 
			
		||||
@ -320,20 +326,67 @@ server_context_service_class_init (ServerContextServiceClass *klass)
 | 
			
		||||
    g_object_class_install_property (gobject_class,
 | 
			
		||||
                                     PROP_VISIBLE,
 | 
			
		||||
                                     pspec);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * ServerContextServie:keyboard:
 | 
			
		||||
     *
 | 
			
		||||
     * Does the user want the keyboard to show up automatically?
 | 
			
		||||
     */
 | 
			
		||||
    pspec =
 | 
			
		||||
        g_param_spec_boolean ("enabled",
 | 
			
		||||
                              "Enabled",
 | 
			
		||||
                              "Whether the keyboard is enabled",
 | 
			
		||||
                              TRUE,
 | 
			
		||||
                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 | 
			
		||||
    g_object_class_install_property (gobject_class,
 | 
			
		||||
                                     PROP_ENABLED,
 | 
			
		||||
                                     pspec);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_init (ServerContextService *state) {
 | 
			
		||||
    (void)state;
 | 
			
		||||
server_context_service_init (ServerContextService *self) {
 | 
			
		||||
    const char *schema_name = "org.gnome.desktop.a11y.applications";
 | 
			
		||||
    GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
 | 
			
		||||
    g_autoptr(GSettingsSchema) schema = NULL;
 | 
			
		||||
 | 
			
		||||
    self->enabled = TRUE;
 | 
			
		||||
    if (!ssrc) {
 | 
			
		||||
        g_warning("No gsettings schemas installed.");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    schema = g_settings_schema_source_lookup(ssrc, schema_name, TRUE);
 | 
			
		||||
    if (schema) {
 | 
			
		||||
        g_autoptr(GSettings) settings = g_settings_new (schema_name);
 | 
			
		||||
        g_settings_bind (settings, "screen-keyboard-enabled",
 | 
			
		||||
                         self, "enabled", G_SETTINGS_BIND_GET);
 | 
			
		||||
    } else {
 | 
			
		||||
        g_warning("Gsettings schema %s is not installed on the system. "
 | 
			
		||||
                  "Enabling by default.", schema_name);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ServerContextService *
 | 
			
		||||
server_context_service_new (EekboardContextService *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman)
 | 
			
		||||
server_context_service_new (EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman)
 | 
			
		||||
{
 | 
			
		||||
    ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL);
 | 
			
		||||
    ui->submission = submission;
 | 
			
		||||
    ui->state = state;
 | 
			
		||||
    ui->state = self;
 | 
			
		||||
    ui->layout = layout;
 | 
			
		||||
    ui->manager = uiman;
 | 
			
		||||
    return ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
server_context_service_set_enabled (ServerContextService *self, gboolean enabled)
 | 
			
		||||
{
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
 | 
			
		||||
    if (enabled == self->enabled)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    self->enabled = enabled;
 | 
			
		||||
    if (self->enabled)
 | 
			
		||||
        server_context_service_show_keyboard (self);
 | 
			
		||||
    else
 | 
			
		||||
        server_context_service_hide_keyboard (self);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,22 +25,15 @@
 | 
			
		||||
G_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
#define SERVER_TYPE_CONTEXT_SERVICE (server_context_service_get_type())
 | 
			
		||||
#define SERVER_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SERVER_TYPE_CONTEXT_SERVICE, ServerContextService))
 | 
			
		||||
#define SERVER_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SERVER_TYPE_CONTEXT_SERVICE, ServerContextServiceClass))
 | 
			
		||||
#define SERVER_IS_CONTEXT_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SERVER_TYPE_CONTEXT_SERVICE))
 | 
			
		||||
#define SERVER_IS_CONTEXT_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SERVER_TYPE_CONTEXT_SERVICE))
 | 
			
		||||
#define SERVER_CONTEXT_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SERVER_TYPE_CONTEXT_SERVICE, ServerContextServiceClass))
 | 
			
		||||
 | 
			
		||||
/** Manages the lifecycle of the window displaying layouts. */
 | 
			
		||||
typedef struct _ServerContextService ServerContextService;
 | 
			
		||||
G_DECLARE_FINAL_TYPE (ServerContextService, server_context_service, SERVER, CONTEXT_SERVICE, GObject)
 | 
			
		||||
 | 
			
		||||
GType         server_context_service_get_type
 | 
			
		||||
                                              (void) G_GNUC_CONST;
 | 
			
		||||
 | 
			
		||||
ServerContextService *server_context_service_new(EekboardContextService *state, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman);
 | 
			
		||||
ServerContextService *server_context_service_new(EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman);
 | 
			
		||||
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
 | 
			
		||||
void server_context_service_show_keyboard (ServerContextService *context);
 | 
			
		||||
void server_context_service_hide_keyboard (ServerContextService *context);
 | 
			
		||||
void server_context_service_show_keyboard (ServerContextService *self);
 | 
			
		||||
void server_context_service_hide_keyboard (ServerContextService *self);
 | 
			
		||||
void server_context_service_set_enabled (ServerContextService *self, gboolean enabled);
 | 
			
		||||
G_END_DECLS
 | 
			
		||||
#endif  /* SERVER_CONTEXT_SERVICE_H */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,6 @@
 | 
			
		||||
#define __STYLE_H
 | 
			
		||||
#include "gtk/gtk.h"
 | 
			
		||||
 | 
			
		||||
GtkCssProvider *squeek_load_style();
 | 
			
		||||
GtkCssProvider *squeek_load_style(void);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@
 | 
			
		||||
#include "eek/eek-types.h"
 | 
			
		||||
 | 
			
		||||
struct submission;
 | 
			
		||||
struct squeek_layout;
 | 
			
		||||
 | 
			
		||||
struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
 | 
			
		||||
                                  struct zwp_virtual_keyboard_manager_v1 *vkmanager,
 | 
			
		||||
@ -15,5 +16,5 @@ struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager,
 | 
			
		||||
// Defined in Rust
 | 
			
		||||
struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state);
 | 
			
		||||
void submission_set_ui(struct submission *self, ServerContextService *ui_context);
 | 
			
		||||
void submission_set_keyboard(struct submission *self, LevelKeyboard *keyboard);
 | 
			
		||||
void submission_use_layout(struct submission *self, struct squeek_layout *layout, uint32_t time);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,9 @@ use ::action::Modifier;
 | 
			
		||||
use ::imservice;
 | 
			
		||||
use ::imservice::IMService;
 | 
			
		||||
use ::keyboard::{ KeyCode, KeyStateId, Modifiers, PressType };
 | 
			
		||||
use ::layout;
 | 
			
		||||
use ::util::vec_remove;
 | 
			
		||||
use ::vkeyboard;
 | 
			
		||||
use ::vkeyboard::VirtualKeyboard;
 | 
			
		||||
 | 
			
		||||
// traits
 | 
			
		||||
@ -36,7 +38,6 @@ pub mod c {
 | 
			
		||||
    use std::os::raw::c_void;
 | 
			
		||||
 | 
			
		||||
    use ::imservice::c::InputMethod;
 | 
			
		||||
    use ::layout::c::LevelKeyboard;
 | 
			
		||||
    use ::vkeyboard::c::ZwpVirtualKeyboardV1;
 | 
			
		||||
 | 
			
		||||
    // The following defined in C
 | 
			
		||||
@ -68,6 +69,8 @@ pub mod c {
 | 
			
		||||
                modifiers_active: Vec::new(),
 | 
			
		||||
                virtual_keyboard: VirtualKeyboard(vk),
 | 
			
		||||
                pressed: Vec::new(),
 | 
			
		||||
                keymap_fds: Vec::new(),
 | 
			
		||||
                keymap_idx: None,
 | 
			
		||||
            }
 | 
			
		||||
        ))
 | 
			
		||||
    }
 | 
			
		||||
@ -91,18 +94,24 @@ pub mod c {
 | 
			
		||||
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
    fn submission_set_keyboard(submission: *mut Submission, keyboard: LevelKeyboard) {
 | 
			
		||||
    fn submission_use_layout(
 | 
			
		||||
        submission: *mut Submission,
 | 
			
		||||
        layout: *const layout::Layout,
 | 
			
		||||
        time: u32,
 | 
			
		||||
    ) {
 | 
			
		||||
        if submission.is_null() {
 | 
			
		||||
            panic!("Null submission pointer");
 | 
			
		||||
        }
 | 
			
		||||
        let submission: &mut Submission = unsafe { &mut *submission };
 | 
			
		||||
        submission.virtual_keyboard.update_keymap(keyboard);
 | 
			
		||||
        let layout = unsafe { &*layout };
 | 
			
		||||
        submission.use_layout(layout, Timestamp(time));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Copy)]
 | 
			
		||||
pub struct Timestamp(pub u32);
 | 
			
		||||
 | 
			
		||||
#[derive(Clone)]
 | 
			
		||||
enum SubmittedAction {
 | 
			
		||||
    /// A collection of keycodes that were pressed
 | 
			
		||||
    VirtualKeyboard(Vec<KeyCode>),
 | 
			
		||||
@ -114,6 +123,8 @@ pub struct Submission {
 | 
			
		||||
    virtual_keyboard: VirtualKeyboard,
 | 
			
		||||
    modifiers_active: Vec<(KeyStateId, Modifier)>,
 | 
			
		||||
    pressed: Vec<(KeyStateId, SubmittedAction)>,
 | 
			
		||||
    keymap_fds: Vec<vkeyboard::c::KeyMap>,
 | 
			
		||||
    keymap_idx: Option<usize>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub enum SubmitData<'a> {
 | 
			
		||||
@ -172,11 +183,34 @@ impl Submission {
 | 
			
		||||
        let submit_action = match was_committed_as_text {
 | 
			
		||||
            true => SubmittedAction::IMService,
 | 
			
		||||
            false => {
 | 
			
		||||
                self.virtual_keyboard.switch(
 | 
			
		||||
                    keycodes,
 | 
			
		||||
                    PressType::Pressed,
 | 
			
		||||
                    time,
 | 
			
		||||
                );
 | 
			
		||||
                let keycodes_count = keycodes.len();
 | 
			
		||||
                for keycode in keycodes.iter() {
 | 
			
		||||
                    self.select_keymap(keycode.keymap_idx, time);
 | 
			
		||||
                    let keycode = keycode.code;
 | 
			
		||||
                    match keycodes_count {
 | 
			
		||||
                        // Pressing a key made out of a single keycode is simple:
 | 
			
		||||
                        // press on press, release on release.
 | 
			
		||||
                        1 => self.virtual_keyboard.switch(
 | 
			
		||||
                            keycode,
 | 
			
		||||
                            PressType::Pressed,
 | 
			
		||||
                            time,
 | 
			
		||||
                        ),
 | 
			
		||||
                        // A key made of multiple keycodes
 | 
			
		||||
                        // has to submit them one after the other.
 | 
			
		||||
                        _ => {
 | 
			
		||||
                            self.virtual_keyboard.switch(
 | 
			
		||||
                                keycode.clone(),
 | 
			
		||||
                                PressType::Pressed,
 | 
			
		||||
                                time,
 | 
			
		||||
                            );
 | 
			
		||||
                            self.virtual_keyboard.switch(
 | 
			
		||||
                                keycode.clone(),
 | 
			
		||||
                                PressType::Released,
 | 
			
		||||
                                time,
 | 
			
		||||
                            );
 | 
			
		||||
                        },
 | 
			
		||||
                    };
 | 
			
		||||
                }
 | 
			
		||||
                SubmittedAction::VirtualKeyboard(keycodes.clone())
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
@ -194,11 +228,21 @@ impl Submission {
 | 
			
		||||
                // no matter if the imservice got activated,
 | 
			
		||||
                // keys must be released
 | 
			
		||||
                SubmittedAction::VirtualKeyboard(keycodes) => {
 | 
			
		||||
                    self.virtual_keyboard.switch(
 | 
			
		||||
                        &keycodes,
 | 
			
		||||
                        PressType::Released,
 | 
			
		||||
                        time,
 | 
			
		||||
                    )
 | 
			
		||||
                    let keycodes_count = keycodes.len();
 | 
			
		||||
                    match keycodes_count {
 | 
			
		||||
                        1 => {
 | 
			
		||||
                            let keycode = &keycodes[0];
 | 
			
		||||
                            self.select_keymap(keycode.keymap_idx, time);
 | 
			
		||||
                            self.virtual_keyboard.switch(
 | 
			
		||||
                                keycode.code,
 | 
			
		||||
                                PressType::Released,
 | 
			
		||||
                                time,
 | 
			
		||||
                            );
 | 
			
		||||
                        },
 | 
			
		||||
                        // Design choice here: submit multiple all at press time
 | 
			
		||||
                        // and do nothing at release time.
 | 
			
		||||
                        _ => {},
 | 
			
		||||
                    };
 | 
			
		||||
                },
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
@ -243,4 +287,64 @@ impl Submission {
 | 
			
		||||
            self.modifiers_active.iter().map(|(_id, m)| m.clone())
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn clear_all_modifiers(&mut self) {
 | 
			
		||||
        // Looks like an optimization,
 | 
			
		||||
        // but preemptive cleaning is needed before setting a new keymap,
 | 
			
		||||
        // so removing this check would break keymap setting.
 | 
			
		||||
        if self.modifiers_active.is_empty() {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        self.modifiers_active = Vec::new();
 | 
			
		||||
        self.virtual_keyboard.set_modifiers_state(Modifiers::empty())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn release_all_virtual_keys(&mut self, time: Timestamp) {
 | 
			
		||||
        let virtual_pressed = self.pressed
 | 
			
		||||
            .clone().into_iter()
 | 
			
		||||
            .filter_map(|(id, action)| {
 | 
			
		||||
                match action {
 | 
			
		||||
                    SubmittedAction::VirtualKeyboard(_) => Some(id),
 | 
			
		||||
                    _ => None,
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        for id in virtual_pressed {
 | 
			
		||||
            self.handle_release(id, time);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /// Changes keymap and clears pressed keys and modifiers.
 | 
			
		||||
    ///
 | 
			
		||||
    /// It's not obvious if clearing is the right thing to do, 
 | 
			
		||||
    /// but keymap update may (or may not) do that,
 | 
			
		||||
    /// possibly putting self.modifiers_active and self.pressed out of sync,
 | 
			
		||||
    /// so a consistent stance is adopted to avoid that.
 | 
			
		||||
    /// Alternatively, modifiers could be restored on the new keymap.
 | 
			
		||||
    /// That approach might be difficult
 | 
			
		||||
    /// due to modifiers meaning different things in different keymaps.
 | 
			
		||||
    fn select_keymap(&mut self, idx: usize, time: Timestamp) {
 | 
			
		||||
        if self.keymap_idx != Some(idx) {
 | 
			
		||||
            self.keymap_idx = Some(idx);
 | 
			
		||||
            self.clear_all_modifiers();
 | 
			
		||||
            self.release_all_virtual_keys(time);
 | 
			
		||||
            let keymap = &self.keymap_fds[idx];
 | 
			
		||||
            self.virtual_keyboard.update_keymap(keymap);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    pub fn use_layout(&mut self, layout: &layout::Layout, time: Timestamp) {
 | 
			
		||||
        self.keymap_fds = layout.keymaps.iter()
 | 
			
		||||
            .map(|keymap_str| vkeyboard::c::KeyMap::from_cstr(
 | 
			
		||||
                keymap_str.as_c_str()
 | 
			
		||||
            ))
 | 
			
		||||
            .collect();
 | 
			
		||||
        self.keymap_idx = None;
 | 
			
		||||
 | 
			
		||||
        // This can probably be eliminated,
 | 
			
		||||
        // because key presses can trigger an update anyway.
 | 
			
		||||
        // However, self.keymap_idx needs to become Option<>
 | 
			
		||||
        // in order to force update on new layouts.
 | 
			
		||||
        self.select_keymap(0, time);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										99
									
								
								src/tests.rs
									
									
									
									
									
								
							
							
						
						
									
										99
									
								
								src/tests.rs
									
									
									
									
									
								
							@ -26,49 +26,104 @@ impl CountAndPrint {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn check_builtin_layout(name: &str) {
 | 
			
		||||
    check_layout(Layout::from_resource(name).expect("Invalid layout data"))
 | 
			
		||||
pub fn check_builtin_layout(name: &str, missing_return: bool) {
 | 
			
		||||
    check_layout(
 | 
			
		||||
        Layout::from_resource(name).expect("Invalid layout data"),
 | 
			
		||||
        missing_return,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn check_layout_file(path: &str) {
 | 
			
		||||
    check_layout(Layout::from_file(path.into()).expect("Invalid layout file"))
 | 
			
		||||
    check_layout(
 | 
			
		||||
        Layout::from_file(path.into()).expect("Invalid layout file"),
 | 
			
		||||
        false,
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn check_layout(layout: Layout) {
 | 
			
		||||
fn check_sym_in_keymap(state: &xkb::State, sym_name: &str) -> bool {
 | 
			
		||||
    let sym = xkb::keysym_from_name(sym_name, xkb::KEYSYM_NO_FLAGS);
 | 
			
		||||
    if sym == xkb::KEY_NoSymbol {
 | 
			
		||||
        panic!(format!("Entered invalid keysym: {}", sym_name));
 | 
			
		||||
    }
 | 
			
		||||
    let map = state.get_keymap();
 | 
			
		||||
    let range = map.min_keycode()..=map.max_keycode();
 | 
			
		||||
    range.flat_map(|code| state.key_get_syms(code))
 | 
			
		||||
        .find(|s| **s == sym)
 | 
			
		||||
        .is_some()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn check_sym_presence(
 | 
			
		||||
    states: &[xkb::State],
 | 
			
		||||
    sym_name: &str,
 | 
			
		||||
    handler: &mut dyn logging::Handler,
 | 
			
		||||
) {
 | 
			
		||||
    let found = states.iter()
 | 
			
		||||
        .position(|state| {
 | 
			
		||||
            check_sym_in_keymap(&state, sym_name)
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    if let None = found {
 | 
			
		||||
        handler.handle(
 | 
			
		||||
            logging::Level::Surprise,
 | 
			
		||||
            &format!("There's no way to input the keysym {} on this layout", sym_name),
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn check_layout(layout: Layout, allow_missing_return: bool) {
 | 
			
		||||
    let handler = CountAndPrint::new();
 | 
			
		||||
    let (layout, handler) = layout.build(handler);
 | 
			
		||||
    let (layout, mut handler) = layout.build(handler);
 | 
			
		||||
 | 
			
		||||
    if handler.0 > 0 {
 | 
			
		||||
        println!("{} problems while parsing layout", handler.0)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let layout = layout.expect("layout broken");
 | 
			
		||||
    
 | 
			
		||||
    let xkb_states: Vec<xkb::State> = layout.keymaps.iter()
 | 
			
		||||
        .map(|keymap_str| {
 | 
			
		||||
            let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
 | 
			
		||||
            let keymap_str = keymap_str
 | 
			
		||||
                .clone()
 | 
			
		||||
                .into_string().expect("Failed to decode keymap string");
 | 
			
		||||
            let keymap = xkb::Keymap::new_from_string(
 | 
			
		||||
                &context,
 | 
			
		||||
                keymap_str.clone(),
 | 
			
		||||
                xkb::KEYMAP_FORMAT_TEXT_V1,
 | 
			
		||||
                xkb::KEYMAP_COMPILE_NO_FLAGS,
 | 
			
		||||
            ).expect("Failed to create keymap");
 | 
			
		||||
            xkb::State::new(&keymap)
 | 
			
		||||
        })
 | 
			
		||||
        .collect();
 | 
			
		||||
 | 
			
		||||
    let context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
 | 
			
		||||
    
 | 
			
		||||
    let keymap_str = layout.keymap_str
 | 
			
		||||
        .clone()
 | 
			
		||||
        .into_string().expect("Failed to decode keymap string");
 | 
			
		||||
    
 | 
			
		||||
    let keymap = xkb::Keymap::new_from_string(
 | 
			
		||||
        &context,
 | 
			
		||||
        keymap_str.clone(),
 | 
			
		||||
        xkb::KEYMAP_FORMAT_TEXT_V1,
 | 
			
		||||
        xkb::KEYMAP_COMPILE_NO_FLAGS,
 | 
			
		||||
    ).expect("Failed to create keymap");
 | 
			
		||||
    check_sym_presence(&xkb_states, "BackSpace", &mut handler);
 | 
			
		||||
    let mut printer = logging::Print;
 | 
			
		||||
    check_sym_presence(
 | 
			
		||||
        &xkb_states,
 | 
			
		||||
        "Return",
 | 
			
		||||
        if allow_missing_return { &mut printer }
 | 
			
		||||
        else { &mut handler },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    let state = xkb::State::new(&keymap);
 | 
			
		||||
    
 | 
			
		||||
    // "Press" each button with keysyms
 | 
			
		||||
    for (_pos, view) in layout.views.values() {
 | 
			
		||||
        for (_y, row) in &view.get_rows() {
 | 
			
		||||
            for (_x, button) in &row.buttons {
 | 
			
		||||
                let keystate = button.state.borrow();
 | 
			
		||||
                for keycode in &keystate.keycodes {
 | 
			
		||||
                    match state.key_get_one_sym(*keycode) {
 | 
			
		||||
                    match xkb_states[keycode.keymap_idx].key_get_one_sym(keycode.code) {
 | 
			
		||||
                        xkb::KEY_NoSymbol => {
 | 
			
		||||
                            eprintln!("{}", keymap_str);
 | 
			
		||||
                            panic!("Keysym {} on key {:?} can't be resolved", keycode, button.name);
 | 
			
		||||
                            eprintln!(
 | 
			
		||||
                                "keymap {}: {}",
 | 
			
		||||
                                keycode.keymap_idx,
 | 
			
		||||
                                layout.keymaps[keycode.keymap_idx].to_str().unwrap(),
 | 
			
		||||
                            );
 | 
			
		||||
                            panic!(
 | 
			
		||||
                                "Keysym for code {:?} on key {} ({:?}) can't be resolved",
 | 
			
		||||
                                keycode,
 | 
			
		||||
                                button.name.to_string_lossy(),
 | 
			
		||||
                                button.name,
 | 
			
		||||
                            );
 | 
			
		||||
                        },
 | 
			
		||||
                        _ => {},
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@
 | 
			
		||||
 | 
			
		||||
struct ui_manager;
 | 
			
		||||
 | 
			
		||||
struct ui_manager *squeek_uiman_new();
 | 
			
		||||
struct ui_manager *squeek_uiman_new(void);
 | 
			
		||||
void squeek_uiman_set_output(struct ui_manager *uiman, struct squeek_output_handle output);
 | 
			
		||||
uint32_t squeek_uiman_get_perceptual_height(struct ui_manager *uiman);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								src/util.rs
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/util.rs
									
									
									
									
									
								
							@ -203,6 +203,23 @@ pub fn vec_remove<T, F: FnMut(&T) -> bool>(v: &mut Vec<T>, pred: F) -> Option<T>
 | 
			
		||||
    idx.map(|idx| v.remove(idx))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Repeats all the items of the iterator forever,
 | 
			
		||||
/// but returns the cycle number alongside.
 | 
			
		||||
/// Inefficient due to all the vectors, but doesn't have to be fast.
 | 
			
		||||
pub fn cycle_count<T, I: Clone + Iterator<Item=T>>(iter: I)
 | 
			
		||||
    -> impl Iterator<Item=(T, usize)>
 | 
			
		||||
{
 | 
			
		||||
    let numbered_copies = vec![iter].into_iter()
 | 
			
		||||
        .cycle()
 | 
			
		||||
        .enumerate();
 | 
			
		||||
    numbered_copies.flat_map(|(idx, cycle)|
 | 
			
		||||
        // Pair each element from the cycle with a copy of the index.
 | 
			
		||||
        cycle.zip(
 | 
			
		||||
            vec![idx].into_iter().cycle() // Repeat the index forever.
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod tests {
 | 
			
		||||
    use super::*;
 | 
			
		||||
@ -217,4 +234,12 @@ mod tests {
 | 
			
		||||
        assert_eq!(s.insert(Pointer(Rc::new(2u32))), true);
 | 
			
		||||
        assert_eq!(s.remove(&Pointer(first)), true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn check_count() {
 | 
			
		||||
        assert_eq!(
 | 
			
		||||
            cycle_count(5..8).take(7).collect::<Vec<_>>(),
 | 
			
		||||
            vec![(5, 0), (6, 0), (7, 0), (5, 1), (6, 1), (7, 1), (5, 2)]
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,18 +1,42 @@
 | 
			
		||||
/*! Managing the events belonging to virtual-keyboard interface. */
 | 
			
		||||
 | 
			
		||||
use ::keyboard::{ KeyCode, Modifiers, PressType };
 | 
			
		||||
use ::layout::c::LevelKeyboard;
 | 
			
		||||
use ::keyboard::{ Modifiers, PressType };
 | 
			
		||||
use ::submission::Timestamp;
 | 
			
		||||
 | 
			
		||||
/// Standard xkb keycode
 | 
			
		||||
type KeyCode = u32;
 | 
			
		||||
 | 
			
		||||
/// Gathers stuff defined in C or called by C
 | 
			
		||||
pub mod c {
 | 
			
		||||
    use super::*;
 | 
			
		||||
    use std::os::raw::c_void;
 | 
			
		||||
    use std::ffi::CStr;
 | 
			
		||||
    use std::os::raw::{ c_char, c_void };
 | 
			
		||||
 | 
			
		||||
    #[repr(transparent)]
 | 
			
		||||
    #[derive(Clone, Copy)]
 | 
			
		||||
    pub struct ZwpVirtualKeyboardV1(*const c_void);
 | 
			
		||||
 | 
			
		||||
    #[repr(C)]
 | 
			
		||||
    pub struct KeyMap {
 | 
			
		||||
        fd: u32,
 | 
			
		||||
        fd_len: usize,
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    impl KeyMap {
 | 
			
		||||
        pub fn from_cstr(s: &CStr) -> KeyMap {
 | 
			
		||||
            unsafe {
 | 
			
		||||
                eek_key_map_from_str(s.as_ptr())
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    impl Drop for KeyMap {
 | 
			
		||||
        fn drop(&mut self) {
 | 
			
		||||
            unsafe {
 | 
			
		||||
                eek_key_map_deinit(self as *mut KeyMap);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    extern "C" {
 | 
			
		||||
        pub fn eek_virtual_keyboard_v1_key(
 | 
			
		||||
@ -24,13 +48,16 @@ pub mod c {
 | 
			
		||||
 | 
			
		||||
        pub fn eek_virtual_keyboard_update_keymap(
 | 
			
		||||
            virtual_keyboard: ZwpVirtualKeyboardV1,
 | 
			
		||||
            keyboard: LevelKeyboard,
 | 
			
		||||
            keymap: *const KeyMap,
 | 
			
		||||
        );
 | 
			
		||||
        
 | 
			
		||||
        pub fn eek_virtual_keyboard_set_modifiers(
 | 
			
		||||
            virtual_keyboard: ZwpVirtualKeyboardV1,
 | 
			
		||||
            modifiers: u32,
 | 
			
		||||
        );
 | 
			
		||||
        
 | 
			
		||||
        pub fn eek_key_map_from_str(keymap_str: *const c_char) -> KeyMap;
 | 
			
		||||
        pub fn eek_key_map_deinit(keymap: *mut KeyMap);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -41,35 +68,15 @@ impl VirtualKeyboard {
 | 
			
		||||
    // TODO: error out if keymap not set
 | 
			
		||||
    pub fn switch(
 | 
			
		||||
        &self,
 | 
			
		||||
        keycodes: &Vec<KeyCode>,
 | 
			
		||||
        keycode: KeyCode,
 | 
			
		||||
        action: PressType,
 | 
			
		||||
        timestamp: Timestamp,
 | 
			
		||||
    ) {
 | 
			
		||||
        let keycodes_count = keycodes.len();
 | 
			
		||||
        for keycode in keycodes.iter() {
 | 
			
		||||
            let keycode = keycode - 8;
 | 
			
		||||
            match (action, keycodes_count) {
 | 
			
		||||
                // Pressing a key made out of a single keycode is simple:
 | 
			
		||||
                // press on press, release on release.
 | 
			
		||||
                (_, 1) => unsafe {
 | 
			
		||||
                    c::eek_virtual_keyboard_v1_key(
 | 
			
		||||
                        self.0, timestamp.0, keycode, action.clone() as u32
 | 
			
		||||
                    );
 | 
			
		||||
                },
 | 
			
		||||
                // A key made of multiple keycodes
 | 
			
		||||
                // has to submit them one after the other
 | 
			
		||||
                (PressType::Pressed, _) => unsafe {
 | 
			
		||||
                    c::eek_virtual_keyboard_v1_key(
 | 
			
		||||
                        self.0, timestamp.0, keycode, PressType::Pressed as u32
 | 
			
		||||
                    );
 | 
			
		||||
                    c::eek_virtual_keyboard_v1_key(
 | 
			
		||||
                        self.0, timestamp.0, keycode, PressType::Released as u32
 | 
			
		||||
                    );
 | 
			
		||||
                },
 | 
			
		||||
                // Design choice here: submit multiple all at press time
 | 
			
		||||
                // and do nothing at release time
 | 
			
		||||
                (PressType::Released, _) => {},
 | 
			
		||||
            }
 | 
			
		||||
        let keycode = keycode - 8;
 | 
			
		||||
        unsafe {
 | 
			
		||||
            c::eek_virtual_keyboard_v1_key(
 | 
			
		||||
                self.0, timestamp.0, keycode, action.clone() as u32
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@ -80,9 +87,12 @@ impl VirtualKeyboard {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    pub fn update_keymap(&self, keyboard: LevelKeyboard) {
 | 
			
		||||
    pub fn update_keymap(&self, keymap: &c::KeyMap) {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            c::eek_virtual_keyboard_update_keymap(self.0, keyboard);
 | 
			
		||||
            c::eek_virtual_keyboard_update_keymap(
 | 
			
		||||
                self.0,
 | 
			
		||||
                keymap as *const c::KeyMap,
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,10 +14,10 @@ eek_virtual_keyboard_v1_key(struct zwp_virtual_keyboard_v1 *zwp_virtual_keyboard
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void eek_virtual_keyboard_update_keymap(struct zwp_virtual_keyboard_v1 *zwp_virtual_keyboard_v1, const LevelKeyboard *keyboard) {
 | 
			
		||||
void eek_virtual_keyboard_update_keymap(struct zwp_virtual_keyboard_v1 *zwp_virtual_keyboard_v1, struct KeyMap *keymap) {
 | 
			
		||||
    zwp_virtual_keyboard_v1_keymap(zwp_virtual_keyboard_v1,
 | 
			
		||||
        WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
 | 
			
		||||
        keyboard->keymap_fd, keyboard->keymap_len);
 | 
			
		||||
        keymap->fd, keymap->fd_len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								tests/layout_erase.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								tests/layout_erase.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
---
 | 
			
		||||
# Erase only
 | 
			
		||||
views:
 | 
			
		||||
    base:
 | 
			
		||||
        - "BackSpace"
 | 
			
		||||
outlines:
 | 
			
		||||
    default: { width: 0, height: 0 }
 | 
			
		||||
buttons:
 | 
			
		||||
    BackSpace:
 | 
			
		||||
        action: erase
 | 
			
		||||
@ -50,6 +50,7 @@ endforeach
 | 
			
		||||
foreach layout : [
 | 
			
		||||
    'us', 'us_wide',
 | 
			
		||||
    'br',
 | 
			
		||||
    'be',
 | 
			
		||||
    'de', 'de_wide',
 | 
			
		||||
    'dk',
 | 
			
		||||
    'es',
 | 
			
		||||
@ -63,15 +64,22 @@ foreach layout : [
 | 
			
		||||
    'pl', 'pl_wide',
 | 
			
		||||
    'ru',
 | 
			
		||||
    'se',
 | 
			
		||||
    'ua',
 | 
			
		||||
    'terminal',
 | 
			
		||||
    
 | 
			
		||||
    'emoji',
 | 
			
		||||
]
 | 
			
		||||
    extra = []
 | 
			
		||||
    if layout == 'emoji'
 | 
			
		||||
        extra += ['allow_missing_return']
 | 
			
		||||
    endif
 | 
			
		||||
 | 
			
		||||
    test(
 | 
			
		||||
        'test_layout_' + layout,
 | 
			
		||||
        cargo_script,
 | 
			
		||||
        args: ['run'] + cargo_build_flags
 | 
			
		||||
            + [ '--example', 'test_layout', '--', layout],
 | 
			
		||||
            + ['--example', 'test_layout', '--', layout]
 | 
			
		||||
            + extra,
 | 
			
		||||
        workdir: meson.build_root(),
 | 
			
		||||
    )
 | 
			
		||||
endforeach
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user