From cf09d1b3bcd801a0cd7b92fada39e0178e418fe4 Mon Sep 17 00:00:00 2001 From: clonex10100 Date: Mon, 2 Nov 2020 13:27:27 -0500 Subject: [PATCH 01/51] Added US Colemak Keyboard Layout --- data/keyboards/us+colemak.yaml | 78 ++++++++++++++++++++++++++++++++++ src/resources.rs | 1 + tests/meson.build | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 data/keyboards/us+colemak.yaml diff --git a/data/keyboards/us+colemak.yaml b/data/keyboards/us+colemak.yaml new file mode 100644 index 00000000..59d71d96 --- /dev/null +++ b/data/keyboards/us+colemak.yaml @@ -0,0 +1,78 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "q w f p g j l u y" + - "a r s t d h n e i o" + - "Shift_L z x c v b k m BackSpace" + - "show_numbers preferences space period Return" + upper: + - "Q W F P G J L U Y" + - "A R S T D H N E I O" + - "Shift_L Z X C V B K M BackSpace" + - "show_numbers preferences space period Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences space period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/src/resources.rs b/src/resources.rs index 2d21595b..e23b9d2a 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -14,6 +14,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ // layouts: us must be left as first, as it is the, // fallback layout. The others should be alphabetical. ("us", include_str!("../data/keyboards/us.yaml")), + ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), ("us_wide", include_str!("../data/keyboards/us_wide.yaml")), ("br", include_str!("../data/keyboards/br.yaml")), ("de", include_str!("../data/keyboards/de.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 96229297..ae7a332a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -48,7 +48,7 @@ endforeach # due to the way Cargo builds executables # and the need to call it manually foreach layout : [ - 'us', 'us_wide', + 'us', 'us+colemak', 'us_wide', 'br', 'be', 'be_wide', 'de', 'de_wide', From 17db3db29668a4c28f57350279ff077d45360fc2 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 19 Nov 2020 09:48:23 +0000 Subject: [PATCH 02/51] visibility: Centralize keyboard panel visibility policy and handling With the policy being disentangled from application, it becomes testable. This prepares for moving the entire visibility mechanism to the new class and taking away more pieces of ServerContextService. In addition, this is a good warmup before trying to implement sizing policy. --- src/imservice.c | 3 +- src/imservice.rs | 37 ++------ src/server-context-service.c | 43 ++++----- src/server-context-service.h | 3 +- src/server-main.c | 11 ++- src/submission.h | 4 +- src/submission.rs | 33 +++---- src/ui_manager.h | 6 ++ src/ui_manager.rs | 170 ++++++++++++++++++++++++++++++++++- 9 files changed, 223 insertions(+), 87 deletions(-) diff --git a/src/imservice.c b/src/imservice.c index b6b04784..25dc65e4 100644 --- a/src/imservice.c +++ b/src/imservice.c @@ -25,6 +25,7 @@ static const struct zwp_input_method_v2_listener input_method_listener = { struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager, struct zwp_virtual_keyboard_manager_v1 *vkmanager, + struct vis_manager *vis_manager, struct wl_seat *seat, EekboardContextService *state) { struct zwp_input_method_v2 *im = NULL; @@ -35,7 +36,7 @@ struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager, if (vkmanager) { vk = zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(vkmanager, seat); } - return submission_new(im, vk, state); + return submission_new(im, vk, state, vis_manager); } /// Un-inlined diff --git a/src/imservice.rs b/src/imservice.rs index a25edd5e..462c4203 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -6,7 +6,6 @@ use std::boxed::Box; use std::ffi::CString; use std::fmt; -use std::mem; use std::num::Wrapping; use std::string::String; @@ -24,7 +23,7 @@ pub mod c { use std::os::raw::{c_char, c_void}; - pub use ::submission::c::UIManager; + pub use ::ui_manager::c::UIManager; pub use ::submission::c::StateManager; // The following defined in C @@ -42,8 +41,6 @@ pub mod c { pub fn eek_input_method_delete_surrounding_text(im: *mut InputMethod, before: u32, after: u32); pub fn eek_input_method_commit(im: *mut InputMethod, serial: u32); fn eekboard_context_service_set_hint_purpose(state: *const StateManager, hint: u32, purpose: u32); - pub fn server_context_service_set_im_active(imservice: *const UIManager, active: u32); - pub fn server_context_service_keyboard_release_visibility(imservice: *const UIManager); } // The following defined in Rust. TODO: wrap naked pointers to Rust data inside RefCells to prevent multiple writers @@ -153,7 +150,7 @@ pub mod c { }; if active_changed { - imservice.apply_active_to_ui(); + (imservice.active_callback)(imservice.current.active); if imservice.current.active { unsafe { eekboard_context_service_set_hint_purpose( @@ -179,9 +176,7 @@ pub mod c { // the keyboard is already decommissioned imservice.current.active = false; - if let Some(ui) = imservice.ui_manager { - unsafe { server_context_service_keyboard_release_visibility(ui); } - } + (imservice.active_callback)(imservice.current.active); } // FIXME: destroy and deallocate @@ -334,8 +329,7 @@ pub struct IMService { pub im: *mut c::InputMethod, /// Unowned reference. Be careful, it's shared with C at large state_manager: *const c::StateManager, - /// Unowned reference. Be careful, it's shared with C at large - ui_manager: Option<*const c::UIManager>, + active_callback: Box, pending: IMProtocolState, current: IMProtocolState, // turn current into an idiomatic representation? @@ -352,12 +346,13 @@ impl IMService { pub fn new( im: *mut c::InputMethod, state_manager: *const c::StateManager, + active_callback: Box, ) -> Box { // IMService will be referenced to by C, // so it needs to stay in the same place in memory via Box let imservice = Box::new(IMService { im, - ui_manager: None, + active_callback, state_manager, pending: IMProtocolState::default(), current: IMProtocolState::default(), @@ -373,26 +368,6 @@ impl IMService { imservice } - pub fn set_ui_manager(&mut self, mut ui_manager: Option<*const c::UIManager>) { - mem::swap(&mut self.ui_manager, &mut ui_manager); - // Now ui_manager is what was previously self.ui_manager. - // If there wasn't any, we need to consider if UI was requested. - if let None = ui_manager { - self.apply_active_to_ui(); - } - } - - fn apply_active_to_ui(&self) { - if let Some(ui) = self.ui_manager { - unsafe { - c::server_context_service_set_im_active( - ui, - self.is_active() as u32, - ); - } - } - } - pub fn commit_string(&self, text: &CString) -> Result<(), SubmitError> { match self.current.active { true => { diff --git a/src/server-context-service.c b/src/server-context-service.c index 6923ab0b..44364aec 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -43,10 +43,9 @@ struct _ServerContextService { struct submission *submission; // unowned struct squeek_layout_state *layout; struct ui_manager *manager; // unowned + struct vis_manager *vis_manager; // owned gboolean visible; - gboolean enabled; - gboolean im_active; PhoshLayerSurface *window; GtkWidget *widget; // nullable guint hiding; @@ -288,7 +287,7 @@ server_context_service_hide_keyboard (ServerContextService *self) /// In this case, the user doesn't really need the keyboard surface /// to disappear completely. void -server_context_service_keyboard_release_visibility (ServerContextService *self) +server_context_service_release_visibility (ServerContextService *self) { g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self)); @@ -297,6 +296,13 @@ server_context_service_keyboard_release_visibility (ServerContextService *self) } } +static void +server_context_service_set_physical_keyboard_present (ServerContextService *self, gboolean physical_keyboard_present) +{ + g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self)); + squeek_visman_set_keyboard_present(self->vis_manager, physical_keyboard_present); +} + static void server_context_service_set_property (GObject *object, guint prop_id, @@ -310,7 +316,7 @@ server_context_service_set_property (GObject *object, self->visible = g_value_get_boolean (value); break; case PROP_ENABLED: - server_context_service_set_enabled (self, g_value_get_boolean (value)); + server_context_service_set_physical_keyboard_present (self, !g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -385,12 +391,14 @@ server_context_service_class_init (ServerContextServiceClass *klass) } static void -server_context_service_init (ServerContextService *self) { +server_context_service_init (ServerContextService *self) {} + +static void +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; @@ -407,37 +415,24 @@ server_context_service_init (ServerContextService *self) { } ServerContextService * -server_context_service_new (EekboardContextService *self, 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, struct vis_manager *visman) { ServerContextService *ui = g_object_new (SERVER_TYPE_CONTEXT_SERVICE, NULL); ui->submission = submission; ui->state = self; ui->layout = layout; ui->manager = uiman; + ui->vis_manager = visman; + init(ui); return ui; } void -server_context_service_update_visible (ServerContextService *self, gboolean delay) { - if (self->enabled && self->im_active) { +server_context_service_update_visible (ServerContextService *self, gboolean visible) { + if (visible) { server_context_service_show_keyboard(self); - } else if (delay) { - server_context_service_keyboard_release_visibility(self); } else { server_context_service_hide_keyboard(self); } } -void -server_context_service_set_enabled (ServerContextService *self, gboolean enabled) -{ - g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self)); - self->enabled = enabled; - server_context_service_update_visible(self, FALSE); -} - -void -server_context_service_set_im_active(ServerContextService *self, uint32_t active) { - self->im_active = active; - server_context_service_update_visible(self, TRUE); -} diff --git a/src/server-context-service.h b/src/server-context-service.h index a091d0f9..99aca139 100644 --- a/src/server-context-service.h +++ b/src/server-context-service.h @@ -29,11 +29,10 @@ G_BEGIN_DECLS /** Manages the lifecycle of the window displaying layouts. */ G_DECLARE_FINAL_TYPE (ServerContextService, server_context_service, SERVER, CONTEXT_SERVICE, GObject) -ServerContextService *server_context_service_new(EekboardContextService *self, 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, struct vis_manager *visman); enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *); 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 */ diff --git a/src/server-main.c b/src/server-main.c index 6149df5b..d199acab 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -277,8 +277,11 @@ main (int argc, char **argv) } } + struct vis_manager *vis_manager = squeek_visman_new(); + instance.submission = get_submission(instance.wayland.input_method_manager, instance.wayland.virtual_keyboard_manager, + vis_manager, instance.wayland.seat, instance.settings_context); @@ -288,15 +291,15 @@ main (int argc, char **argv) instance.settings_context, instance.submission, &instance.layout_choice, - instance.ui_manager); + instance.ui_manager, + vis_manager); if (!ui_context) { g_error("Could not initialize GUI"); exit(1); } instance.ui_context = ui_context; - if (instance.submission) { - submission_set_ui(instance.submission, instance.ui_context); - } + squeek_visman_set_ui(vis_manager, instance.ui_context); + if (instance.dbus_handler) { dbus_handler_set_ui_context(instance.dbus_handler, instance.ui_context); } diff --git a/src/submission.h b/src/submission.h index acb20323..49a15116 100644 --- a/src/submission.h +++ b/src/submission.h @@ -4,17 +4,19 @@ #include "input-method-unstable-v2-client-protocol.h" #include "virtual-keyboard-unstable-v1-client-protocol.h" #include "eek/eek-types.h" +#include "src/ui_manager.h" struct submission; struct squeek_layout; struct submission* get_submission(struct zwp_input_method_manager_v2 *immanager, struct zwp_virtual_keyboard_manager_v1 *vkmanager, + struct vis_manager *vis_manager, struct wl_seat *seat, EekboardContextService *state); // Defined in Rust -struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state); +struct submission* submission_new(struct zwp_input_method_v2 *im, struct zwp_virtual_keyboard_v1 *vk, EekboardContextService *state, struct vis_manager *vis_manager); void submission_set_ui(struct submission *self, ServerContextService *ui_context); void submission_use_layout(struct submission *self, struct squeek_layout *layout, uint32_t time); #endif diff --git a/src/submission.rs b/src/submission.rs index c256de04..f64810f8 100644 --- a/src/submission.rs +++ b/src/submission.rs @@ -24,6 +24,7 @@ use ::imservice; use ::imservice::IMService; use ::keyboard::{ KeyCode, KeyStateId, Modifiers, PressType }; use ::layout; +use ::ui_manager::VisibilityManager; use ::util::vec_remove; use ::vkeyboard; use ::vkeyboard::VirtualKeyboard; @@ -38,14 +39,11 @@ pub mod c { use std::os::raw::c_void; use ::imservice::c::InputMethod; + use ::util::c::Wrapped; use ::vkeyboard::c::ZwpVirtualKeyboardV1; // The following defined in C - /// ServerContextService* - #[repr(transparent)] - pub struct UIManager(*const c_void); - /// EekboardContextService* #[repr(transparent)] pub struct StateManager(*const c_void); @@ -55,12 +53,18 @@ pub mod c { fn submission_new( im: *mut InputMethod, vk: ZwpVirtualKeyboardV1, - state_manager: *const StateManager + state_manager: *const StateManager, + visibility_manager: Wrapped, ) -> *mut Submission { let imservice = if im.is_null() { None } else { - Some(IMService::new(im, state_manager)) + let visibility_manager = visibility_manager.clone_ref(); + Some(IMService::new( + im, + state_manager, + Box::new(move |active| visibility_manager.borrow_mut().set_im_active(active)), + )) }; // TODO: add vkeyboard too Box::::into_raw(Box::new( @@ -75,23 +79,6 @@ pub mod c { )) } - /// Use to initialize the UI reference - #[no_mangle] - pub extern "C" - fn submission_set_ui(submission: *mut Submission, ui_manager: *const UIManager) { - if submission.is_null() { - panic!("Null submission pointer"); - } - let submission: &mut Submission = unsafe { &mut *submission }; - if let Some(ref mut imservice) = &mut submission.imservice { - imservice.set_ui_manager(if ui_manager.is_null() { - None - } else { - Some(ui_manager) - }) - }; - } - #[no_mangle] pub extern "C" fn submission_use_layout( diff --git a/src/ui_manager.h b/src/ui_manager.h index b0c64592..0f95e2e4 100644 --- a/src/ui_manager.h +++ b/src/ui_manager.h @@ -3,6 +3,7 @@ #include +#include "eek/eek-types.h" #include "outputs.h" struct ui_manager; @@ -11,4 +12,9 @@ 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); +struct vis_manager; + +struct vis_manager *squeek_visman_new(void); +void squeek_visman_set_ui(struct vis_manager *visman, ServerContextService *ui_context); +void squeek_visman_set_keyboard_present(struct vis_manager *visman, uint32_t keyboard_present); #endif diff --git a/src/ui_manager.rs b/src/ui_manager.rs index c7af6521..a9196c1b 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -10,9 +10,49 @@ use std::cmp::min; use ::outputs::c::OutputHandle; -mod c { +pub mod c { use super::*; + use std::os::raw::c_void; use ::util::c::Wrapped; + + /// ServerContextService* + #[repr(transparent)] + pub struct UIManager(*const c_void); + + #[no_mangle] + extern "C" { + pub fn server_context_service_update_visible(imservice: *const UIManager, active: u32); + pub fn server_context_service_release_visibility(imservice: *const UIManager); + } + + #[no_mangle] + pub extern "C" + fn squeek_visman_new() -> Wrapped { + Wrapped::new(VisibilityManager { + ui_manager: None, + visibility_state: VisibilityFactors { + im_active: false, + physical_keyboard_present: false, + } + }) + } + + /// Use to initialize the UI reference + #[no_mangle] + pub extern "C" + fn squeek_visman_set_ui(visman: Wrapped, ui_manager: *const UIManager) { + let visman = visman.clone_ref(); + let mut visman = visman.borrow_mut(); + visman.set_ui_manager(Some(ui_manager)) + } + + #[no_mangle] + pub extern "C" + fn squeek_visman_set_keyboard_present(visman: Wrapped, present: u32) { + let visman = visman.clone_ref(); + let mut visman = visman.borrow_mut(); + visman.set_keyboard_present(present != 0) + } #[no_mangle] pub extern "C" @@ -79,3 +119,131 @@ impl Manager { } } } + +#[derive(PartialEq, Debug)] +enum Visibility { + Hidden, + Visible, +} + +#[derive(Debug)] +enum VisibilityTransition { + /// Hide immediately + Hide, + /// Hide if no show request comes soon + Release, + /// Show instantly + Show, + /// Don't do anything + NoTransition, +} + +/// Contains visibility policy +#[derive(Clone, Debug)] +struct VisibilityFactors { + im_active: bool, + physical_keyboard_present: bool, +} + +impl VisibilityFactors { + /// Static policy. + /// Use when transitioning from an undefined state (e.g. no UI before). + fn desired(&self) -> Visibility { + match self { + VisibilityFactors { + im_active: true, + physical_keyboard_present: false, + } => Visibility::Visible, + _ => Visibility::Hidden, + } + } + /// Stateful policy + fn transition_to(&self, next: &Self) -> VisibilityTransition { + use self::Visibility::*; + let im_deactivation = self.im_active && !next.im_active; + match (self.desired(), next.desired(), im_deactivation) { + (Visible, Hidden, true) => VisibilityTransition::Release, + (Visible, Hidden, _) => VisibilityTransition::Hide, + (Hidden, Visible, _) => VisibilityTransition::Show, + _ => VisibilityTransition::NoTransition, + } + } +} + +// Temporary struct for migration. Should be integrated with Manager eventually. +pub struct VisibilityManager { + /// Owned reference. Be careful, it's shared with C at large + ui_manager: Option<*const c::UIManager>, + visibility_state: VisibilityFactors, +} + +impl VisibilityManager { + fn set_ui_manager(&mut self, ui_manager: Option<*const c::UIManager>) { + let new = VisibilityManager { + ui_manager, + ..unsafe { self.clone() } + }; + self.apply_changes(new); + } + + fn apply_changes(&mut self, new: Self) { + if let Some(ui) = &new.ui_manager { + if self.ui_manager.is_none() { + // Previous state was never applied, so effectively undefined. + // Just apply the new one. + let new_state = new.visibility_state.desired(); + unsafe { + c::server_context_service_update_visible( + *ui, + (new_state == Visibility::Visible) as u32, + ); + } + } else { + match self.visibility_state.transition_to(&new.visibility_state) { + VisibilityTransition::Hide => unsafe { + c::server_context_service_update_visible(*ui, 0); + }, + VisibilityTransition::Show => unsafe { + c::server_context_service_update_visible(*ui, 1); + }, + VisibilityTransition::Release => unsafe { + c::server_context_service_release_visibility(*ui); + }, + VisibilityTransition::NoTransition => {} + } + } + } + *self = new; + } + + pub fn set_im_active(&mut self, im_active: bool) { + let new = VisibilityManager { + visibility_state: VisibilityFactors { + im_active, + ..self.visibility_state.clone() + }, + ..unsafe { self.clone() } + }; + self.apply_changes(new); + } + + pub fn set_keyboard_present(&mut self, keyboard_present: bool) { + let new = VisibilityManager { + visibility_state: VisibilityFactors { + physical_keyboard_present: keyboard_present, + ..self.visibility_state.clone() + }, + ..unsafe { self.clone() } + }; + self.apply_changes(new); + } + + /// The struct is not really safe to clone due to the ui_manager reference. + /// This is only a helper for getting desired visibility. + unsafe fn clone(&self) -> Self { + VisibilityManager { + ui_manager: self.ui_manager.clone(), + visibility_state: self.visibility_state.clone(), + } + } +} From df8e88598317905fb6da3a1dbe777bfa0de5523e Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 28 Nov 2020 17:18:09 +0000 Subject: [PATCH 03/51] build: Fix release --- cargo_build.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ cargo_build.sh | 34 ---------------------------------- debian/control | 1 + meson.build | 2 +- 4 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 cargo_build.py delete mode 100755 cargo_build.sh diff --git a/cargo_build.py b/cargo_build.py new file mode 100644 index 00000000..d78ceb9e --- /dev/null +++ b/cargo_build.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +"""This script manages Cargo builds +while keeping the artifact directory within the build tree +instead of the source tree. +""" + +from pathlib import Path +import shlex +import subprocess +import sys + +source_dir = Path(__file__).absolute().parent + +args = sys.argv[1:] +binary_dir = "debug" + +if '--release' in args: + binary_dir = "release" + +# The file produced by Cargo will have a special name +try: + i = args.index('--rename') +except ValueError: + filename = None +else: + args.pop(i) + filename = args.pop(i) + +# The target destination of the produced file is a positional argument +out_path = [arg for arg in args if not arg.startswith('--')] +if out_path: + out_path = out_path[0] + i = args.index(out_path) + args.pop(i) + +subprocess.run(['sh', "{}/cargo.sh".format(shlex.quote(source_dir.as_posix())), 'build'] + + args, + check=True) + +if out_path: + out_path = Path(out_path).absolute() + out_basename = out_path.name + filename = filename or out_basename + subprocess.run(['cp', '-a', + './{}/{}'.format(shlex.quote(binary_dir), shlex.quote(filename)), + out_path], + check=True) + diff --git a/cargo_build.sh b/cargo_build.sh deleted file mode 100755 index 840bc1c6..00000000 --- a/cargo_build.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# This script manages Cargo builds -# while keeping the artifact directory within the build tree -# instead of the source tree - -set -e - -SCRIPT_PATH="$(realpath "$0")" -SOURCE_DIR="$(dirname "$SCRIPT_PATH")" - -RELEASE="" -BINARY_DIR="debug" -if [ "${1}" = "--release" ]; then - shift - BINARY_DIR="release" - RELEASE="--release" -fi - -if [ "${1}" = "--rename" ]; then - shift - FILENAME="${1}" - shift -fi -OUT_PATH="$(realpath "${1}")" -shift -OUT_BASENAME="$(basename "${OUT_PATH}")" -FILENAME="${FILENAME:-"${OUT_BASENAME}"}" - -sh "$SOURCE_DIR"/cargo.sh build $RELEASE "$@" - -if [ -n "${OUT_PATH}" ]; then - cp -a ./"${BINARY_DIR}"/"${FILENAME}" "${OUT_PATH}" -fi diff --git a/debian/control b/debian/control index ff713e71..f57b943a 100644 --- a/debian/control +++ b/debian/control @@ -26,6 +26,7 @@ Build-Depends: librust-xkbcommon-0.4+wayland-dev (>= 0.4), libwayland-dev (>= 1.16), lsb-release, + python3, rustc, wayland-protocols (>= 1.14), Standards-Version: 4.1.3 diff --git a/meson.build b/meson.build index a1a073a4..c0eac362 100644 --- a/meson.build +++ b/meson.build @@ -100,7 +100,7 @@ cargo_toml = custom_target( dep_cargo = find_program('cargo') cargo_script = find_program('cargo.sh') -cargo_build = find_program('cargo_build.sh') +cargo_build = find_program('cargo_build.py') subdir('data') subdir('protocols') From 9dcc4c986867c6ee1d52ae1fa74b7144bfd606c0 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 28 Nov 2020 18:35:48 +0000 Subject: [PATCH 04/51] tests: Prefer the env var for finding test layouts The builtin file path is embedded in the binary and subject to substitution, which makes it invalid when trying to build a .deb reproducibly. Out of the two solutions, it's easier to make the change here rather than customize .debu building not to run tests reproducibly. --- src/data.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/data.rs b/src/data.rs index ab0c4d5a..41123b24 100644 --- a/src/data.rs +++ b/src/data.rs @@ -746,13 +746,21 @@ mod tests { use ::logging::ProblemPanic; - const THIS_FILE: &str = file!(); - fn path_from_root(file: &'static str) -> PathBuf { - PathBuf::from(THIS_FILE) - .parent().unwrap() - .parent().unwrap() - .join(file) + let source_dir = env::var("SOURCE_DIR") + .map(PathBuf::from) + .unwrap_or_else(|e| { + if let env::VarError::NotPresent = e { + let this_file = file!(); + PathBuf::from(this_file) + .parent().unwrap() + .parent().unwrap() + .into() + } else { + panic!("{:?}", e); + } + }); + source_dir.join(file) } #[test] From 963f52bbc3282107ef00ea5c2a51084ec44905f2 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 28 Nov 2020 18:42:02 +0000 Subject: [PATCH 05/51] tests: Explicitly pass source directory to tests --- src/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/meson.build b/src/meson.build index f5bd27ae..d85be960 100644 --- a/src/meson.build +++ b/src/meson.build @@ -80,6 +80,7 @@ test( 'rstest', cargo_script, args: ['test'] + cargo_build_flags, + env: ['SOURCE_DIR=' + meson.source_root()], # this is a whole Carg-based test suite, let it run for a while timeout: 900, depends: [build_rstests, cargo_toml], From 39a3c40d67f442ad0ab44e23fb108954941c6711 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 28 Nov 2020 17:32:05 +0000 Subject: [PATCH 06/51] debian: Build reproducibly --- debian/rules | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/rules b/debian/rules index 8e5b6bd6..05ee1295 100755 --- a/debian/rules +++ b/debian/rules @@ -2,6 +2,13 @@ export CARGO_HOME = $(CURDIR)/debian/cargo export DEB_BUILD_MAINT_OPTIONS = hardening=+all +# Don't use paths that may change between builds. +# No need to care about $HOME +# because Cargo will not place any source in ~/.cargo. +# The build directory is a subdirectory of the source directory, +# so it doesn't need to be explicitly taken care of. +export RUSTFLAGS = --remap-path-prefix=$(CURDIR)=/remap-pwd + distrel := $(shell lsb_release --codename --short) ifneq (,$(filter $(distrel),buster amber)) From 1fe6d65525efbe916f1c07824db66609983dd156 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 29 Nov 2020 10:44:02 +0000 Subject: [PATCH 07/51] tests: Allow legacy mode to have much longer tests. --- tests/meson.build | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index 9850a957..27d6620c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -75,13 +75,23 @@ foreach layout : [ if layout == 'emoji' extra += ['allow_missing_return'] endif - + + # Older Cargo seens to be sensitive to something + # about the RUST_FLAGS env var, and rebuilds all tests when it's set, + # increasing test time by 2 orders of magnitude. + # Let it have its way. + if get_option('legacy') == true + timeout = 300 + else + timeout = 30 + endif test( 'test_layout_' + layout, cargo_script, args: ['run'] + cargo_build_flags + ['--example', 'test_layout', '--', layout] + extra, + timeout: timeout, workdir: meson.build_root(), ) endforeach From c3b428e517ec69cd6f5770c2dc7d85a2ea8af786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Str=C3=A1nsk=C3=BD?= Date: Sun, 29 Nov 2020 11:17:51 +0100 Subject: [PATCH 08/51] Add Czech keyboard layouts Two variants: * Czech Standard (= qwertz) * Czech qwerty The accented letters layout corresponds to the UCW [1] layout shipped with xkb, so we follow this precedent. Like the DE layout, and unlike the US layout, the CZ layout has a comma key and a narrower space bar. The added comma key also serves as a visual balance to the added accents key, to keep the spacebar centered. The layouts have been tested manually on PinePhone. [1] https://github.com/xkbcommon/libxkbcommon/blob/c60b77ea512bef92e481be38972b58dd71a34180/test/data/symbols/cz#L180 --- data/keyboards/cz+qwerty.yaml | 106 +++++++++++++++++++++++++++++ data/keyboards/cz+qwerty_wide.yaml | 106 +++++++++++++++++++++++++++++ data/keyboards/cz.yaml | 106 +++++++++++++++++++++++++++++ data/keyboards/cz_wide.yaml | 106 +++++++++++++++++++++++++++++ data/langs/cs-CZ.txt | 21 ++++++ src/resources.rs | 4 ++ tests/meson.build | 2 + 7 files changed, 451 insertions(+) create mode 100644 data/keyboards/cz+qwerty.yaml create mode 100644 data/keyboards/cz+qwerty_wide.yaml create mode 100644 data/keyboards/cz.yaml create mode 100644 data/keyboards/cz_wide.yaml create mode 100644 data/langs/cs-CZ.txt diff --git a/data/keyboards/cz+qwerty.yaml b/data/keyboards/cz+qwerty.yaml new file mode 100644 index 00000000..a9040af9 --- /dev/null +++ b/data/keyboards/cz+qwerty.yaml @@ -0,0 +1,106 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 52.67, height: 52 } + spaceline: { width: 106, height: 52 } + special: { width: 35.33, height: 52 } + +views: + base: + - "q w e r t y u i o p" + - "a s d f g h j k l" + - "Shift_L z x c v b n m BackSpace" + - "show_numbers preferences show_accents space , . Return" + upper: + - "Q W E R T Y U I O P" + - "A S D F G H J K L" + - "Shift_L Z X C V B N M BackSpace" + - "show_numbers preferences show_upper_accents space ! ? Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences show_accents space , . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences show_accents space , . Return" + accents: + - "ä ě é ř ť ý ů í ó ö" + - "á š ď ë ŕ ú ü ô ľ" + - "accents_Shift_L ž ß č ç ñ ň ĺ BackSpace" + - "show_letters preferences show_accents space , . Return" + upper_accents: + - "Ä Ě É Ř Ť Ý Ů Í Ó Ö" + - "Á Š Ď Ë Ŕ Ú Ü Ô Ľ" + - "accents_Shift_L Ž ẞ Č Ç Ñ Ň Ĺ BackSpace" + - "show_letters preferences show_upper_accents space , . Return" + +buttons: + Shift_L: + action: + locking: + lock_view: "upper" + unlock_view: "base" + outline: "altline" + icon: "key-shift" + accents_Shift_L: + action: + locking: + lock_view: "upper_accents" + 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_accents: + action: + locking: + lock_view: "accents" + unlock_view: "base" + outline: "special" + label: "á" + show_upper_accents: + action: + locking: + lock_view: "upper_accents" + unlock_view: "base" + outline: "special" + label: "Á" + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/keyboards/cz+qwerty_wide.yaml b/data/keyboards/cz+qwerty_wide.yaml new file mode 100644 index 00000000..78fd042d --- /dev/null +++ b/data/keyboards/cz+qwerty_wide.yaml @@ -0,0 +1,106 @@ +--- +outlines: + default: { width: 54, height: 42 } + altline: { width: 81, height: 42 } + wide: { width: 81, height: 42 } + spaceline: { width: 162, height: 42 } + special: { width: 54, height: 42 } + +views: + base: + - "q w e r t y u i o p" + - "a s d f g h j k l" + - "Shift_L z x c v b n m BackSpace" + - "show_numbers preferences show_accents space , . Return" + upper: + - "Q W E R T Y U I O P" + - "A S D F G H J K L" + - "Shift_L Z X C V B N M BackSpace" + - "show_numbers preferences show_upper_accents space ! ? Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences show_accents space , . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences show_accents space , . Return" + accents: + - "ä ě é ř ť ý ů í ó ö" + - "á š ď ë ŕ ú ü ô ľ" + - "accents_Shift_L ž ß č ç ñ ň ĺ BackSpace" + - "show_letters preferences show_accents space , . Return" + upper_accents: + - "Ä Ě É Ř Ť Ý Ů Í Ó Ö" + - "Á Š Ď Ë Ŕ Ú Ü Ô Ľ" + - "accents_Shift_L Ž ẞ Č Ç Ñ Ň Ĺ BackSpace" + - "show_letters preferences show_upper_accents space , . Return" + +buttons: + Shift_L: + action: + locking: + lock_view: "upper" + unlock_view: "base" + outline: "altline" + icon: "key-shift" + accents_Shift_L: + action: + locking: + lock_view: "upper_accents" + 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_accents: + action: + locking: + lock_view: "accents" + unlock_view: "base" + outline: "special" + label: "á" + show_upper_accents: + action: + locking: + lock_view: "upper_accents" + unlock_view: "base" + outline: "special" + label: "Á" + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/keyboards/cz.yaml b/data/keyboards/cz.yaml new file mode 100644 index 00000000..889b9674 --- /dev/null +++ b/data/keyboards/cz.yaml @@ -0,0 +1,106 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 52.67, height: 52 } + spaceline: { width: 106, height: 52 } + special: { width: 35.33, height: 52 } + +views: + base: + - "q w e r t z u i o p" + - "a s d f g h j k l" + - "Shift_L y x c v b n m BackSpace" + - "show_numbers preferences show_accents space , . Return" + upper: + - "Q W E R T Z U I O P" + - "A S D F G H J K L" + - "Shift_L Y X C V B N M BackSpace" + - "show_numbers preferences show_upper_accents space ! ? Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences show_accents space , . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences show_accents space , . Return" + accents: + - "ä ě é ř ť ž ů í ó ö" + - "á š ď ë ŕ ú ü ô ľ" + - "accents_Shift_L ý ß č ç ñ ň ĺ BackSpace" + - "show_letters preferences show_accents space , . Return" + upper_accents: + - "Ä Ě É Ř Ť Ž Ů Í Ó Ö" + - "Á Š Ď Ë Ŕ Ú Ü Ô Ľ" + - "accents_Shift_L Ý ẞ Č Ç Ñ Ň Ĺ BackSpace" + - "show_letters preferences show_upper_accents space , . Return" + +buttons: + Shift_L: + action: + locking: + lock_view: "upper" + unlock_view: "base" + outline: "altline" + icon: "key-shift" + accents_Shift_L: + action: + locking: + lock_view: "upper_accents" + 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_accents: + action: + locking: + lock_view: "accents" + unlock_view: "base" + outline: "special" + label: "á" + show_upper_accents: + action: + locking: + lock_view: "upper_accents" + unlock_view: "base" + outline: "special" + label: "Á" + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/keyboards/cz_wide.yaml b/data/keyboards/cz_wide.yaml new file mode 100644 index 00000000..1ea62758 --- /dev/null +++ b/data/keyboards/cz_wide.yaml @@ -0,0 +1,106 @@ +--- +outlines: + default: { width: 54, height: 42 } + altline: { width: 81, height: 42 } + wide: { width: 81, height: 42 } + spaceline: { width: 162, height: 42 } + special: { width: 54, height: 42 } + +views: + base: + - "q w e r t z u i o p" + - "a s d f g h j k l" + - "Shift_L y x c v b n m BackSpace" + - "show_numbers preferences show_accents space , . Return" + upper: + - "Q W E R T Z U I O P" + - "A S D F G H J K L" + - "Shift_L Y X C V B N M BackSpace" + - "show_numbers preferences show_upper_accents space ! ? Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences show_accents space , . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences show_accents space , . Return" + accents: + - "ä ě é ř ť ž ů í ó ö" + - "á š ď ë ŕ ú ü ô ľ" + - "accents_Shift_L ý ß č ç ñ ň ĺ BackSpace" + - "show_letters preferences show_accents space , . Return" + upper_accents: + - "Ä Ě É Ř Ť Ž Ů Í Ó Ö" + - "Á Š Ď Ë Ŕ Ú Ü Ô Ľ" + - "accents_Shift_L Ý ẞ Č Ç Ñ Ň Ĺ BackSpace" + - "show_letters preferences show_upper_accents space , . Return" + +buttons: + Shift_L: + action: + locking: + lock_view: "upper" + unlock_view: "base" + outline: "altline" + icon: "key-shift" + accents_Shift_L: + action: + locking: + lock_view: "upper_accents" + 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_accents: + action: + locking: + lock_view: "accents" + unlock_view: "base" + outline: "special" + label: "á" + show_upper_accents: + action: + locking: + lock_view: "upper_accents" + unlock_view: "base" + outline: "special" + label: "Á" + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/langs/cs-CZ.txt b/data/langs/cs-CZ.txt new file mode 100644 index 00000000..6c87837e --- /dev/null +++ b/data/langs/cs-CZ.txt @@ -0,0 +1,21 @@ +be Belgická +cz Česká +cz+qwerty Česká (QWERTY) +de Německá +dk Dánská +emoji Emoji +es Španělská +fi Finská +fr Francouzská +gr Řecká +it Italská +jp Japonská +jp+kana Japonská (Kana) +no Norská +pl Polská +ru Ruská +se Švédská +terminal Terminál +th Thajská +ua Ukrajinská +us Anglická (USA) diff --git a/src/resources.rs b/src/resources.rs index d94b9cb5..b192f1e8 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -20,6 +20,10 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("be", include_str!("../data/keyboards/be.yaml")), ("be_wide", include_str!("../data/keyboards/be_wide.yaml")), ("de_wide", include_str!("../data/keyboards/de_wide.yaml")), + ("cz", include_str!("../data/keyboards/cz.yaml")), + ("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")), + ("cz+qwerty", include_str!("../data/keyboards/cz+qwerty.yaml")), + ("cz+qwerty_wide", include_str!("../data/keyboards/cz+qwerty_wide.yaml")), ("dk", include_str!("../data/keyboards/dk.yaml")), ("es", include_str!("../data/keyboards/es.yaml")), ("fi", include_str!("../data/keyboards/fi.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 9850a957..6cd55c55 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -51,6 +51,8 @@ foreach layout : [ 'us', 'us_wide', 'br', 'be', 'be_wide', + 'cz', 'cz_wide', + 'cz+qwerty', 'cz+qwerty_wide', 'de', 'de_wide', 'dk', 'es', From 696d77293e9d4ca87b06bbe11e1221f6cbc4d46d Mon Sep 17 00:00:00 2001 From: Henry-Nicolas Tourneur Date: Tue, 10 Nov 2020 14:57:09 +0000 Subject: [PATCH 09/51] d/rules: export RUSTFLAGS only on architecture that needs it Altered from original to take reproducibility into account. Not tested on mips64el. --- debian/rules | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 05ee1295..9f4ad75c 100755 --- a/debian/rules +++ b/debian/rules @@ -2,12 +2,21 @@ export CARGO_HOME = $(CURDIR)/debian/cargo export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# the below avoids an FTBFS on mips64el with a GOT > 64kb +DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) +ifeq ($(DEB_HOST_ARCH),mips64el) + xgot = -Ctarget-feature=+xgot +else + xgot = +endif + # Don't use paths that may change between builds. # No need to care about $HOME # because Cargo will not place any source in ~/.cargo. # The build directory is a subdirectory of the source directory, # so it doesn't need to be explicitly taken care of. -export RUSTFLAGS = --remap-path-prefix=$(CURDIR)=/remap-pwd +export RUSTFLAGS = --remap-path-prefix=$(CURDIR)=/remap-pwd $(xgot) distrel := $(shell lsb_release --codename --short) From 02d579d7571a25947a46f0c1d149dc0d90269e17 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 21 Sep 2020 10:02:22 +0000 Subject: [PATCH 10/51] build: Enable unused warnings in C The goal is to be free of unused X class of problems. For this, CI and any "serious" builds will fail on warnings. Debug builds, used in development, will warn by default but not fail. In addition, the 'strict' build option is added for when the debug build should fail on unused warnings as well. --- meson.build | 12 +++++++++++- meson_options.txt | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index d8e0e1bb..80b85f81 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ add_project_arguments( '-Wold-style-definition', '-Wredundant-decls', '-Wstrict-prototypes', - '-Wunused-function', + '-Wunused', ], language: 'c' ) @@ -38,6 +38,16 @@ conf_data = configuration_data() if get_option('buildtype').startswith('debug') add_project_arguments('-DDEBUG=1', language : 'c') endif + +if get_option('strict') + add_project_arguments( + [ + '-Werror=unused', + ], + language: 'c' + ) +endif + if get_option('buildtype') != 'plain' add_project_arguments('-fstack-protector-strong', language: 'c') endif diff --git a/meson_options.txt b/meson_options.txt index 180f12f3..bb68374d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,3 +10,7 @@ option('tests', option('legacy', type: 'boolean', value: false, description: 'Build with Deban Buster versions of dependencies') + +option('strict', + type: 'boolean', value: true, + description: 'Turn more warnings into errors') From af00d74f71ac411d7cfe2de023b0cc30528552b8 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:26:28 +0000 Subject: [PATCH 11/51] build: Enable wformat to remove warnings about missing wformat --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 80b85f81..a00bae53 100644 --- a/meson.build +++ b/meson.build @@ -21,6 +21,7 @@ add_project_arguments( '-Werror=int-conversion', '-Wformat-nonliteral', '-Wformat-security', + '-Wformat', '-Winit-self', '-Wmaybe-uninitialized', '-Wold-style-definition', From 2796362d348124cde1e20223a73ac70f42fdc03d Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:26:54 +0000 Subject: [PATCH 12/51] build: Fail on any C warnings when strict --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a00bae53..1adf7489 100644 --- a/meson.build +++ b/meson.build @@ -43,7 +43,7 @@ endif if get_option('strict') add_project_arguments( [ - '-Werror=unused', + '-Werror', ], language: 'c' ) From 103e64b96ca817b41a4433584eef6ef170ba3585 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:45:45 +0000 Subject: [PATCH 13/51] data: Made data flow in fallback clearer --- src/data.rs | 60 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/data.rs b/src/data.rs index ab0c4d5a..b8eb62c6 100644 --- a/src/data.rs +++ b/src/data.rs @@ -97,6 +97,8 @@ impl fmt::Display for DataSource { } } +type LayoutSource = (ArrangementKind, DataSource); + /// Lists possible sources, with 0 as the most preferred one /// Trying order: native lang of the right kind, native base, /// fallback lang of the right kind, fallback base @@ -104,9 +106,29 @@ fn list_layout_sources( name: &str, kind: ArrangementKind, keyboards_path: Option, -) -> Vec<(ArrangementKind, DataSource)> { - let mut ret = Vec::new(); - { +) -> Vec { + let add_by_name = | + mut ret: Vec, + name: &str, + kind: &ArrangementKind, + | -> Vec { + if let Some(path) = keyboards_path.clone() { + ret.push(( + kind.clone(), + DataSource::File( + path.join(name.to_owned()).with_extension("yaml") + ) + )) + } + + ret.push(( + kind.clone(), + DataSource::Resource(name.into()) + )); + ret + }; + + let ret = { fn name_with_arrangement(name: String, kind: &ArrangementKind) -> String { @@ -116,42 +138,30 @@ fn list_layout_sources( } } - let mut add_by_name = |name: &str, kind: &ArrangementKind| { - if let Some(path) = keyboards_path.clone() { - ret.push(( - kind.clone(), - DataSource::File( - path.join(name.to_owned()).with_extension("yaml") - ) - )) - } - - ret.push(( - kind.clone(), - DataSource::Resource(name.into()) - )); - }; + let ret = Vec::new(); - match &kind { - ArrangementKind::Base => {}, + let ret = match &kind { + ArrangementKind::Base => ret, kind => add_by_name( + ret, &name_with_arrangement(name.into(), &kind), &kind, ), }; - add_by_name(name, &ArrangementKind::Base); + let ret = add_by_name(ret, name, &ArrangementKind::Base); - match &kind { - ArrangementKind::Base => {}, + let ret = match &kind { + ArrangementKind::Base => ret, kind => add_by_name( + ret, &name_with_arrangement(FALLBACK_LAYOUT_NAME.into(), &kind), &kind, ), }; - add_by_name(FALLBACK_LAYOUT_NAME, &ArrangementKind::Base); - } + add_by_name(ret, FALLBACK_LAYOUT_NAME, &ArrangementKind::Base) + }; ret } From cc4f14e8c6dee3f9f64f1db6814d32a7b9f782a0 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 15:47:44 +0000 Subject: [PATCH 14/51] data: Flattened layout fallback function --- src/data.rs | 57 ++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/data.rs b/src/data.rs index b8eb62c6..8075d38e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -128,41 +128,36 @@ fn list_layout_sources( ret }; - let ret = { - fn name_with_arrangement(name: String, kind: &ArrangementKind) - -> String - { - match kind { - ArrangementKind::Base => name, - ArrangementKind::Wide => name + "_wide", - } + fn name_with_arrangement(name: String, kind: &ArrangementKind) -> String { + match kind { + ArrangementKind::Base => name, + ArrangementKind::Wide => name + "_wide", } + } - let ret = Vec::new(); + let ret = Vec::new(); - let ret = match &kind { - ArrangementKind::Base => ret, - kind => add_by_name( - ret, - &name_with_arrangement(name.into(), &kind), - &kind, - ), - }; - - let ret = add_by_name(ret, name, &ArrangementKind::Base); - - let ret = match &kind { - ArrangementKind::Base => ret, - kind => add_by_name( - ret, - &name_with_arrangement(FALLBACK_LAYOUT_NAME.into(), &kind), - &kind, - ), - }; - - add_by_name(ret, FALLBACK_LAYOUT_NAME, &ArrangementKind::Base) + let ret = match &kind { + ArrangementKind::Base => ret, + kind => add_by_name( + ret, + &name_with_arrangement(name.into(), &kind), + &kind, + ), }; - ret + + let ret = add_by_name(ret, name, &ArrangementKind::Base); + + let ret = match &kind { + ArrangementKind::Base => ret, + kind => add_by_name( + ret, + &name_with_arrangement(FALLBACK_LAYOUT_NAME.into(), &kind), + &kind, + ), + }; + + add_by_name(ret, FALLBACK_LAYOUT_NAME, &ArrangementKind::Base) } fn load_layout_data(source: DataSource) From ba2e1919185f786da4ffb4c8d84f86e1ea12cf18 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 16:15:22 +0000 Subject: [PATCH 15/51] layouts: Use base as fallback for alternative layouts --- src/data.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/data.rs b/src/data.rs index 8075d38e..b8feacc5 100644 --- a/src/data.rs +++ b/src/data.rs @@ -137,6 +137,7 @@ fn list_layout_sources( let ret = Vec::new(); + // Name as given takes priority. let ret = match &kind { ArrangementKind::Base => ret, kind => add_by_name( @@ -148,6 +149,35 @@ fn list_layout_sources( let ret = add_by_name(ret, name, &ArrangementKind::Base); + // Then try non-alternative name if applicable (`us` for `us+colemak`). + let ret = { + let mut parts = name.splitn(2, '+'); + match parts.next() { + Some(base) => { + // The name is already equal to base, so it was already added. + if base == name { ret } + else { + let ret = match &kind { + ArrangementKind::Base => ret, + kind => add_by_name( + ret, + &name_with_arrangement(base.into(), &kind), + &kind, + ), + }; + + add_by_name(ret, base, &ArrangementKind::Base) + } + }, + // The layout's base name starts with a "+". Weird but OK. + None => { + log_print!(logging::Level::Surprise, "Base layout name is empty: {}", name); + ret + } + } + }; + + // Finally, fallback name let ret = match &kind { ArrangementKind::Base => ret, kind => add_by_name( @@ -914,7 +944,26 @@ mod tests { ) ); } + + /// If layout contains a "+", it should reach for what's in front of it too. + #[test] + fn fallbacks_order_base() { + let sources = list_layout_sources("nb+aliens", ArrangementKind::Base, None); + + assert_eq!( + sources, + vec!( + (ArrangementKind::Base, DataSource::Resource("nb+aliens".into())), + (ArrangementKind::Base, DataSource::Resource("nb".into())), + ( + ArrangementKind::Base, + DataSource::Resource(FALLBACK_LAYOUT_NAME.into()) + ), + ) + ); + } + #[test] fn unicode_keysym() { let keysym = xkb::keysym_from_name( From fcd0eaddf2abcb6a5eff50581eb9f37b1432b7db Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Thu, 3 Dec 2020 16:26:47 +0000 Subject: [PATCH 16/51] layouts: Simplify the main flow of source list --- src/data.rs | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/src/data.rs b/src/data.rs index b8feacc5..0787d33a 100644 --- a/src/data.rs +++ b/src/data.rs @@ -107,6 +107,7 @@ fn list_layout_sources( kind: ArrangementKind, keyboards_path: Option, ) -> Vec { + // Just a simplification of often called code. let add_by_name = | mut ret: Vec, name: &str, @@ -128,6 +129,20 @@ fn list_layout_sources( ret }; + // Another grouping. + let add_by_kind = |ret, name: &str, kind| { + let ret = match kind { + &ArrangementKind::Base => ret, + kind => add_by_name( + ret, + &name_with_arrangement(name.into(), kind), + kind, + ), + }; + + add_by_name(ret, name, &ArrangementKind::Base) + }; + fn name_with_arrangement(name: String, kind: &ArrangementKind) -> String { match kind { ArrangementKind::Base => name, @@ -138,16 +153,7 @@ fn list_layout_sources( let ret = Vec::new(); // Name as given takes priority. - let ret = match &kind { - ArrangementKind::Base => ret, - kind => add_by_name( - ret, - &name_with_arrangement(name.into(), &kind), - &kind, - ), - }; - - let ret = add_by_name(ret, name, &ArrangementKind::Base); + let ret = add_by_kind(ret, name, &kind); // Then try non-alternative name if applicable (`us` for `us+colemak`). let ret = { @@ -157,16 +163,7 @@ fn list_layout_sources( // The name is already equal to base, so it was already added. if base == name { ret } else { - let ret = match &kind { - ArrangementKind::Base => ret, - kind => add_by_name( - ret, - &name_with_arrangement(base.into(), &kind), - &kind, - ), - }; - - add_by_name(ret, base, &ArrangementKind::Base) + add_by_kind(ret, base, &kind) } }, // The layout's base name starts with a "+". Weird but OK. @@ -177,17 +174,8 @@ fn list_layout_sources( } }; - // Finally, fallback name - let ret = match &kind { - ArrangementKind::Base => ret, - kind => add_by_name( - ret, - &name_with_arrangement(FALLBACK_LAYOUT_NAME.into(), &kind), - &kind, - ), - }; - - add_by_name(ret, FALLBACK_LAYOUT_NAME, &ArrangementKind::Base) + // No other choices left, so give anything. + add_by_kind(ret, FALLBACK_LAYOUT_NAME.into(), &kind) } fn load_layout_data(source: DataSource) From 61a84c47f15ef8a32918da77fbe90b7c653b83c3 Mon Sep 17 00:00:00 2001 From: Stefan Grotz Date: Wed, 1 Jul 2020 19:45:01 +0000 Subject: [PATCH 17/51] Esperanto keyboard Fixed by Dorota Czaplejewicz --- data/keyboards/epo.yaml | 81 +++++++++++++++++++++++++++++++++++++++++ src/resources.rs | 1 + tests/meson.build | 1 + 3 files changed, 83 insertions(+) create mode 100644 data/keyboards/epo.yaml diff --git a/data/keyboards/epo.yaml b/data/keyboards/epo.yaml new file mode 100644 index 00000000..ef4705e1 --- /dev/null +++ b/data/keyboards/epo.yaml @@ -0,0 +1,81 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 99.67, height: 52 } + special: { width: 35.33, height: 52 } + +views: + base: + - "q w e r t y u i o p" + - "a s d f g h j k l" + - "Shift_L z x c v b n m BackSpace" + - "show_numbers show_eschars preferences space , . Return" + upper: + - "Q W E R T Y U I O P" + - "A S D F G H J K L" + - "Shift_L Z X C V B N M BackSpace" + - "show_numbers show_eschars preferences space ! ? Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' : ; ! ? BackSpace" + - "show_letters preferences space . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space . Return" + eschars: + - "ĉ ĝ ĥ ĵ ŝ ŭ ?" + - "Ĉ Ĝ Ĥ Ĵ Ŝ Ŭ !" + - "show_numbers ' - 🐊 💚 🌐 . BackSpace" + - "show_letters show_eschars preferences space „ “ 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "altline" + 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" + label: " " + text: " " + Return: + outline: "altline" + icon: "key-enter" + keysym: "Return" diff --git a/src/resources.rs b/src/resources.rs index 109226bd..2148bf0a 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -17,6 +17,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("de", include_str!("../data/keyboards/de.yaml")), ("de_wide", include_str!("../data/keyboards/de_wide.yaml")), ("dk", include_str!("../data/keyboards/dk.yaml")), + ("epo", include_str!("../data/keyboards/epo.yaml")), ("es", include_str!("../data/keyboards/es.yaml")), ("fi", include_str!("../data/keyboards/fi.yaml")), ("fr", include_str!("../data/keyboards/fr.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 67b7983b..d27ae5d8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -51,6 +51,7 @@ foreach layout : [ 'us', 'us_wide', 'de', 'de_wide', 'dk', + 'epo', 'es', 'fi', 'fr', From c103b84fa6264a8281823755346a6963b353b027 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 10 Dec 2020 19:42:28 +0000 Subject: [PATCH 18/51] Bulgarian language keyboard layout --- data/keyboards/bg.yaml | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 data/keyboards/bg.yaml diff --git a/data/keyboards/bg.yaml b/data/keyboards/bg.yaml new file mode 100644 index 00000000..a0efff02 --- /dev/null +++ b/data/keyboards/bg.yaml @@ -0,0 +1,78 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "я в е р т ъ у и о п ю" + - "а с д ф г х й к л ш щ" + - "Shift_L з ь ц ж б н м ч BackSpace" + - "show_numbers preferences space . Return" + upper: + - "Я В Е Р Т Ъ У И О П Ю" + - "А С Д Ф Г Х Й К Л Ш Щ" + - "Shift_L З Ь Ц Ж Б Н М Ч BackSpace" + - "show_numbers preferences space , Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # € % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences space Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ $ ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space 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: "*/=" + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" + "\"": + keysym: "quotedbl" From 8dd92c81e7d7666187e7b44d6e2b0421cc59d571 Mon Sep 17 00:00:00 2001 From: Vladimir Stoilov Date: Fri, 11 Dec 2020 22:06:39 +0200 Subject: [PATCH 19/51] bulgarian add translation and to needed lists --- data/langs/bg-BG.txt | 13 +++++++++++++ src/resources.rs | 1 + tests/meson.build | 1 + 3 files changed, 15 insertions(+) create mode 100644 data/langs/bg-BG.txt diff --git a/data/langs/bg-BG.txt b/data/langs/bg-BG.txt new file mode 100644 index 00000000..ce59b534 --- /dev/null +++ b/data/langs/bg-BG.txt @@ -0,0 +1,13 @@ +bg Български +de Немски +es Испански +emoji Емоджи +fi Френски +gr Гръцки +it Италянски +no Норевежки +pl Полски +ru Руски +se Шведски +terminal Терминал +us Английски (САЩ) diff --git a/src/resources.rs b/src/resources.rs index 993fde9c..50366cb9 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -44,6 +44,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("se", include_str!("../data/keyboards/se.yaml")), ("th", include_str!("../data/keyboards/th.yaml")), ("ua", include_str!("../data/keyboards/ua.yaml")), + ("bg", include_str!("../data/keyboards/bg.yaml")), // layout+overlay ("terminal", include_str!("../data/keyboards/terminal.yaml")), ("terminal_wide", include_str!("../data/keyboards/terminal_wide.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 6bc3fb9f..b73b637a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -51,6 +51,7 @@ foreach layout : [ 'us', 'us+colemak', 'us_wide', 'br', 'be', 'be_wide', + 'bg', 'cz', 'cz_wide', 'cz+qwerty', 'cz+qwerty_wide', 'de', 'de_wide', From 9517c347b64ebb22c7893149041f6947513dc755 Mon Sep 17 00:00:00 2001 From: Vladimir Stoilov Date: Sat, 12 Dec 2020 00:28:21 +0200 Subject: [PATCH 20/51] Fix bulgarian layout size --- data/keyboards/bg.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/keyboards/bg.yaml b/data/keyboards/bg.yaml index a0efff02..93e14987 100644 --- a/data/keyboards/bg.yaml +++ b/data/keyboards/bg.yaml @@ -1,9 +1,9 @@ --- outlines: - default: { width: 35.33, height: 52 } - altline: { width: 52.67, height: 52 } - wide: { width: 62, height: 52 } - spaceline: { width: 142, height: 52 } + default: { width: 32.72, height: 52 } + altline: { width: 47, height: 52 } + wide: { width: 49.09, height: 52 } + spaceline: { width: 185, height: 52 } special: { width: 44, height: 52 } views: From 6f7252ec7ca072e9987a031ffef601a96da7f41e Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 7 Dec 2020 15:42:25 +0000 Subject: [PATCH 21/51] tests: Add some description to the list of tested layouts Contributors have started to make it messy. --- src/resources.rs | 1 + tests/meson.build | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/resources.rs b/src/resources.rs index 50366cb9..7d00ed03 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -16,6 +16,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("us", include_str!("../data/keyboards/us.yaml")), ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), ("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")), diff --git a/tests/meson.build b/tests/meson.build index b73b637a..017f2143 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -46,12 +46,21 @@ endforeach # The layout test is in the examples directory # due to the way Cargo builds executables -# and the need to call it manually +# and the need to call it manually. + +# This is the list of tested builtin layouts. +# Please keep each block alphabetical! +# Please keep shapes (with _) on the same line, +# variants (with +) on separate lines. foreach layout : [ - 'us', 'us+colemak', 'us_wide', - 'br', + # This is the fallback layout, + # so stays first to make sure it never goes missing. + 'us', 'us_wide', + + # Block: Languages 'be', 'be_wide', 'bg', + 'br', 'cz', 'cz_wide', 'cz+qwerty', 'cz+qwerty_wide', 'de', 'de_wide', @@ -60,20 +69,22 @@ foreach layout : [ 'es', 'fi', 'fr', 'fr_wide', - 'it+fur', 'gr', 'it', + 'it+fur', 'jp+kana','jp+kana_wide', 'no', - 'number', 'pl', 'pl_wide', 'ru', 'se', - 'ua', 'th', - 'terminal', 'terminal_wide', + 'ua', + 'us+colemak', + # Block: Not languages. 'emoji', + 'number', + 'terminal', 'terminal_wide', ] extra = [] if layout == 'emoji' From 658df98e18c46f696738ebc579d35f62d8bac7ef Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 7 Dec 2020 15:45:58 +0000 Subject: [PATCH 22/51] layout_names: Unmess the list of builtin layouts --- src/resources.rs | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/resources.rs b/src/resources.rs index 7d00ed03..98fb24d8 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -10,42 +10,67 @@ use std::iter::FromIterator; // TODO: keep a list of what is a language layout, // and what a convenience layout. "_wide" is not a layout, // neither is "number" +/// List of builtin layouts const KEYBOARDS: &[(*const str, *const str)] = &[ // layouts: us must be left as first, as it is the, - // fallback layout. The others should be alphabetical. + // fallback layout. ("us", include_str!("../data/keyboards/us.yaml")), - ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), ("us_wide", include_str!("../data/keyboards/us_wide.yaml")), - ("br", include_str!("../data/keyboards/br.yaml")), - ("de", include_str!("../data/keyboards/de.yaml")), + // Language layouts: keep alphabetical. ("be", include_str!("../data/keyboards/be.yaml")), ("be_wide", include_str!("../data/keyboards/be_wide.yaml")), + + ("bg", include_str!("../data/keyboards/bg.yaml")), + + ("br", include_str!("../data/keyboards/br.yaml")), + + ("de", include_str!("../data/keyboards/de.yaml")), ("de_wide", include_str!("../data/keyboards/de_wide.yaml")), + ("cz", include_str!("../data/keyboards/cz.yaml")), ("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")), + ("cz+qwerty", include_str!("../data/keyboards/cz+qwerty.yaml")), ("cz+qwerty_wide", include_str!("../data/keyboards/cz+qwerty_wide.yaml")), + ("dk", include_str!("../data/keyboards/dk.yaml")), + ("epo", include_str!("../data/keyboards/epo.yaml")), + ("es", include_str!("../data/keyboards/es.yaml")), + ("fi", include_str!("../data/keyboards/fi.yaml")), + ("fr", include_str!("../data/keyboards/fr.yaml")), ("fr_wide", include_str!("../data/keyboards/fr_wide.yaml")), - ("it+fur", include_str!("../data/keyboards/it+fur.yaml")), + ("gr", include_str!("../data/keyboards/gr.yaml")), + ("it", include_str!("../data/keyboards/it.yaml")), + ("it+fur", include_str!("../data/keyboards/it+fur.yaml")), + ("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")), ("jp+kana_wide", include_str!("../data/keyboards/jp+kana_wide.yaml")), + ("no", include_str!("../data/keyboards/no.yaml")), - ("number", include_str!("../data/keyboards/number.yaml")), + ("pl", include_str!("../data/keyboards/pl.yaml")), ("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")), + ("ru", include_str!("../data/keyboards/ru.yaml")), + ("se", include_str!("../data/keyboards/se.yaml")), + ("th", include_str!("../data/keyboards/th.yaml")), + ("ua", include_str!("../data/keyboards/ua.yaml")), - ("bg", include_str!("../data/keyboards/bg.yaml")), + + ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), + + // Others + ("number", include_str!("../data/keyboards/number.yaml")), + // layout+overlay ("terminal", include_str!("../data/keyboards/terminal.yaml")), ("terminal_wide", include_str!("../data/keyboards/terminal_wide.yaml")), From 701168c32b4b7a2df83bb66c29861dc7bec39cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20R=C3=B6nnquist?= Date: Sun, 13 Dec 2020 19:26:47 +0100 Subject: [PATCH 23/51] no: Use wide button switching between numbers, symbols and base --- data/keyboards/no.yaml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/data/keyboards/no.yaml b/data/keyboards/no.yaml index 44de74cc..0248356b 100644 --- a/data/keyboards/no.yaml +++ b/data/keyboards/no.yaml @@ -2,9 +2,9 @@ outlines: default: { width: 32, height: 52 } altline: { width: 48.39024, height: 52 } - wide: { width: 62, height: 52 } - outline7: { width: 88.97561, height: 52 } - spaceline: { width: 150.5853, height: 52 } + wide: { width: 64, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } views: base: @@ -25,7 +25,7 @@ views: symbols: - "~ ` | U00B7 squareroot Greek_pi Greek_tau division multiply paragraph" - "copyright U00AE U00A3 EuroSign U00A5 asciicircum degree * { }" - - "show_numbers \\ / < > = [ ] BackSpace" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" - "show_letters preferences space . Return" buttons: @@ -42,17 +42,22 @@ buttons: action: erase preferences: action: "show_prefs" - outline: "altline" + outline: "special" icon: "keyboard-mode-symbolic" show_numbers: action: set_view: "numbers" - outline: "altline" + outline: "wide" + label: "123" + show_numbers_from_symbols: + action: + set_view: "numbers" + outline: altline label: "123" show_letters: action: set_view: "base" - outline: "altline" + outline: "wide" label: "ABC" show_symbols: action: @@ -60,7 +65,7 @@ buttons: outline: "altline" label: "*/=" ".": - outline: altline + outline: "special" space: outline: spaceline text: " " From 4890c86b4efc299ca9da71408af9574dd3663505 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 15 Dec 2020 13:20:34 +0000 Subject: [PATCH 24/51] dbus: Reset hints if text input missing --- src/dbus.c | 2 +- src/server-context-service.c | 15 ++++++++++++++- src/server-context-service.h | 2 +- src/submission.h | 1 + src/submission.rs | 12 ++++++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 046b6bd8..24bab66f 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -59,7 +59,7 @@ handle_set_visible(SmPuriOSK0 *object, GDBusMethodInvocation *invocation, if (service->context) { if (arg_visible) { - server_context_service_show_keyboard (service->context); + server_context_service_force_show_keyboard (service->context); } else { server_context_service_hide_keyboard (service->context); } diff --git a/src/server-context-service.c b/src/server-context-service.c index 44364aec..8c907848 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -255,7 +255,7 @@ on_hide (ServerContextService *self) return G_SOURCE_REMOVE; } -void +static void server_context_service_show_keyboard (ServerContextService *self) { g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self)); @@ -270,6 +270,19 @@ server_context_service_show_keyboard (ServerContextService *self) } } +void +server_context_service_force_show_keyboard (ServerContextService *self) +{ + if (!submission_hint_available(self->submission)) { + eekboard_context_service_set_hint_purpose( + self->state, + ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL + ); + } + server_context_service_show_keyboard(self); +} + void server_context_service_hide_keyboard (ServerContextService *self) { diff --git a/src/server-context-service.h b/src/server-context-service.h index 99aca139..a77a8edd 100644 --- a/src/server-context-service.h +++ b/src/server-context-service.h @@ -31,7 +31,7 @@ G_DECLARE_FINAL_TYPE (ServerContextService, server_context_service, SERVER, CONT ServerContextService *server_context_service_new(EekboardContextService *self, struct submission *submission, struct squeek_layout_state *layout, struct ui_manager *uiman, struct vis_manager *visman); enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *); -void server_context_service_show_keyboard (ServerContextService *self); +void server_context_service_force_show_keyboard (ServerContextService *self); void server_context_service_hide_keyboard (ServerContextService *self); G_END_DECLS #endif /* SERVER_CONTEXT_SERVICE_H */ diff --git a/src/submission.h b/src/submission.h index 49a15116..1e7274ae 100644 --- a/src/submission.h +++ b/src/submission.h @@ -17,6 +17,7 @@ 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, struct vis_manager *vis_manager); +uint8_t submission_hint_available(struct submission *self); void submission_set_ui(struct submission *self, ServerContextService *ui_context); void submission_use_layout(struct submission *self, struct squeek_layout *layout, uint32_t time); #endif diff --git a/src/submission.rs b/src/submission.rs index f64810f8..ba9f0c7a 100644 --- a/src/submission.rs +++ b/src/submission.rs @@ -93,6 +93,18 @@ pub mod c { let layout = unsafe { &*layout }; submission.use_layout(layout, Timestamp(time)); } + + #[no_mangle] + pub extern "C" + fn submission_hint_available(submission: *mut Submission) -> u8 { + if submission.is_null() { + panic!("Null submission pointer"); + } + let submission: &mut Submission = unsafe { &mut *submission }; + let active = submission.imservice.as_ref() + .map(|imservice| imservice.is_active()); + (Some(true) == active) as u8 + } } #[derive(Clone, Copy)] From 976f0a6e37bed4714c995723acd7b9532d52f0bf Mon Sep 17 00:00:00 2001 From: jranaraki Date: Sun, 27 Dec 2020 01:08:07 -0500 Subject: [PATCH 25/51] Farsi/Persian keyboard layout --- data/keyboards/ir.yaml | 78 +++++++++++++++++++++++++++++++++++++ data/keyboards/ir_wide.yaml | 78 +++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 data/keyboards/ir.yaml create mode 100644 data/keyboards/ir_wide.yaml diff --git a/data/keyboards/ir.yaml b/data/keyboards/ir.yaml new file mode 100644 index 00000000..5f5fe5e4 --- /dev/null +++ b/data/keyboards/ir.yaml @@ -0,0 +1,78 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "ض ص ث ق ف غ ع ه خ ح" + - "ش س ی ب ل ا ت ن م" + - "Shift_L ظ ط ز ر ذ د پ BackSpace" + - "show_numbers preferences space period Return" + upper: + - "ْ ٌ ٍ ً ُ ِ َ ّ ] [" + - "و ئ ي إ أ آ ة » «" + - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" + - "show_numbers preferences space period Return" + numbers: + - "۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰" + - "@ # ﷼ % & - _ + ( )" + - "show_symbols , \" ' colon ؛ ! ? BackSpace" + - "show_letters preferences space period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/keyboards/ir_wide.yaml b/data/keyboards/ir_wide.yaml new file mode 100644 index 00000000..984f364d --- /dev/null +++ b/data/keyboards/ir_wide.yaml @@ -0,0 +1,78 @@ +--- +outlines: + default: { width: 54, height: 42 } + altline: { width: 81, height: 42 } + wide: { width: 108, height: 42 } + spaceline: { width: 216, height: 42 } + special: { width: 54, height: 42 } + +views: + base: + - "ض ص ث ق ف غ ع ه خ ح" + - "ش س ی ب ل ا ت ن م" + - "Shift_L ظ ط ز ر ذ د پ BackSpace" + - "show_numbers preferences space period Return" + upper: + - "ْ ٌ ٍ ً ُ ِ َ ّ ] [" + - "و ئ ي إ أ آ ة » «" + - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" + - "show_numbers preferences space period Return" + numbers: + - "۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰" + - "@ # ﷼ % & - _ + ( )" + - "show_symbols , \" ' colon ؛ ! ? BackSpace" + - "show_letters preferences space period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + ".": + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" From 1856e7023d1433c93091978c2508a739749132a6 Mon Sep 17 00:00:00 2001 From: jranaraki Date: Sun, 27 Dec 2020 01:48:33 -0500 Subject: [PATCH 26/51] Farsi/Persian keyboard layout --- data/keyboards/ir.yaml | 2 +- data/keyboards/ir_wide.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/keyboards/ir.yaml b/data/keyboards/ir.yaml index 5f5fe5e4..33ced36a 100644 --- a/data/keyboards/ir.yaml +++ b/data/keyboards/ir.yaml @@ -13,7 +13,7 @@ views: - "Shift_L ظ ط ز ر ذ د پ BackSpace" - "show_numbers preferences space period Return" upper: - - "ْ ٌ ٍ ً ُ ِ َ ّ ] [" + - "ْ ٌ ٍ ً ُ ِ َ ّ ج چ" - "و ئ ي إ أ آ ة » «" - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" - "show_numbers preferences space period Return" diff --git a/data/keyboards/ir_wide.yaml b/data/keyboards/ir_wide.yaml index 984f364d..117290ad 100644 --- a/data/keyboards/ir_wide.yaml +++ b/data/keyboards/ir_wide.yaml @@ -13,7 +13,7 @@ views: - "Shift_L ظ ط ز ر ذ د پ BackSpace" - "show_numbers preferences space period Return" upper: - - "ْ ٌ ٍ ً ُ ِ َ ّ ] [" + - "ْ ٌ ٍ ً ُ ِ َ ّ ج چ" - "و ئ ي إ أ آ ة » «" - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" - "show_numbers preferences space period Return" From 66c3926eb2a53ec03e55b25f39a6c8508c90261c Mon Sep 17 00:00:00 2001 From: jranaraki Date: Sun, 27 Dec 2020 02:01:54 -0500 Subject: [PATCH 27/51] Added requirements to resources.rs and meson.build --- data/langs/fa-IR.txt | 2 ++ src/resources.rs | 3 +++ tests/meson.build | 1 + 3 files changed, 6 insertions(+) create mode 100644 data/langs/fa-IR.txt diff --git a/data/langs/fa-IR.txt b/data/langs/fa-IR.txt new file mode 100644 index 00000000..17a65aec --- /dev/null +++ b/data/langs/fa-IR.txt @@ -0,0 +1,2 @@ +emoji ایموجی +terminal ترمینال diff --git a/src/resources.rs b/src/resources.rs index 98fb24d8..298877a6 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -47,6 +47,9 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("gr", include_str!("../data/keyboards/gr.yaml")), + ("ir", include_str!("../data/keyboards/ir.yaml")), + ("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")), + ("it", include_str!("../data/keyboards/it.yaml")), ("it+fur", include_str!("../data/keyboards/it+fur.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 017f2143..01f0dbe2 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -70,6 +70,7 @@ foreach layout : [ 'fi', 'fr', 'fr_wide', 'gr', + 'ir', 'it', 'it+fur', 'jp+kana','jp+kana_wide', From 0e83697b61b6dd9d247d0239cc0d5041336fa8d2 Mon Sep 17 00:00:00 2001 From: jranaraki Date: Sun, 27 Dec 2020 12:38:29 -0500 Subject: [PATCH 28/51] Updated the layout to provide more convenient and faster typing experience --- data/keyboards/ir.yaml | 12 ++++++------ data/keyboards/ir_wide.yaml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data/keyboards/ir.yaml b/data/keyboards/ir.yaml index 33ced36a..310e0789 100644 --- a/data/keyboards/ir.yaml +++ b/data/keyboards/ir.yaml @@ -8,14 +8,14 @@ outlines: views: base: - - "ض ص ث ق ف غ ع ه خ ح" - - "ش س ی ب ل ا ت ن م" - - "Shift_L ظ ط ز ر ذ د پ BackSpace" + - "ض ص ق ف غ ع ه خ ح ج" + - "ش س ی ب ل ا ت ن م ک" + - "Shift_L ظ ط ز ر ذ د و BackSpace" - "show_numbers preferences space period Return" upper: - - "ْ ٌ ٍ ً ُ ِ َ ّ ج چ" - - "و ئ ي إ أ آ ة » «" - - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" + - "پ { } [ ] ّ َ ِ ُ چ" + - "ؤ‌ ئ ي‌ إ أ آ ة‌ » « گ" + - "Shift_L ك ٓ ژ ء > < ؟ BackSpace" - "show_numbers preferences space period Return" numbers: - "۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰" diff --git a/data/keyboards/ir_wide.yaml b/data/keyboards/ir_wide.yaml index 117290ad..e9df0532 100644 --- a/data/keyboards/ir_wide.yaml +++ b/data/keyboards/ir_wide.yaml @@ -8,14 +8,14 @@ outlines: views: base: - - "ض ص ث ق ف غ ع ه خ ح" - - "ش س ی ب ل ا ت ن م" - - "Shift_L ظ ط ز ر ذ د پ BackSpace" + - "ض ص ق ف غ ع ه خ ح ج" + - "ش س ی ب ل ا ت ن م ک" + - "Shift_L ظ ط ز ر ذ د و BackSpace" - "show_numbers preferences space period Return" upper: - - "ْ ٌ ٍ ً ُ ِ َ ّ ج چ" - - "و ئ ي إ أ آ ة » «" - - "Shift_L ك گ ژ ٰ ‌ ٔ ء BackSpace" + - "پ { } [ ] ّ َ ِ ُ چ" + - "ؤ‌ ئ ي‌ إ أ آ ة‌ » « گ" + - "Shift_L ك ٓ ژ ء > < ؟ BackSpace" - "show_numbers preferences space period Return" numbers: - "۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰" From 3cbfd8351c73d05260d3ac7123f94a2291dd46fe Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 10 Jan 2021 10:16:07 +0000 Subject: [PATCH 29/51] imservice: Increment serials on receiving done, not sending commit No idea how that managed to stay undetected for so long. --- src/imservice.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/imservice.rs b/src/imservice.rs index 462c4203..e8723e2f 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -149,6 +149,8 @@ pub mod c { ..IMProtocolState::default() }; + imservice.serial += Wrapping(1u32); + if active_changed { (imservice.active_callback)(imservice.current.active); if imservice.current.active { @@ -404,7 +406,6 @@ impl IMService { unsafe { c::eek_input_method_commit(self.im, self.serial.0) } - self.serial += Wrapping(1u32); Ok(()) }, false => Err(SubmitError::NotActive), From 38842f9743e8cf3bfc4962f5241944b2064fade9 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 10 Jan 2021 10:45:14 +0000 Subject: [PATCH 30/51] input-method: Fix commit/done mixup in protocol text --- protocols/input-method-unstable-v2.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/input-method-unstable-v2.xml b/protocols/input-method-unstable-v2.xml index 97484d81..a51b98a3 100644 --- a/protocols/input-method-unstable-v2.xml +++ b/protocols/input-method-unstable-v2.xml @@ -294,8 +294,8 @@ The serial number reflects the last state of the zwp_input_method_v2 object known to the client. The value of the serial argument must be - equal to the number of commit requests already issued on that object. - When the compositor receives a done event with a serial different than + equal to the number of done events already issued on that object. + When the compositor receives a commit request with a serial different than the number of past commit requests, it must proceed as normal, except it should not change the current state of the zwp_input_method_v2 object. From 0c179560b3f52e8de4ce28fe687c40080ed25123 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 9 Jan 2021 07:20:59 +0000 Subject: [PATCH 31/51] visibility: Stop calling GTK functions from the visibility manager The viibility manager state is changed from various handlers, which are not guaranteed to be reentrant, most notably the Wayland handler for preedit done. As the state is changed, relevant requests to synchronize user-visible UI are fired from the same handler. In case of imservice_handle_done, GTK widget show function was being called, which triggered another round of handling Wayland, leading to the done handler being called again, and flaking out. To solve this, the phase of issuing commands needs to be separate from adjusting desired state. It seems that the easiest solution is to delay the show() and hide() calls into the next GTK main loop spin. A better solution would probably inject itself directly after the change of desired state, so that *all* the side effects are delayed. --- src/server-context-service.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/server-context-service.c b/src/server-context-service.c index 8c907848..5541e3e1 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -239,6 +239,13 @@ server_context_service_real_show_keyboard (ServerContextService *self) gtk_widget_show (GTK_WIDGET(self->window)); } +static gboolean +show_keyboard_source_func(ServerContextService *context) +{ + server_context_service_real_show_keyboard(context); + return G_SOURCE_REMOVE; +} + static void server_context_service_real_hide_keyboard (ServerContextService *self) { @@ -246,6 +253,13 @@ server_context_service_real_hide_keyboard (ServerContextService *self) self->visible = FALSE; } +static gboolean +hide_keyboard_source_func(ServerContextService *context) +{ + server_context_service_real_hide_keyboard(context); + return G_SOURCE_REMOVE; +} + static gboolean on_hide (ServerContextService *self) { @@ -266,7 +280,7 @@ server_context_service_show_keyboard (ServerContextService *self) } if (!self->visible) { - server_context_service_real_show_keyboard (self); + g_idle_add((GSourceFunc)show_keyboard_source_func, self); } } @@ -289,7 +303,7 @@ server_context_service_hide_keyboard (ServerContextService *self) g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self)); if (self->visible) { - server_context_service_real_hide_keyboard (self); + g_idle_add((GSourceFunc)hide_keyboard_source_func, self); } } From 21c3a74019f5522bbadcef2a6bff2f337330d6cf Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 10 Jan 2021 09:42:36 +0000 Subject: [PATCH 32/51] cargo: Update dependencies for release --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8be6b59..346ebe6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95752358c8f7552394baf48cd82695b345628ad3f170d607de3ca03b8dacca15" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" [[package]] name = "clap" @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" +checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" [[package]] name = "fragile" @@ -265,15 +265,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "maplit" @@ -335,9 +335,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -353,9 +353,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "rs" @@ -380,18 +380,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ "proc-macro2", "quote", @@ -400,9 +400,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7baae0a99f1a324984bcdc5f0718384c1f69775f1c7eec8b859b71b443e3fd7" +checksum = "971be8f6e4d4a47163b405a3df70d14359186f9ab0f3a3ec37df144ca1ce089f" dependencies = [ "dtoa", "linked-hash-map", @@ -412,9 +412,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.48" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" dependencies = [ "proc-macro2", "quote", @@ -476,9 +476,9 @@ dependencies = [ [[package]] name = "yaml-rust" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] From fefebf7f6e8c86b0577b8f4fd5b16f5755723724 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 10 Jan 2021 09:45:33 +0000 Subject: [PATCH 33/51] Release 1.12.0 "Convolution" User-visible changes: - Fixed a crash related to making keyboard visible. - Better fallback: when selecting a missing layout named "fr+foo", "fr" will be used instead. - When enabling the keyboard manually, it will never be stuck in the numbers view. - Thai layout - US-Colemak layout - Czech layouts - Esperanto layout - Bulgarian layout - Improved Norwegian layout That's a lot of new layouts! Plus a bunch of stricter warnings, MIPS64el support, and reproducible building. --- debian/changelog | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ meson.build | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 83678dd6..43ced1cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,63 @@ +squeekboard (1.12.0pureos0~amber0) amber-phone; urgency=medium + + [ Dorota Czaplejewicz ] + * docs: Correct Cargo update instructions + * visibility: Centralize keyboard panel visibility policy and handling + * build: Fix release + * tests: Prefer the env var for finding test layouts + * tests: Explicitly pass source directory to tests + * debian: Build reproducibly + * tests: Allow legacy mode to have much longer tests. + * build: Enable unused warnings in C + * build: Enable wformat to remove warnings about missing wformat + * build: Fail on any C warnings when strict + * data: Made data flow in fallback clearer + * data: Flattened layout fallback function + * layouts: Use base as fallback for alternative layouts + * layouts: Simplify the main flow of source list + * tests: Add some description to the list of tested layouts + * layout_names: Unmess the list of builtin layouts + * dbus: Reset hints if text input missing + * visibility: Stop calling GTK functions from the visibility manager + + [ Wannaphong Phatthiyaphaibun ] + * Add thai keyboard + * Update resources.rs + * Update meson.build + * escape " on thai keyboard + + [ clonex10100 ] + * Added US Colemak Keyboard Layout + + [ Henry-Nicolas Tourneur ] + * d/rules: fix an FTBFS on mips64el with GOT > 64kb + * d/rules: export RUSTFLAGS only on architecture that needs it + * d/rules: export RUSTFLAGS only on architecture that needs it + + [ Jiří Stránský ] + * Add Czech keyboard layouts + + [ Stefan Grotz ] + * Esperanto keyboard + + [ Vladimir ] + * Bulgarian language keyboard layout + + [ Vladimir Stoilov ] + * bulgarian add translation and to needed lists + * Fix bulgarian layout size + + [ Andreas Rönnquist ] + * no: Use wide button switching between numbers, symbols and base + + [ jranaraki ] + * Farsi/Persian keyboard layout + * Farsi/Persian keyboard layout + * Added requirements to resources.rs and meson.build + * Updated the layout to provide more convenient and faster typing experience + + -- Dorota Czaplejewicz Sun, 10 Jan 2021 09:43:42 +0000 + squeekboard (1.11.1) amber-phone; urgency=medium [ Mark Müller ] diff --git a/meson.build b/meson.build index 95903ab9..5a049fed 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'squeekboard', 'c', 'rust', - version: '1.10.0', + version: '1.12.0', license: 'GPLv3', meson_version: '>=0.51.0', default_options: [ From a332efca45b686153f018fd6d64d4363c35cbdd2 Mon Sep 17 00:00:00 2001 From: "J.D. Laub" Date: Sat, 23 Jan 2021 16:42:02 -0700 Subject: [PATCH 34/51] Add US Dvorak layout (and Colemak wide) Signed-off-by: Dave Laub --- data/keyboards/us+colemak_wide.yaml | 78 +++++++++++++++++++++++++ data/keyboards/us+dvorak.yaml | 89 +++++++++++++++++++++++++++++ data/keyboards/us+dvorak_wide.yaml | 89 +++++++++++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 data/keyboards/us+colemak_wide.yaml create mode 100644 data/keyboards/us+dvorak.yaml create mode 100644 data/keyboards/us+dvorak_wide.yaml diff --git a/data/keyboards/us+colemak_wide.yaml b/data/keyboards/us+colemak_wide.yaml new file mode 100644 index 00000000..8deb9ce0 --- /dev/null +++ b/data/keyboards/us+colemak_wide.yaml @@ -0,0 +1,78 @@ +--- +outlines: + default: { width: 54, height: 42 } + altline: { width: 81, height: 42 } + wide: { width: 108, height: 42 } + spaceline: { width: 216, height: 42 } + special: { width: 54, height: 42 } + +views: + base: + - "q w f p g j l u y" + - "a r s t d h n e i o" + - "Shift_L z x c v b k m BackSpace" + - "show_numbers preferences space . Return" + upper: + - "Q W F P G J L U Y" + - "A R S T D H N E I O" + - "Shift_L Z X C V B K M BackSpace" + - "show_numbers preferences space . Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences space . Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space . 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: "*/=" + ".": + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/data/keyboards/us+dvorak.yaml b/data/keyboards/us+dvorak.yaml new file mode 100644 index 00000000..bbbf8436 --- /dev/null +++ b/data/keyboards/us+dvorak.yaml @@ -0,0 +1,89 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "Shift_L p y f g c r l BackSpace" + - "a o e u i d h t n s" + - ", q j k x b m w v z" + - "show_numbers preferences space period Return" + upper: + - "Shift_L P Y F G C R L BackSpace" + - "A O E U I D H T N S" + - ", Q J K X B M W V Z" + - "show_numbers preferences space period Return" + numbers: + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "* # $ / & - _ + ( )" + - "1 2 3 4 5 6 7 8 9 0" + - "show_letters preferences space period Return" + symbols: + - "show_numbers_from_symbols \\ % < > = [ ] BackSpace" + - "© ® £ € ¥ ^ ° @ { }" + - "~ ` | · √ π τ ÷ × ¶" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" + +# The US QWERTY layout has fewer letters on the third row, and so has +# the shift & backspace keys placed there. In contrast, the US DVORAK +# layout has fewer letters on the first row, which makes it a good +# choice for the shift & backspace keys. That leads to what may be, +# for many people, an unexpected layout in numbers mode: the numerals +# are on the third row (not the first) so that the backspace key +# remains in a consistent location regardless of mode, without +# sacrificing key width. (Once could argue that in numbers mode, the +# numerals should be closer to the enter key.) As with any keyboard +# layout, familiarity comes with repeated use. diff --git a/data/keyboards/us+dvorak_wide.yaml b/data/keyboards/us+dvorak_wide.yaml new file mode 100644 index 00000000..04bbef7e --- /dev/null +++ b/data/keyboards/us+dvorak_wide.yaml @@ -0,0 +1,89 @@ +--- +outlines: + default: { width: 54, height: 42 } + altline: { width: 81, height: 42 } + wide: { width: 108, height: 42 } + spaceline: { width: 216, height: 42 } + special: { width: 54, height: 42 } + +views: + base: + - "Shift_L p y f g c r l BackSpace" + - "a o e u i d h t n s" + - ", q j k x b m w v z" + - "show_numbers preferences space period Return" + upper: + - "Shift_L P Y F G C R L BackSpace" + - "A O E U I D H T N S" + - ", Q J K X B M W V Z" + - "show_numbers preferences space period Return" + numbers: + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "* # $ / & - _ + ( )" + - "1 2 3 4 5 6 7 8 9 0" + - "show_letters preferences space period Return" + symbols: + - "show_numbers_from_symbols \\ % < > = [ ] BackSpace" + - "© ® £ € ¥ ^ ° @ { }" + - "~ ` | · √ π τ ÷ × ¶" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" + +# The US QWERTY layout has fewer letters on the third row, and so has +# the shift & backspace keys placed there. In contrast, the US DVORAK +# layout has fewer letters on the first row, which makes it a good +# choice for the shift & backspace keys. That leads to what may be, +# for many people, an unexpected layout in numbers mode: the numerals +# are on the third row (not the first) so that the backspace key +# remains in a consistent location regardless of mode, without +# sacrificing key width. (Once could argue that in numbers mode, the +# numerals should be closer to the enter key.) As with any keyboard +# layout, familiarity comes with repeated use. From 630cfc8e59a1e009eeaaf59fc7c3ce80334ec8fa Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 24 Jan 2021 06:07:06 +0000 Subject: [PATCH 35/51] CI: fix xheck_tag to be compatible with Amber --- debian/check_release.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/check_release.py b/debian/check_release.py index 66788911..7eb64fcb 100755 --- a/debian/check_release.py +++ b/debian/check_release.py @@ -5,6 +5,7 @@ Feed it the first changelog line, and then all available tags. """ import re, sys -tag = "v" + re.findall("\\((.*)\\)", input())[0] +version = re.findall("\\((.*)\\)", input())[0] +tag = 'v' + re.findall("([0-9]+\\.[0-9]+\\.[0-9]+).*", version)[0] if tag not in map(str.strip, sys.stdin.readlines()): raise Exception("Changelog's current version doesn't have a tag. Push the tag!") From eb7d0d5db958191bd1423078ed3c676c242f3871 Mon Sep 17 00:00:00 2001 From: "J.D. Laub" Date: Sun, 24 Jan 2021 10:48:12 -0700 Subject: [PATCH 36/51] Add US Dvorak layout (and Colemak wide) Signed-off-by: Dave Laub --- src/resources.rs | 4 ++++ tests/meson.build | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/resources.rs b/src/resources.rs index 298877a6..33944f83 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -70,6 +70,10 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("ua", include_str!("../data/keyboards/ua.yaml")), ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), + ("us+colemak_wide", include_str!("../data/keyboards/us+colemak_wide.yaml")), + + ("us+dvorak", include_str!("../data/keyboards/us+dvorak.yaml")), + ("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")), // Others ("number", include_str!("../data/keyboards/number.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 01f0dbe2..7ded8397 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -80,7 +80,8 @@ foreach layout : [ 'se', 'th', 'ua', - 'us+colemak', + 'us+colemak', 'us+colemak_wide', + 'us+dvorak', 'us+dvorak_wide', # Block: Not languages. 'emoji', From a030f55a7ce48bc235f1be774b8b9ee1679f5155 Mon Sep 17 00:00:00 2001 From: Jordi Masip Date: Sun, 7 Jun 2020 22:49:50 +0200 Subject: [PATCH 37/51] Catalan keyboard layout Modified by Dorota Czaplejewicz --- data/keyboards/es+cat.yaml | 87 ++++++++++++++++++++++++++++++++++++++ src/resources.rs | 1 + tests/meson.build | 1 + 3 files changed, 89 insertions(+) create mode 100644 data/keyboards/es+cat.yaml diff --git a/data/keyboards/es+cat.yaml b/data/keyboards/es+cat.yaml new file mode 100644 index 00000000..9be53258 --- /dev/null +++ b/data/keyboards/es+cat.yaml @@ -0,0 +1,87 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 99.67, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "q w e r t y u i o p" + - "a s d f g h j k l ç" + - "Shift_L z x c v b n m BackSpace" + - "show_numbers show_eschars preferences space ? period Return" + upper: + - "Q W E R T Y U I O P" + - "A S D F G H J K L Ç" + - "Shift_L Z X C V B N M BackSpace" + - "show_numbers show_eschars preferences space ¿ period Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # € % & - _ + ( )" + - "show_symbols , \" ' colon ; ! = BackSpace" + - "show_letters show_eschars preferences space ? period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ $ ¥ ^ ° * { }" + - "show_numbers \\ / < > = [ ] BackSpace" + - "show_letters show_eschars preferences space ? period Return" + eschars: + - "á é í ó ú Á É Í Ó Ú" + - "à è ì ò ù À È Ì Ò Ù" + - "show_numbers ü ç ï Ü Ç Ï ¡ BackSpace" + - "show_letters show_eschars preferences space « » 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: "default" + icon: "keyboard-mode-symbolic" + show_numbers: + action: + set_view: "numbers" + outline: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "altline" + label: "abc" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + show_eschars: + action: + locking: + lock_view: "eschars" + unlock_view: "base" + outline: "altline" + label: "àÀ" + + period: + outline: "default" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "altline" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" + diff --git a/src/resources.rs b/src/resources.rs index 298877a6..dc07ed6d 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -39,6 +39,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("epo", include_str!("../data/keyboards/epo.yaml")), ("es", include_str!("../data/keyboards/es.yaml")), + ("es+cat", include_str!("../data/keyboards/es+cat.yaml")), ("fi", include_str!("../data/keyboards/fi.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 01f0dbe2..1ff09448 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -67,6 +67,7 @@ foreach layout : [ 'dk', 'epo', 'es', + 'es+cat', 'fi', 'fr', 'fr_wide', 'gr', From e82e2565812a6de20c9d16e1c57af8f26081548b Mon Sep 17 00:00:00 2001 From: Myth Date: Sat, 6 Feb 2021 10:45:12 +0000 Subject: [PATCH 38/51] Added hebrew keyboard layout --- data/keyboards/il.yaml | 79 ++++++++++++++++++++++++++++++++++++++++++ data/langs/he_IL.txt | 0 src/resources.rs | 2 ++ tests/meson.build | 1 + 4 files changed, 82 insertions(+) create mode 100644 data/keyboards/il.yaml create mode 100644 data/langs/he_IL.txt diff --git a/data/keyboards/il.yaml b/data/keyboards/il.yaml new file mode 100644 index 00000000..68b34daa --- /dev/null +++ b/data/keyboards/il.yaml @@ -0,0 +1,79 @@ +--- +outlines: + default: { width: 35.33, height: 52 } + altline: { width: 52.67, height: 52 } + wide: { width: 62, height: 52 } + spaceline: { width: 142, height: 52 } + special: { width: 44, height: 52 } + +views: + base: + - "ך ף ק ר א ט ו ן ם פ" + - "ץ ת ש ד ג כ ע י ח ל" + - "Shift_L ז ס ב ה נ מ צ BackSpace" + - "show_numbers preferences space period Return" + upper: + - "Q W E R T Y U I O P" + - "A S D F G H J K L" + - "Shift_L Z X C V B N M BackSpace" + - "show_numbers preferences space period Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences space period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences space 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "ABC" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" + diff --git a/data/langs/he_IL.txt b/data/langs/he_IL.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/resources.rs b/src/resources.rs index 33944f83..c9812fd0 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -47,6 +47,8 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("gr", include_str!("../data/keyboards/gr.yaml")), + ("il", include_str!("../data/keyboards/il.yaml")), + ("ir", include_str!("../data/keyboards/ir.yaml")), ("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")), diff --git a/tests/meson.build b/tests/meson.build index 7ded8397..3cbcef32 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -70,6 +70,7 @@ foreach layout : [ 'fi', 'fr', 'fr_wide', 'gr', + 'il', 'ir', 'it', 'it+fur', From a265427e8ec0bf00ce7fdb7caaff0396d0456599 Mon Sep 17 00:00:00 2001 From: David96 Date: Thu, 11 Feb 2021 18:04:13 +0100 Subject: [PATCH 39/51] Add Mod4 (Windows) key --- src/action.rs | 1 + src/data.rs | 3 +++ src/submission.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/action.rs b/src/action.rs index 693dd1c5..c56462f7 100644 --- a/src/action.rs +++ b/src/action.rs @@ -17,6 +17,7 @@ pub enum Modifier { /// so it's simple to implement as levels are deprecated in squeekboard. Control, Alt, + Mod4, } /// Action to perform on the keypress and, in reverse, on keyrelease diff --git a/src/data.rs b/src/data.rs index e559c515..ecc63fe4 100644 --- a/src/data.rs +++ b/src/data.rs @@ -658,6 +658,9 @@ fn create_action( Modifier::Alt => action::Action::ApplyModifier( action::Modifier::Alt, ), + Modifier::Mod4 => action::Action::ApplyModifier( + action::Modifier::Mod4, + ), unsupported_modifier => { warning_handler.handle( logging::Level::Bug, diff --git a/src/submission.rs b/src/submission.rs index ba9f0c7a..e2230718 100644 --- a/src/submission.rs +++ b/src/submission.rs @@ -270,6 +270,7 @@ impl Submission { .map(|(_id, m)| match m { Modifier::Control => Modifiers::CONTROL, Modifier::Alt => Modifiers::MOD1, + Modifier::Mod4 => Modifiers::MOD4, }) .fold(Modifiers::empty(), |m, n| m | n); self.virtual_keyboard.set_modifiers_state(raw_modifiers); From 11952ed29a25a8229e368826fb21b34d0bb04452 Mon Sep 17 00:00:00 2001 From: Panawat Wong-klaew Date: Sat, 13 Feb 2021 15:11:16 +0000 Subject: [PATCH 40/51] Add wide Thai keyboard layout --- data/keyboards/th_wide.yaml | 84 +++++++++++++++++++++++++++++++++++++ src/resources.rs | 1 + tests/meson.build | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 data/keyboards/th_wide.yaml diff --git a/data/keyboards/th_wide.yaml b/data/keyboards/th_wide.yaml new file mode 100644 index 00000000..722aef2b --- /dev/null +++ b/data/keyboards/th_wide.yaml @@ -0,0 +1,84 @@ +--- +outlines: + default: { width: 75, height: 56 } + altline: { width: 75, height: 56 } + wide: { width: 135, height: 56 } + spaceline: { width: 450, height: 56 } + spacelinesymbol: { width: 300, height: 56 } + special: { width: 90, height: 56 } + +views: + base: + - "ๅ / _ ภ ถ ุ ึ ค ต จ ข ช" + - "ๆ ไ ำ พ ะ ั ี ร น ย บ ล" + - "ฟ ห ก ด เ ้ ่ า ส ว ง ฃ" + - "Shift_L ผ ป แ อ ิ ื ท ม ใ ฝ BackSpace" + - "show_numbers preferences space period Return" + upper: + - "+ ๑ ๒ ๓ ๔ ู ฿ ๕ ๖ ๗ ๘ ๙" + - "๐ \" ฎ ฑ ธ ํ ๊ ณ ฯ ญ ฐ ," + - "ฤ ฆ ฏ โ ฌ ็ ๋ ษ ศ ซ . ฅ" + - "Shift_L ( ) ฉ ฮ ฺ ์ ? ฒ ฬ ฦ BackSpace" + - "show_numbers preferences space period Return" + numbers: + - "1 2 3 4 5 6 7 8 9 0" + - "@ # $ % & - _ + ( )" + - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_letters preferences spacesymbol period Return" + symbols: + - "~ ` | · √ π τ ÷ × ¶" + - "© ® £ € ¥ ^ ° * { }" + - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" + - "show_letters preferences spacesymbol 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: "altline" + label: "123" + show_letters: + action: + set_view: "base" + outline: "wide" + label: "กขค" + show_symbols: + action: + set_view: "symbols" + outline: "altline" + label: "*/=" + period: + outline: "special" + text: "." + space: + outline: "spaceline" + text: " " + spacesymbol: + outline: "spacelinesymbol" + text: " " + Return: + outline: "wide" + icon: "key-enter" + keysym: "Return" + colon: + text: ":" diff --git a/src/resources.rs b/src/resources.rs index 0cd7f595..cb7544b9 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -69,6 +69,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ ("se", include_str!("../data/keyboards/se.yaml")), ("th", include_str!("../data/keyboards/th.yaml")), + ("th_wide", include_str!("../data/keyboards/th_wide.yaml")), ("ua", include_str!("../data/keyboards/ua.yaml")), diff --git a/tests/meson.build b/tests/meson.build index a59e95c0..ad86a7c6 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -80,7 +80,7 @@ foreach layout : [ 'pl', 'pl_wide', 'ru', 'se', - 'th', + 'th', 'th_wide', 'ua', 'us+colemak', 'us+colemak_wide', 'us+dvorak', 'us+dvorak_wide', From d3cd7dc11f41538b0e9e8a43722f8e60e18dc3f3 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 9 Mar 2021 14:09:59 +0000 Subject: [PATCH 41/51] italian: Fix colon --- data/keyboards/it+fur.yaml | 7 ++----- data/keyboards/it.yaml | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/data/keyboards/it+fur.yaml b/data/keyboards/it+fur.yaml index 1f81234d..cc34b1d5 100644 --- a/data/keyboards/it+fur.yaml +++ b/data/keyboards/it+fur.yaml @@ -22,7 +22,7 @@ views: numbers: - "1 2 3 4 5 6 7 8 9 0" - "@ # € % & - _ + ( )" - - "show_symbols , \" ' colon ; ! = BackSpace" + - "show_symbols , \" ' : ; ! = BackSpace" - "show_letters show_eschars preferences space ? . Return" symbols: - "~ ` | · √ π τ ÷ × ¶" @@ -86,7 +86,4 @@ buttons: outline: "altline" icon: "key-enter" keysym: "Return" - colon: - label: ":" - "\"": - keysym: "quotedbl" + diff --git a/data/keyboards/it.yaml b/data/keyboards/it.yaml index 2c727010..09093fdf 100644 --- a/data/keyboards/it.yaml +++ b/data/keyboards/it.yaml @@ -22,7 +22,7 @@ views: numbers: - "1 2 3 4 5 6 7 8 9 0" - "@ # € % & - _ + ( )" - - "show_symbols , \" ' colon ; ! ? BackSpace" + - "show_symbols , \" ' : ; ! ? BackSpace" - "show_letters show_eschars preferences space ? . Return" symbols: - "~ ` | · √ π τ ÷ × ¶" @@ -84,7 +84,4 @@ buttons: outline: "altline" icon: "key-enter" keysym: "Return" - colon: - label: ":" - "\"": - keysym: "quotedbl" + From 1ae29ff7bc5c814d7e8fe5355ad322c7007941ff Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 9 Mar 2021 14:36:32 +0000 Subject: [PATCH 42/51] popover: Fix prematurely deallocated CString --- src/popover.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/popover.rs b/src/popover.rs index 5605056e..7535ecb1 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -437,7 +437,8 @@ pub fn show( let settings_action = gio::SimpleAction::new("settings", None); settings_action.connect_activate(move |_, _| { - unsafe { c::popover_open_settings_panel(CString::new("region").unwrap().as_ptr()) }; + let s = CString::new("region").unwrap(); + unsafe { c::popover_open_settings_panel(s.as_ptr()) }; }); let action_group = gio::SimpleActionGroup::new(); From c2c379b870a767c6e35c234cb69beedf4f6f1bc4 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Tue, 9 Mar 2021 14:59:23 +0000 Subject: [PATCH 43/51] Rust: Remove unnecessary no_mangle statements to silence warnings --- src/drawing.rs | 1 - src/imservice.rs | 2 +- src/layout.rs | 1 - src/locale.rs | 1 - src/manager.rs | 1 - src/popover.rs | 1 - src/ui_manager.rs | 1 - src/vkeyboard.rs | 1 - 8 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/drawing.rs b/src/drawing.rs index 5a0f91ad..58210268 100644 --- a/src/drawing.rs +++ b/src/drawing.rs @@ -24,7 +24,6 @@ mod c { #[derive(Clone, Copy)] pub struct EekRenderer(*const c_void); - #[no_mangle] extern "C" { // Button and View inside CButtonPlace are safe to pass to C // as long as they don't outlive the call diff --git a/src/imservice.rs b/src/imservice.rs index e8723e2f..3a87de4b 100644 --- a/src/imservice.rs +++ b/src/imservice.rs @@ -32,9 +32,9 @@ pub mod c { #[repr(transparent)] pub struct InputMethod(*const c_void); - #[no_mangle] extern "C" { fn imservice_destroy_im(im: *mut c::InputMethod); + #[allow(improper_ctypes)] // IMService will never be dereferenced in C pub fn imservice_connect_listeners(im: *mut InputMethod, imservice: *const IMService); pub fn eek_input_method_commit_string(im: *mut InputMethod, text: *const c_char); diff --git a/src/layout.rs b/src/layout.rs index 03b20039..c464a522 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -52,7 +52,6 @@ pub mod c { #[derive(Copy, Clone)] pub struct EekGtkKeyboard(pub *const gtk_sys::GtkWidget); - #[no_mangle] extern "C" { #[allow(improper_ctypes)] pub fn eek_gtk_keyboard_emit_feedback( diff --git a/src/locale.rs b/src/locale.rs index 03e6bd9c..63ff6fca 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -24,7 +24,6 @@ mod c { #[repr(C)] pub struct GnomeXkbInfo(*const c_void); - #[no_mangle] extern "C" { // from libc pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; diff --git a/src/manager.rs b/src/manager.rs index 42d1ce26..55fc561a 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -9,7 +9,6 @@ pub mod c { #[derive(Clone, Copy)] pub struct Manager(*const c_void); - #[no_mangle] extern "C" { pub fn eekboard_context_service_set_overlay( manager: Manager, diff --git a/src/popover.rs b/src/popover.rs index 7535ecb1..92103869 100644 --- a/src/popover.rs +++ b/src/popover.rs @@ -29,7 +29,6 @@ use ::logging::Warn; mod c { use std::os::raw::c_char; - #[no_mangle] extern "C" { pub fn popover_open_settings_panel(panel: *const c_char); } diff --git a/src/ui_manager.rs b/src/ui_manager.rs index a9196c1b..3aa3f0b1 100644 --- a/src/ui_manager.rs +++ b/src/ui_manager.rs @@ -19,7 +19,6 @@ pub mod c { #[repr(transparent)] pub struct UIManager(*const c_void); - #[no_mangle] extern "C" { pub fn server_context_service_update_visible(imservice: *const UIManager, active: u32); pub fn server_context_service_release_visibility(imservice: *const UIManager); diff --git a/src/vkeyboard.rs b/src/vkeyboard.rs index 54f3142f..aff822a7 100644 --- a/src/vkeyboard.rs +++ b/src/vkeyboard.rs @@ -37,7 +37,6 @@ pub mod c { } } - #[no_mangle] extern "C" { // From libc, to let KeyMap get deallocated. fn close(fd: u32); From 46f8790fc09bfe34b4685ed8277bb7f38a6445c9 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 17 Mar 2021 13:29:02 +0000 Subject: [PATCH 44/51] renderer: Reduce reliance on knowing the transform --- eek/eek-gtk-keyboard.c | 2 +- eek/eek-renderer.c | 5 +++-- eek/eek-renderer.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index 071d0703..a574d6c6 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -100,7 +100,7 @@ eek_gtk_keyboard_real_draw (GtkWidget *self, gtk_widget_get_scale_factor (self)); } - eek_renderer_render_keyboard (priv->renderer, priv->submission, cr, priv->keyboard); + eek_renderer_render_keyboard (priv->renderer, priv->renderer->widget_to_layout, priv->submission, cr, priv->keyboard); return FALSE; } diff --git a/eek/eek-renderer.c b/eek/eek-renderer.c index 143c553e..84556f35 100644 --- a/eek/eek-renderer.c +++ b/eek/eek-renderer.c @@ -194,6 +194,7 @@ render_button_label (cairo_t *cr, // FIXME: Pass just the active modifiers instead of entire submission void eek_renderer_render_keyboard (EekRenderer *self, + struct transformation widget_to_layout, struct submission *submission, cairo_t *cr, LevelKeyboard *keyboard) @@ -208,8 +209,8 @@ eek_renderer_render_keyboard (EekRenderer *self, self->allocation_width, self->allocation_height); cairo_save(cr); - cairo_translate (cr, self->widget_to_layout.origin_x, self->widget_to_layout.origin_y); - cairo_scale (cr, self->widget_to_layout.scale, self->widget_to_layout.scale); + cairo_translate (cr, widget_to_layout.origin_x, widget_to_layout.origin_y); + cairo_scale (cr, widget_to_layout.scale, widget_to_layout.scale); squeek_draw_layout_base_view(keyboard->layout, self, cr); squeek_layout_draw_all_changed(keyboard->layout, self, cr, submission); diff --git a/eek/eek-renderer.h b/eek/eek-renderer.h index f1823456..bc8bfc7a 100644 --- a/eek/eek-renderer.h +++ b/eek/eek-renderer.h @@ -64,7 +64,7 @@ cairo_surface_t *eek_renderer_get_icon_surface(const gchar *icon_name, gint size, gint scale); -void eek_renderer_render_keyboard (EekRenderer *renderer, struct submission *submission, +void eek_renderer_render_keyboard (EekRenderer *renderer, struct transformation widget_to_layout, struct submission *submission, cairo_t *cr, LevelKeyboard *keyboard); void eek_renderer_free (EekRenderer *self); From 24c3fac5057f1c0e09f7acf43a9b57b2291b1736 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 17 Mar 2021 13:56:34 +0000 Subject: [PATCH 45/51] renderer: Split mutable geometry and place it directly in GtkKeyboard Geometry is now permanently married to the widget rather the renderer. While geometry is not always defined, C doesn't support sum types, so checks won't be enforced by the compiler. It's OK to pretend there's always some geometry to avoid crashes. --- eek/eek-gtk-keyboard.c | 58 +++++++++++++++++++++++++++++++----------- eek/eek-gtk-keyboard.h | 1 + eek/eek-renderer.c | 41 +++++++++++------------------ eek/eek-renderer.h | 22 ++++++++-------- 4 files changed, 71 insertions(+), 51 deletions(-) diff --git a/eek/eek-gtk-keyboard.c b/eek/eek-gtk-keyboard.c index a574d6c6..17f16e11 100644 --- a/eek/eek-gtk-keyboard.c +++ b/eek/eek-gtk-keyboard.c @@ -45,6 +45,8 @@ typedef struct _EekGtkKeyboardPrivate { EekRenderer *renderer; // owned, nullable + struct render_geometry render_geometry; // mutable + EekboardContextService *eekboard_context; // unowned reference struct submission *submission; // unowned reference @@ -72,12 +74,23 @@ eek_gtk_keyboard_real_realize (GtkWidget *self) GTK_WIDGET_CLASS (eek_gtk_keyboard_parent_class)->realize (self); } +static void set_allocation_size(EekGtkKeyboard *gtk_keyboard, + struct squeek_layout *layout, gdouble width, gdouble height) +{ + // This is where size-dependent surfaces would be released + EekGtkKeyboardPrivate *priv = + eek_gtk_keyboard_get_instance_private (gtk_keyboard); + priv->render_geometry = eek_render_geometry_from_allocation_size( + layout, width, height); +} + static gboolean eek_gtk_keyboard_real_draw (GtkWidget *self, cairo_t *cr) { + EekGtkKeyboard *keyboard = EEK_GTK_KEYBOARD (self); EekGtkKeyboardPrivate *priv = - eek_gtk_keyboard_get_instance_private (EEK_GTK_KEYBOARD (self)); + eek_gtk_keyboard_get_instance_private (keyboard); GtkAllocation allocation; gtk_widget_get_allocation (self, &allocation); @@ -92,15 +105,14 @@ eek_gtk_keyboard_real_draw (GtkWidget *self, priv->keyboard, pcontext); - eek_renderer_set_allocation_size (priv->renderer, - priv->keyboard->layout, - allocation.width, - allocation.height); + set_allocation_size (keyboard, priv->keyboard->layout, + allocation.width, allocation.height); eek_renderer_set_scale_factor (priv->renderer, gtk_widget_get_scale_factor (self)); } - eek_renderer_render_keyboard (priv->renderer, priv->renderer->widget_to_layout, priv->submission, cr, priv->keyboard); + eek_renderer_render_keyboard (priv->renderer, priv->render_geometry, + priv->submission, cr, priv->keyboard); return FALSE; } @@ -117,8 +129,9 @@ static void eek_gtk_keyboard_real_size_allocate (GtkWidget *self, GtkAllocation *allocation) { + EekGtkKeyboard *keyboard = EEK_GTK_KEYBOARD (self); EekGtkKeyboardPrivate *priv = - eek_gtk_keyboard_get_instance_private (EEK_GTK_KEYBOARD (self)); + eek_gtk_keyboard_get_instance_private (keyboard); // check if the change would switch types enum squeek_arrangement_kind new_type = get_type( (uint32_t)(allocation->width - allocation->x), @@ -130,10 +143,8 @@ eek_gtk_keyboard_real_size_allocate (GtkWidget *self, } if (priv->renderer) { - eek_renderer_set_allocation_size (priv->renderer, - priv->keyboard->layout, - allocation->width, - allocation->height); + set_allocation_size (keyboard, priv->keyboard->layout, + allocation->width, allocation->height); } GTK_WIDGET_CLASS (eek_gtk_keyboard_parent_class)-> @@ -162,7 +173,7 @@ static void depress(EekGtkKeyboard *self, } squeek_layout_depress(priv->keyboard->layout, priv->submission, - x, y, eek_renderer_get_transformation(priv->renderer), time, self); + x, y, priv->render_geometry.widget_to_layout, time, self); } static void drag(EekGtkKeyboard *self, @@ -174,7 +185,7 @@ static void drag(EekGtkKeyboard *self, } squeek_layout_drag(eekboard_context_service_get_keyboard(priv->eekboard_context)->layout, priv->submission, - x, y, eek_renderer_get_transformation(priv->renderer), time, + x, y, priv->render_geometry.widget_to_layout, time, priv->eekboard_context, self); } @@ -185,8 +196,7 @@ static void release(EekGtkKeyboard *self, guint32 time) return; } squeek_layout_release(eekboard_context_service_get_keyboard(priv->eekboard_context)->layout, - priv->submission, - eek_renderer_get_transformation(priv->renderer), time, + priv->submission, priv->render_geometry.widget_to_layout, time, priv->eekboard_context, self); } @@ -396,6 +406,24 @@ eek_gtk_keyboard_new (EekboardContextService *eekservice, priv->submission = submission; priv->layout = layout; priv->renderer = NULL; + // This should really be done on initialization. + // Before the widget is allocated, + // we don't really know what geometry it takes. + // When it's off the screen, we also kinda don't. + struct render_geometry initial_geometry = { + // Set to 100 just to make sure if there's any attempt to use it, + // it actually gives plausible results instead of blowing up, + // e.g. on zero division. + .allocation_width = 100, + .allocation_height = 100, + .widget_to_layout = { + .origin_x = 0, + .origin_y = 0, + .scale = 1, + }, + }; + priv->render_geometry = initial_geometry; + g_signal_connect (eekservice, "notify::keyboard", G_CALLBACK(on_notify_keyboard), diff --git a/eek/eek-gtk-keyboard.h b/eek/eek-gtk-keyboard.h index e9df72b3..faccd1fa 100644 --- a/eek/eek-gtk-keyboard.h +++ b/eek/eek-gtk-keyboard.h @@ -28,6 +28,7 @@ #include #include +#include "eek/eek-renderer.h" #include "eek/eek-types.h" struct submission; diff --git a/eek/eek-renderer.c b/eek/eek-renderer.c index 84556f35..1ae3540f 100644 --- a/eek/eek-renderer.c +++ b/eek/eek-renderer.c @@ -194,23 +194,23 @@ render_button_label (cairo_t *cr, // FIXME: Pass just the active modifiers instead of entire submission void eek_renderer_render_keyboard (EekRenderer *self, - struct transformation widget_to_layout, + struct render_geometry geometry, struct submission *submission, cairo_t *cr, LevelKeyboard *keyboard) { - g_return_if_fail (self->allocation_width > 0.0); - g_return_if_fail (self->allocation_height > 0.0); + g_return_if_fail (geometry.allocation_width > 0.0); + g_return_if_fail (geometry.allocation_height > 0.0); /* Paint the background covering the entire widget area */ gtk_render_background (self->view_context, cr, 0, 0, - self->allocation_width, self->allocation_height); + geometry.allocation_width, geometry.allocation_height); cairo_save(cr); - cairo_translate (cr, widget_to_layout.origin_x, widget_to_layout.origin_y); - cairo_scale (cr, widget_to_layout.scale, widget_to_layout.scale); + cairo_translate (cr, geometry.widget_to_layout.origin_x, geometry.widget_to_layout.origin_y); + cairo_scale (cr, geometry.widget_to_layout.scale, geometry.widget_to_layout.scale); squeek_draw_layout_base_view(keyboard->layout, self, cr); squeek_layout_draw_all_changed(keyboard->layout, self, cr, submission); @@ -262,8 +262,6 @@ static void renderer_init (EekRenderer *self) { self->pcontext = NULL; - self->allocation_width = 0.0; - self->allocation_height = 0.0; self->scale_factor = 1; self->css_provider = squeek_load_style(); @@ -310,22 +308,18 @@ eek_renderer_new (LevelKeyboard *keyboard, return renderer; } -void -eek_renderer_set_allocation_size (EekRenderer *renderer, - struct squeek_layout *layout, +struct render_geometry +eek_render_geometry_from_allocation_size (struct squeek_layout *layout, gdouble width, gdouble height) { - g_return_if_fail (width > 0.0 && height > 0.0); - - renderer->allocation_width = width; - renderer->allocation_height = height; - - renderer->widget_to_layout = squeek_layout_calculate_transformation( - layout, - renderer->allocation_width, renderer->allocation_height); - - // This is where size-dependent surfaces would be released + struct render_geometry ret = { + .allocation_width = width, + .allocation_height = height, + .widget_to_layout = squeek_layout_calculate_transformation( + layout, width, height), + }; + return ret; } void @@ -357,8 +351,3 @@ eek_renderer_get_icon_surface (const gchar *icon_name, } return surface; } - -struct transformation -eek_renderer_get_transformation (EekRenderer *renderer) { - return renderer->widget_to_layout; -} diff --git a/eek/eek-renderer.h b/eek/eek-renderer.h index bc8bfc7a..a339b2ad 100644 --- a/eek/eek-renderer.h +++ b/eek/eek-renderer.h @@ -41,22 +41,23 @@ typedef struct EekRenderer gchar *extra_style; // owned // Mutable state + gint scale_factor; /* the outputs scale factor */ +} EekRenderer; + + +/// Mutable part of the renderer state. +/// TODO: Possibly should include scale factor. +struct render_geometry { /// Background extents gdouble allocation_width; gdouble allocation_height; - gint scale_factor; /* the outputs scale factor */ /// Coords transformation struct transformation widget_to_layout; -} EekRenderer; - +}; GType eek_renderer_get_type (void) G_GNUC_CONST; EekRenderer *eek_renderer_new (LevelKeyboard *keyboard, PangoContext *pcontext); -void eek_renderer_set_allocation_size - (EekRenderer *renderer, struct squeek_layout *layout, - gdouble width, - gdouble height); void eek_renderer_set_scale_factor (EekRenderer *renderer, gint scale); @@ -64,13 +65,14 @@ cairo_surface_t *eek_renderer_get_icon_surface(const gchar *icon_name, gint size, gint scale); -void eek_renderer_render_keyboard (EekRenderer *renderer, struct transformation widget_to_layout, struct submission *submission, +void eek_renderer_render_keyboard (EekRenderer *renderer, struct render_geometry geometry, struct submission *submission, cairo_t *cr, LevelKeyboard *keyboard); void eek_renderer_free (EekRenderer *self); -struct transformation -eek_renderer_get_transformation (EekRenderer *renderer); +struct render_geometry +eek_render_geometry_from_allocation_size (struct squeek_layout *layout, + gdouble width, gdouble height); G_END_DECLS #endif /* EEK_RENDERER_H */ From e800a88893722c1fb29400b0750f6dc1ab10d451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 25 Mar 2021 16:03:57 +0100 Subject: [PATCH 46/51] server-main: Add quit() This allows to exit the mainloop e.g. when signalled from gnome-session or by a signal. --- src/server-main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/server-main.c b/src/server-main.c index d199acab..dd8f3563 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -50,9 +50,16 @@ struct squeekboard { }; +GMainLoop *loop; static gboolean opt_system = FALSE; static gchar *opt_address = NULL; +static void +quit (void) +{ + g_main_loop_quit (loop); +} + // D-Bus static void @@ -307,8 +314,7 @@ main (int argc, char **argv) session_register(); - GMainLoop *loop = g_main_loop_new (NULL, FALSE); - + loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); if (connection) { From 40bf3ca5deab948dee443f330d81ab6c64814243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 25 Mar 2021 16:04:46 +0100 Subject: [PATCH 47/51] server-main: Properly register to gnome-session So far squeeboard only did half of the registration failing to respond to the signals sent by the session. This causes problems e.g. when exiting the session since the it thinks the client hangs or is busy. Closes: #274 --- src/server-main.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/src/server-main.c b/src/server-main.c index dd8f3563..1dafbac1 100644 --- a/src/server-main.c +++ b/src/server-main.c @@ -138,6 +138,67 @@ static const struct wl_registry_listener registry_listener = { #define SESSION_NAME "sm.puri.OSK0" GDBusProxy *_proxy = NULL; +GDBusProxy *_client_proxy = NULL; +gchar *_client_path = NULL; + + +static void +send_quit_response (GDBusProxy *proxy) +{ + g_debug ("Calling EndSessionResponse"); + g_dbus_proxy_call (proxy, "EndSessionResponse", + g_variant_new ("(bs)", TRUE, ""), G_DBUS_CALL_FLAGS_NONE, + G_MAXINT, NULL, NULL, NULL); +} + +static void +unregister_client (void) +{ + g_autoptr (GError) error = NULL; + + g_return_if_fail (G_IS_DBUS_PROXY (_proxy)); + g_return_if_fail (_client_path != NULL); + + g_debug ("Unregistering client"); + + g_dbus_proxy_call_sync (_proxy, + "UnregisterClient", + g_variant_new ("(o)", _client_path), + G_DBUS_CALL_FLAGS_NONE, + G_MAXINT, + NULL, + &error); + + if (error) { + g_warning ("Failed to unregister client: %s", error->message); + } + + g_clear_object (&_client_proxy); + g_clear_pointer (&_client_path, g_free); +} + +static void client_proxy_signal (GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + if (g_str_equal (signal_name, "QueryEndSession")) { + g_debug ("Received QueryEndSession"); + send_quit_response (proxy); + } else if (g_str_equal (signal_name, "CancelEndSession")) { + g_debug ("Received CancelEndSession"); + } else if (g_str_equal (signal_name, "EndSession")) { + g_debug ("Received EndSession"); + send_quit_response (proxy); + unregister_client (); + quit (); + } else if (g_str_equal (signal_name, "Stop")) { + g_debug ("Received Stop"); + unregister_client (); + quit (); + } +} static void session_register(void) { @@ -158,7 +219,8 @@ session_register(void) { return; } - g_dbus_proxy_call_sync(_proxy, "RegisterClient", + g_autoptr (GVariant) res = NULL; + res = g_dbus_proxy_call_sync(_proxy, "RegisterClient", g_variant_new("(ss)", SESSION_NAME, autostart_id), G_DBUS_CALL_FLAGS_NONE, 1000, NULL, &error); if (error) { @@ -167,6 +229,22 @@ session_register(void) { g_clear_error(&error); return; } + + g_variant_get (res, "(o)", &_client_path); + g_debug ("Registered client at '%s'", _client_path); + + _client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + 0, NULL, "org.gnome.SessionManager", _client_path, + "org.gnome.SessionManager.ClientPrivate", NULL, &error); + if (error) { + g_warning ("Failed to get client proxy: %s", error->message); + g_clear_error (&error); + g_free (_client_path); + _client_path = NULL; + return; + } + + g_signal_connect (_client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), NULL); } int From a3638f4bfb99856ffced16132aa4927da5e54e21 Mon Sep 17 00:00:00 2001 From: Kozova1 Date: Wed, 24 Mar 2021 00:07:36 +0200 Subject: [PATCH 48/51] Added Hebrew translations for most layouts. This commit adds translations in Hebrew for most layouts. Note: the hebrew file seems to be named incorrectly, is that intentional? (he_IL.txt instead of he-IL.txt) Signed-off-by: Kozova1 --- data/langs/he_IL.txt | 19 +++++++++++++++++++ src/resources.rs | 1 + 2 files changed, 20 insertions(+) diff --git a/data/langs/he_IL.txt b/data/langs/he_IL.txt index e69de29b..221cdf77 100644 --- a/data/langs/he_IL.txt +++ b/data/langs/he_IL.txt @@ -0,0 +1,19 @@ +be בלגית +br פורטוגזית (ברזיל) +cz צ'כית +de גרמנית +dk דנית +es ספרדית +emoji אימוג'י +fi פינית +fr צרפתית +gr יוונית +il עברית +it איטלקית +no נורווגית +pl פולנית +ru רוסית +se שוודית +terminal טרמינל +ua אוקראינית +us אנגלית (ארה"ב) diff --git a/src/resources.rs b/src/resources.rs index cb7544b9..d449b40f 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -122,6 +122,7 @@ const LAYOUT_NAMES: &[(*const str, *const str)] = &[ ("en-US", include_str!("../data/langs/en-US.txt")), ("es-ES", include_str!("../data/langs/es-ES.txt")), ("fur-IT", include_str!("../data/langs/fur-IT.txt")), + ("he-IL", include_str!("../data/langs/he_IL.txt")), ("ja-JP", include_str!("../data/langs/ja-JP.txt")), ("pl-PL", include_str!("../data/langs/pl-PL.txt")), ("ru-RU", include_str!("../data/langs/ru-RU.txt")), From d8ca9f47ca4d35791b8fe9a02dac7d35950a3be8 Mon Sep 17 00:00:00 2001 From: Kozova1 Date: Tue, 30 Mar 2021 20:30:53 +0300 Subject: [PATCH 49/51] moved data/langs/he_IL.txt -> data/langs/he-IL.txt to better conform with existing translations. Signed-off-by: Kozova1 --- data/langs/{he_IL.txt => he-IL.txt} | 0 src/resources.rs | 96 ++++++++++++++--------------- 2 files changed, 45 insertions(+), 51 deletions(-) rename data/langs/{he_IL.txt => he-IL.txt} (100%) diff --git a/data/langs/he_IL.txt b/data/langs/he-IL.txt similarity index 100% rename from data/langs/he_IL.txt rename to data/langs/he-IL.txt diff --git a/src/resources.rs b/src/resources.rs index d449b40f..cb352860 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -2,8 +2,8 @@ * This could be done using GResource, but that would need additional work. */ -use std::collections::HashMap; use ::locale::Translation; +use std::collections::HashMap; use std::iter::FromIterator; @@ -16,75 +16,73 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ // fallback layout. ("us", include_str!("../data/keyboards/us.yaml")), ("us_wide", include_str!("../data/keyboards/us_wide.yaml")), - // Language layouts: keep alphabetical. ("be", include_str!("../data/keyboards/be.yaml")), ("be_wide", include_str!("../data/keyboards/be_wide.yaml")), - ("bg", include_str!("../data/keyboards/bg.yaml")), - ("br", include_str!("../data/keyboards/br.yaml")), - ("de", include_str!("../data/keyboards/de.yaml")), ("de_wide", include_str!("../data/keyboards/de_wide.yaml")), - ("cz", include_str!("../data/keyboards/cz.yaml")), ("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")), - - ("cz+qwerty", include_str!("../data/keyboards/cz+qwerty.yaml")), - ("cz+qwerty_wide", include_str!("../data/keyboards/cz+qwerty_wide.yaml")), - + ( + "cz+qwerty", + include_str!("../data/keyboards/cz+qwerty.yaml"), + ), + ( + "cz+qwerty_wide", + include_str!("../data/keyboards/cz+qwerty_wide.yaml"), + ), ("dk", include_str!("../data/keyboards/dk.yaml")), - ("epo", include_str!("../data/keyboards/epo.yaml")), - ("es", include_str!("../data/keyboards/es.yaml")), ("es+cat", include_str!("../data/keyboards/es+cat.yaml")), - ("fi", include_str!("../data/keyboards/fi.yaml")), - ("fr", include_str!("../data/keyboards/fr.yaml")), ("fr_wide", include_str!("../data/keyboards/fr_wide.yaml")), - ("gr", include_str!("../data/keyboards/gr.yaml")), - ("il", include_str!("../data/keyboards/il.yaml")), - ("ir", include_str!("../data/keyboards/ir.yaml")), ("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")), - ("it", include_str!("../data/keyboards/it.yaml")), ("it+fur", include_str!("../data/keyboards/it+fur.yaml")), - ("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")), - ("jp+kana_wide", include_str!("../data/keyboards/jp+kana_wide.yaml")), - + ( + "jp+kana_wide", + include_str!("../data/keyboards/jp+kana_wide.yaml"), + ), ("no", include_str!("../data/keyboards/no.yaml")), - ("pl", include_str!("../data/keyboards/pl.yaml")), ("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")), - ("ru", include_str!("../data/keyboards/ru.yaml")), - ("se", include_str!("../data/keyboards/se.yaml")), - ("th", include_str!("../data/keyboards/th.yaml")), ("th_wide", include_str!("../data/keyboards/th_wide.yaml")), - ("ua", include_str!("../data/keyboards/ua.yaml")), - - ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), - ("us+colemak_wide", include_str!("../data/keyboards/us+colemak_wide.yaml")), - - ("us+dvorak", include_str!("../data/keyboards/us+dvorak.yaml")), - ("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")), - + ( + "us+colemak", + include_str!("../data/keyboards/us+colemak.yaml"), + ), + ( + "us+colemak_wide", + include_str!("../data/keyboards/us+colemak_wide.yaml"), + ), + ( + "us+dvorak", + include_str!("../data/keyboards/us+dvorak.yaml"), + ), + ( + "us+dvorak_wide", + include_str!("../data/keyboards/us+dvorak_wide.yaml"), + ), // Others ("number", include_str!("../data/keyboards/number.yaml")), - // layout+overlay ("terminal", include_str!("../data/keyboards/terminal.yaml")), - ("terminal_wide", include_str!("../data/keyboards/terminal_wide.yaml")), + ( + "terminal_wide", + include_str!("../data/keyboards/terminal_wide.yaml"), + ), // Overlays ("emoji", include_str!("../data/keyboards/emoji.yaml")), ]; @@ -92,7 +90,8 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ pub fn get_keyboard(needle: &str) -> Option<&'static str> { // Need to dereference in unsafe code // comparing *const str to &str will compare pointers - KEYBOARDS.iter() + KEYBOARDS + .iter() .find(|(name, _)| { let name: *const str = *name; (unsafe { &*name }) == needle @@ -103,17 +102,16 @@ pub fn get_keyboard(needle: &str) -> Option<&'static str> { }) } -const OVERLAY_NAMES: &[*const str] = &[ - "emoji", - "terminal", -]; +const OVERLAY_NAMES: &[*const str] = &["emoji", "terminal"]; pub fn get_overlays() -> Vec<&'static str> { - OVERLAY_NAMES.iter() + OVERLAY_NAMES + .iter() .map(|name| { let name: *const str = *name; unsafe { &*name } - }).collect() + }) + .collect() } /// Translations of the layout identifier strings @@ -122,16 +120,15 @@ const LAYOUT_NAMES: &[(*const str, *const str)] = &[ ("en-US", include_str!("../data/langs/en-US.txt")), ("es-ES", include_str!("../data/langs/es-ES.txt")), ("fur-IT", include_str!("../data/langs/fur-IT.txt")), - ("he-IL", include_str!("../data/langs/he_IL.txt")), + ("he-IL", include_str!("../data/langs/he-IL.txt")), ("ja-JP", include_str!("../data/langs/ja-JP.txt")), ("pl-PL", include_str!("../data/langs/pl-PL.txt")), ("ru-RU", include_str!("../data/langs/ru-RU.txt")), ]; -pub fn get_layout_names(lang: &str) - -> Option>> -{ - let translations = LAYOUT_NAMES.iter() +pub fn get_layout_names(lang: &str) -> Option>> { + let translations = LAYOUT_NAMES + .iter() .find(|(name, _data)| { let name: *const str = *name; (unsafe { &*name }) == lang @@ -156,10 +153,7 @@ fn parse_line(line: &str) -> Option<(&str, Translation)> { } fn make_mapping(data: &str) -> HashMap<&str, Translation> { - HashMap::from_iter( - data.split("\n") - .filter_map(parse_line) - ) + HashMap::from_iter(data.split("\n").filter_map(parse_line)) } #[cfg(test)] From 8da8d55b9873a36e34134cf4565476722a570183 Mon Sep 17 00:00:00 2001 From: Kozova1 Date: Wed, 24 Mar 2021 10:14:38 +0200 Subject: [PATCH 50/51] Fixed Hebrew layout. The Hebrew layout was a non standard one - this should now be fixed. The left shift key was removed, since Hebrew does not have capital letters. Signed-off-by: Kozova1 --- data/keyboards/il.yaml | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/data/keyboards/il.yaml b/data/keyboards/il.yaml index 68b34daa..b848650e 100644 --- a/data/keyboards/il.yaml +++ b/data/keyboards/il.yaml @@ -1,45 +1,37 @@ --- outlines: - default: { width: 35.33, height: 52 } - altline: { width: 52.67, height: 52 } - wide: { width: 62, height: 52 } - spaceline: { width: 142, height: 52 } - special: { width: 44, height: 52 } + default: { width: 40, height: 60 } + altline: { width: 56, height: 60 } + wide: { width: 62, height: 60 } + spaceline: { width: 142, height: 60 } + special: { width: 44, height: 60 } views: base: - - "ך ף ק ר א ט ו ן ם פ" - - "ץ ת ש ד ג כ ע י ח ל" - - "Shift_L ז ס ב ה נ מ צ BackSpace" - - "show_numbers preferences space period Return" - upper: - - "Q W E R T Y U I O P" - - "A S D F G H J K L" - - "Shift_L Z X C V B N M BackSpace" - - "show_numbers preferences space period Return" + - "' - ק ר א ט ו ן ם פ" + - "ש ד ג כ ע י ח ל ך ף" + - "ז ס ב ה נ מ צ ת ץ BackSpace" + - "show_numbers comma preferences space period Return" numbers: - "1 2 3 4 5 6 7 8 9 0" - - "@ # $ % & - _ + ( )" + - "@ # ₪ % & - _ + ( )" - "show_symbols , \" ' colon ; ! ? BackSpace" - "show_letters preferences space period Return" symbols: - "~ ` | · √ π τ ÷ × ¶" - - "© ® £ € ¥ ^ ° * { }" + - "© ® £ € $ ^ ° * { }" - "show_numbers_from_symbols \\ / < > = [ ] BackSpace" - "show_letters preferences space period Return" buttons: - Shift_L: - action: - locking: - lock_view: "upper" - unlock_view: "base" - outline: "altline" - icon: "key-shift" BackSpace: - outline: "altline" + outline: "default" icon: "edit-clear-symbolic" action: erase + comma: + outline: "special" + text: "," + preferences: action: show_prefs outline: "special" From 32dc25dfbfa81a7bc8b60ee9934d1e1e61d314fd Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Wed, 31 Mar 2021 08:39:57 +0000 Subject: [PATCH 51/51] Revert "moved data/langs/he_IL.txt -> data/langs/he-IL.txt to better conform with existing translations." This reverts commit d8ca9f47ca4d35791b8fe9a02dac7d35950a3be8. This touches way more than advertised. --- data/langs/{he-IL.txt => he_IL.txt} | 0 src/resources.rs | 96 +++++++++++++++-------------- 2 files changed, 51 insertions(+), 45 deletions(-) rename data/langs/{he-IL.txt => he_IL.txt} (100%) diff --git a/data/langs/he-IL.txt b/data/langs/he_IL.txt similarity index 100% rename from data/langs/he-IL.txt rename to data/langs/he_IL.txt diff --git a/src/resources.rs b/src/resources.rs index cb352860..d449b40f 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -2,8 +2,8 @@ * This could be done using GResource, but that would need additional work. */ -use ::locale::Translation; use std::collections::HashMap; +use ::locale::Translation; use std::iter::FromIterator; @@ -16,73 +16,75 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ // fallback layout. ("us", include_str!("../data/keyboards/us.yaml")), ("us_wide", include_str!("../data/keyboards/us_wide.yaml")), + // Language layouts: keep alphabetical. ("be", include_str!("../data/keyboards/be.yaml")), ("be_wide", include_str!("../data/keyboards/be_wide.yaml")), + ("bg", include_str!("../data/keyboards/bg.yaml")), + ("br", include_str!("../data/keyboards/br.yaml")), + ("de", include_str!("../data/keyboards/de.yaml")), ("de_wide", include_str!("../data/keyboards/de_wide.yaml")), + ("cz", include_str!("../data/keyboards/cz.yaml")), ("cz_wide", include_str!("../data/keyboards/cz_wide.yaml")), - ( - "cz+qwerty", - include_str!("../data/keyboards/cz+qwerty.yaml"), - ), - ( - "cz+qwerty_wide", - include_str!("../data/keyboards/cz+qwerty_wide.yaml"), - ), + + ("cz+qwerty", include_str!("../data/keyboards/cz+qwerty.yaml")), + ("cz+qwerty_wide", include_str!("../data/keyboards/cz+qwerty_wide.yaml")), + ("dk", include_str!("../data/keyboards/dk.yaml")), + ("epo", include_str!("../data/keyboards/epo.yaml")), + ("es", include_str!("../data/keyboards/es.yaml")), ("es+cat", include_str!("../data/keyboards/es+cat.yaml")), + ("fi", include_str!("../data/keyboards/fi.yaml")), + ("fr", include_str!("../data/keyboards/fr.yaml")), ("fr_wide", include_str!("../data/keyboards/fr_wide.yaml")), + ("gr", include_str!("../data/keyboards/gr.yaml")), + ("il", include_str!("../data/keyboards/il.yaml")), + ("ir", include_str!("../data/keyboards/ir.yaml")), ("ir_wide", include_str!("../data/keyboards/ir_wide.yaml")), + ("it", include_str!("../data/keyboards/it.yaml")), ("it+fur", include_str!("../data/keyboards/it+fur.yaml")), + ("jp+kana", include_str!("../data/keyboards/jp+kana.yaml")), - ( - "jp+kana_wide", - include_str!("../data/keyboards/jp+kana_wide.yaml"), - ), + ("jp+kana_wide", include_str!("../data/keyboards/jp+kana_wide.yaml")), + ("no", include_str!("../data/keyboards/no.yaml")), + ("pl", include_str!("../data/keyboards/pl.yaml")), ("pl_wide", include_str!("../data/keyboards/pl_wide.yaml")), + ("ru", include_str!("../data/keyboards/ru.yaml")), + ("se", include_str!("../data/keyboards/se.yaml")), + ("th", include_str!("../data/keyboards/th.yaml")), ("th_wide", include_str!("../data/keyboards/th_wide.yaml")), + ("ua", include_str!("../data/keyboards/ua.yaml")), - ( - "us+colemak", - include_str!("../data/keyboards/us+colemak.yaml"), - ), - ( - "us+colemak_wide", - include_str!("../data/keyboards/us+colemak_wide.yaml"), - ), - ( - "us+dvorak", - include_str!("../data/keyboards/us+dvorak.yaml"), - ), - ( - "us+dvorak_wide", - include_str!("../data/keyboards/us+dvorak_wide.yaml"), - ), + + ("us+colemak", include_str!("../data/keyboards/us+colemak.yaml")), + ("us+colemak_wide", include_str!("../data/keyboards/us+colemak_wide.yaml")), + + ("us+dvorak", include_str!("../data/keyboards/us+dvorak.yaml")), + ("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")), + // Others ("number", include_str!("../data/keyboards/number.yaml")), + // layout+overlay ("terminal", include_str!("../data/keyboards/terminal.yaml")), - ( - "terminal_wide", - include_str!("../data/keyboards/terminal_wide.yaml"), - ), + ("terminal_wide", include_str!("../data/keyboards/terminal_wide.yaml")), // Overlays ("emoji", include_str!("../data/keyboards/emoji.yaml")), ]; @@ -90,8 +92,7 @@ const KEYBOARDS: &[(*const str, *const str)] = &[ pub fn get_keyboard(needle: &str) -> Option<&'static str> { // Need to dereference in unsafe code // comparing *const str to &str will compare pointers - KEYBOARDS - .iter() + KEYBOARDS.iter() .find(|(name, _)| { let name: *const str = *name; (unsafe { &*name }) == needle @@ -102,16 +103,17 @@ pub fn get_keyboard(needle: &str) -> Option<&'static str> { }) } -const OVERLAY_NAMES: &[*const str] = &["emoji", "terminal"]; +const OVERLAY_NAMES: &[*const str] = &[ + "emoji", + "terminal", +]; pub fn get_overlays() -> Vec<&'static str> { - OVERLAY_NAMES - .iter() + OVERLAY_NAMES.iter() .map(|name| { let name: *const str = *name; unsafe { &*name } - }) - .collect() + }).collect() } /// Translations of the layout identifier strings @@ -120,15 +122,16 @@ const LAYOUT_NAMES: &[(*const str, *const str)] = &[ ("en-US", include_str!("../data/langs/en-US.txt")), ("es-ES", include_str!("../data/langs/es-ES.txt")), ("fur-IT", include_str!("../data/langs/fur-IT.txt")), - ("he-IL", include_str!("../data/langs/he-IL.txt")), + ("he-IL", include_str!("../data/langs/he_IL.txt")), ("ja-JP", include_str!("../data/langs/ja-JP.txt")), ("pl-PL", include_str!("../data/langs/pl-PL.txt")), ("ru-RU", include_str!("../data/langs/ru-RU.txt")), ]; -pub fn get_layout_names(lang: &str) -> Option>> { - let translations = LAYOUT_NAMES - .iter() +pub fn get_layout_names(lang: &str) + -> Option>> +{ + let translations = LAYOUT_NAMES.iter() .find(|(name, _data)| { let name: *const str = *name; (unsafe { &*name }) == lang @@ -153,7 +156,10 @@ fn parse_line(line: &str) -> Option<(&str, Translation)> { } fn make_mapping(data: &str) -> HashMap<&str, Translation> { - HashMap::from_iter(data.split("\n").filter_map(parse_line)) + HashMap::from_iter( + data.split("\n") + .filter_map(parse_line) + ) } #[cfg(test)]