From 0d3c1677da545a1d4e4cd26910596d34b732f0ba Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Thu, 28 Mar 2024 13:27:01 +0100 Subject: [PATCH] Move cursor to shared component --- README.md | 15 +++++++++--- buffyboard/README.md | 5 ---- buffyboard/indev.c | 5 ++-- buffyboard/meson.build | 9 ++++--- release.sh | 9 +++++-- shared/cursor/README.md | 6 +++++ {unl0kr => shared/cursor}/cursor.c | 10 ++++---- {unl0kr => shared/cursor}/cursor.h | 2 +- {unl0kr => shared/cursor}/cursor.png | Bin {unl0kr => shared/cursor}/package-lock.json | 2 +- {unl0kr => shared/cursor}/package.json | 0 .../cursor/regenerate.sh | 0 unl0kr/README.md | 6 ----- unl0kr/config.c | 1 + unl0kr/indev.c | 6 +++-- unl0kr/main.c | 1 + unl0kr/meson.build | 9 ++++--- unl0kr/regenerate-cursor.sh | 22 ------------------ unl0kr/themes.c | 2 ++ 19 files changed, 55 insertions(+), 55 deletions(-) create mode 100644 shared/cursor/README.md rename {unl0kr => shared/cursor}/cursor.c (98%) rename {unl0kr => shared/cursor}/cursor.h (83%) rename {unl0kr => shared/cursor}/cursor.png (100%) rename {unl0kr => shared/cursor}/package-lock.json (99%) rename {unl0kr => shared/cursor}/package.json (100%) rename buffyboard/regenerate-cursor.sh => shared/cursor/regenerate.sh (100%) delete mode 100755 unl0kr/regenerate-cursor.sh diff --git a/README.md b/README.md index e7c3ea0..3de6e07 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,17 @@ BuffyBox is a suite of graphical applications for the terminal. ## Components -* [buffyboard] – Touch-enabled on-screen keyboard for virtual terminals -* [squeek2lvgl] – Converter for transforming [Squeekboard] layouts into [LVGL]-compatible C code -* [unl0kr] – Disk unlocking UI for the initramfs +### Standalone apps + +**[buffyboard]** – Touch-enabled on-screen keyboard for virtual terminals + +**[unl0kr]** – Disk unlocking UI for the initramfs + +### Utilities + +**[squeek2lvgl]** – Converter for transforming [Squeekboard] layouts into [LVGL]-compatible C code + +**[shared]** – Internal code that is shared by some or all applications in the suite but not meant to be used externally ## Contributing @@ -32,6 +40,7 @@ This project is licensed under the GNU General Public License as published by th [buffyboard]: ./buffyboard [git-archive-all]: https://github.com/Kentzo/git-archive-all [LVGL]: https://github.com/lvgl/lvgl +[shared]: ./shared [squeek2lvgl]: ./squeek2lvgl [Squeekboard]: https://gitlab.gnome.org/World/Phosh/squeekboard [unl0kr]: ./unl0kr diff --git a/buffyboard/README.md b/buffyboard/README.md index f7969c5..4e7bdb4 100644 --- a/buffyboard/README.md +++ b/buffyboard/README.md @@ -92,10 +92,6 @@ Below is a short explanation of the different unicode ranges used above. - Standard `LV_SYMBOL_*` glyphs (`0xF001,0xF008,0xF00B,0xF00C,0xF00D,0xF011,0xF013,0xF015,0xF019,0xF01C,0xF021,0xF026,0xF027,0xF028,0xF03E,0xF0E0,0xF304,0xF043,0xF048,0xF04B,0xF04C,0xF04D,0xF051,0xF052,0xF053,0xF054,0xF067,0xF068,0xF06E,0xF070,0xF071,0xF074,0xF077,0xF078,0xF079,0xF07B,0xF093,0xF095,0xF0C4,0xF0C5,0xF0C7,0xF0C9,0xF0E7,0xF0EA,0xF0F3,0xF11C,0xF124,0xF158,0xF1EB,0xF240,0xF241,0xF242,0xF243,0xF244,0xF287,0xF293,0xF2ED,0xF55A,0xF7C2,0xF8A2`) - [arrow-alt-circle-up] (`0xF35B`) -## Mouse cursor - -Buffyboard's mouse cursor is adapted from Ubuntu's [Yaru] theme suite. Similar to fonts, the mouse cursor image needs to be converted to LVGL-compatible C code. To do this, run `regenerate-cursor.sh` after any change of `cursor.png` to update the code. - ## Keyboard layouts Buffyboard uses [squeekboard layouts] converted to C via [squeek2lvgl]. To regenerate the layouts, ensure that you have pipenv installed (e.g. via `pip install --user pipenv`) and then run @@ -143,4 +139,3 @@ The [FontAwesome] font is licensed under the Open Font License version 1.1. [squeekboard]: https://gitlab.gnome.org/World/Phosh/squeekboard/-/tree/master [v1 milestone]: https://gitlab.com/cherrypicker/buffyboard/-/milestones/1 [wiki]: https://gitlab.com/cherrypicker/buffyboard/-/wikis/home -[Yaru]: https://github.com/ubuntu/yaru diff --git a/buffyboard/indev.c b/buffyboard/indev.c index 674a3f3..1c4750f 100644 --- a/buffyboard/indev.c +++ b/buffyboard/indev.c @@ -4,10 +4,11 @@ */ -#include "cursor.h" #include "indev.h" -#include "../lvgl/lvgl.h" +#include "../shared/cursor/cursor.h" + +#include "lvgl/lvgl.h" #include diff --git a/buffyboard/meson.build b/buffyboard/meson.build index dd84fb5..60c870b 100644 --- a/buffyboard/meson.build +++ b/buffyboard/meson.build @@ -5,7 +5,7 @@ project( 'buffyboard', 'c', - version: '0.2.0', + version: '3.0.0', default_options: 'warning_level=1', meson_version: '>=0.53.0' ) @@ -14,7 +14,6 @@ add_project_arguments('-DBB_VERSION="@0@"'.format(meson.project_version()), lang buffyboard_sources = [ 'command_line.c', - 'cursor.c', 'font_32.c', 'indev.c', 'main.c', @@ -23,6 +22,10 @@ buffyboard_sources = [ 'uinput_device.c', ] +shared_sources = [ + '../shared/cursor/cursor.c' +] + squeek2lvgl_sources = [ '../squeek2lvgl/sq2lv.c', ] @@ -31,7 +34,7 @@ lvgl_sources = run_command('../find-lvgl-sources.sh', '../lvgl', check: true).st executable( 'buffyboard', - sources: buffyboard_sources + squeek2lvgl_sources + lvgl_sources, + sources: buffyboard_sources + shared_sources + squeek2lvgl_sources + lvgl_sources, include_directories: ['..'], dependencies: [ dependency('libinput'), diff --git a/release.sh b/release.sh index a594aa9..6b79a0f 100755 --- a/release.sh +++ b/release.sh @@ -15,8 +15,13 @@ if ! grep "## $1" CHANGELOG.md > /dev/null; then exit 1 fi -if ! grep -E "^\s*version:\s*'$1'" meson.build > /dev/null; then - echo "Error: Version $1 differs from version in meson.build" +if ! grep -E "^\s*version:\s*'$1'" buffyboard/meson.build > /dev/null; then + echo "Error: Version $1 differs from version in buffyboard/meson.build" + exit 1 +fi + +if ! grep -E "^\s*version:\s*'$1'" unl0kr/meson.build > /dev/null; then + echo "Error: Version $1 differs from version in unl0kr/meson.build" exit 1 fi diff --git a/shared/cursor/README.md b/shared/cursor/README.md new file mode 100644 index 0000000..f70304a --- /dev/null +++ b/shared/cursor/README.md @@ -0,0 +1,6 @@ +Mouse Cursor +============ + +This is the mouse cursor image used in BuffyBox applications. The bitmap is adapted from Ubuntu's [Yaru] theme suite. Similar to fonts, the cursor image needs to be converted to LVGL-compatible C code before it can be used. Therefore, after any change to `cursor.png`, run `regenerate.sh` to recreate `cursor.c`. + +[Yaru]: https://github.com/ubuntu/yaru diff --git a/unl0kr/cursor.c b/shared/cursor/cursor.c similarity index 98% rename from unl0kr/cursor.c rename to shared/cursor/cursor.c index a305e63..63ab6e1 100644 --- a/unl0kr/cursor.c +++ b/shared/cursor/cursor.c @@ -17,11 +17,11 @@ #define LV_ATTRIBUTE_MEM_ALIGN #endif -#ifndef LV_ATTRIBUTE_IMG_UL_CURSOR_IMG_DSC -#define LV_ATTRIBUTE_IMG_UL_CURSOR_IMG_DSC +#ifndef LV_ATTRIBUTE_IMG_BB_CURSOR_IMG_DSC +#define LV_ATTRIBUTE_IMG_BB_CURSOR_IMG_DSC #endif -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_UL_CURSOR_IMG_DSC uint8_t ul_cursor_img_dsc_map[] = { +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BB_CURSOR_IMG_DSC uint8_t bb_cursor_img_dsc_map[] = { #if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8 /*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/ 0xff, 0xf7, 0xff, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -107,9 +107,9 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_UL_CURSOR #endif }; -const lv_img_dsc_t ul_cursor_img_dsc = { +const lv_img_dsc_t bb_cursor_img_dsc = { .header.cf = LV_COLOR_FORMAT_NATIVE_WITH_ALPHA, .header.w = 12, .header.h = 18, - .data = ul_cursor_img_dsc_map, + .data = bb_cursor_img_dsc_map, }; diff --git a/unl0kr/cursor.h b/shared/cursor/cursor.h similarity index 83% rename from unl0kr/cursor.h rename to shared/cursor/cursor.h index 29309e1..f7b918a 100644 --- a/unl0kr/cursor.h +++ b/shared/cursor/cursor.h @@ -10,6 +10,6 @@ #include "lvgl/lvgl.h" /* Image description of the mouse cursor */ -extern const lv_img_dsc_t ul_cursor_img_dsc; +extern const lv_img_dsc_t bb_cursor_img_dsc; #endif /* UL_CURSOR_H */ diff --git a/unl0kr/cursor.png b/shared/cursor/cursor.png similarity index 100% rename from unl0kr/cursor.png rename to shared/cursor/cursor.png diff --git a/unl0kr/package-lock.json b/shared/cursor/package-lock.json similarity index 99% rename from unl0kr/package-lock.json rename to shared/cursor/package-lock.json index 1960cce..243e9eb 100644 --- a/unl0kr/package-lock.json +++ b/shared/cursor/package-lock.json @@ -1,5 +1,5 @@ { - "name": "unl0kr", + "name": "shared", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/unl0kr/package.json b/shared/cursor/package.json similarity index 100% rename from unl0kr/package.json rename to shared/cursor/package.json diff --git a/buffyboard/regenerate-cursor.sh b/shared/cursor/regenerate.sh similarity index 100% rename from buffyboard/regenerate-cursor.sh rename to shared/cursor/regenerate.sh diff --git a/unl0kr/README.md b/unl0kr/README.md index f2c685c..380acde 100644 --- a/unl0kr/README.md +++ b/unl0kr/README.md @@ -153,11 +153,6 @@ Below is a short explanation of the different unicode ranges used above. - [arrow-alt-circle-up](https://fontawesome.com/v5/icons/arrow-alt-circle-up) (`0xF35B`) - [chevron-left](https://fontawesome.com/v5/icons/chevron-left) (`0xF053`) - -## Mouse cursor - -Unl0kr's mouse cursor is adapted from Ubuntu's [Yaru] theme suite. Similar to fonts, the mouse cursor image needs to be converted to LVGL-compatible C code. To do this, run `regenerate-cursor.sh` after any change of `cursor.png` to update the code. - ## Keyboard layouts Unl0kr uses [squeekboard layouts] converted to C via [squeek2lvgl]. To regenerate the layouts, ensure that you have pipenv installed (e.g. via `pip install --user pipenv`) and then run @@ -220,4 +215,3 @@ The [FontAwesome] font is licensed under the Open Font License version 1.1. [squeek2lvgl]: ../squeek2lvgl [squeekboard layouts]: https://gitlab.gnome.org/World/Phosh/squeekboard/-/tree/master/data/keyboards [unl0kr.conf]: ./unl0kr.conf -[Yaru]: https://github.com/ubuntu/yaru diff --git a/unl0kr/config.c b/unl0kr/config.c index 6cad514..45c2808 100644 --- a/unl0kr/config.c +++ b/unl0kr/config.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../squeek2lvgl/sq2lv.h" diff --git a/unl0kr/indev.c b/unl0kr/indev.c index 9d2e029..05a598f 100644 --- a/unl0kr/indev.c +++ b/unl0kr/indev.c @@ -6,15 +6,17 @@ #include "indev.h" -#include "cursor.h" #include "log.h" +#include "../shared/cursor/cursor.h" + #include "lvgl/src/indev/lv_indev_private.h" #include #include #include #include +#include #include @@ -353,7 +355,7 @@ static void set_mouse_cursor(struct input_device *device) { /* Initialise cursor image if needed */ if (!cursor_obj) { cursor_obj = lv_img_create(lv_scr_act()); - lv_img_set_src(cursor_obj, &ul_cursor_img_dsc); + lv_img_set_src(cursor_obj, &bb_cursor_img_dsc); } /* Apply the cursor image */ diff --git a/unl0kr/main.c b/unl0kr/main.c index d1b1442..e83422b 100644 --- a/unl0kr/main.c +++ b/unl0kr/main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/unl0kr/meson.build b/unl0kr/meson.build index 8d6243d..02f9b8a 100644 --- a/unl0kr/meson.build +++ b/unl0kr/meson.build @@ -5,7 +5,7 @@ project( 'unl0kr', 'c', - version: '2.0.2', + version: '3.0.0', default_options: 'warning_level=3', meson_version: '>=0.53.0' ) @@ -16,7 +16,6 @@ unl0kr_sources = [ 'backends.c', 'command_line.c', 'config.c', - 'cursor.c', 'font_32.c', 'indev.c', 'log.c', @@ -27,6 +26,10 @@ unl0kr_sources = [ 'themes.c', ] +shared_sources = [ + '../shared/cursor/cursor.c' +] + squeek2lvgl_sources = [ '../squeek2lvgl/sq2lv.c', ] @@ -55,7 +58,7 @@ install_data(sources: 'unl0kr.conf', install_dir : get_option('sysconfdir')) executable( 'unl0kr', - sources: unl0kr_sources + squeek2lvgl_sources + lvgl_sources, + sources: unl0kr_sources + shared_sources + squeek2lvgl_sources + lvgl_sources, include_directories: ['..'], dependencies: unl0kr_dependencies, install: true diff --git a/unl0kr/regenerate-cursor.sh b/unl0kr/regenerate-cursor.sh deleted file mode 100755 index a8edd84..0000000 --- a/unl0kr/regenerate-cursor.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -ex - -# Copyright 2023 Johannes Marbach -# SPDX-License-Identifier: GPL-3.0-or-later - - -npm i - -./node_modules/lv_img_conv/lv_img_conv.js -f \ - -i ul_cursor_img_dsc \ - -c CF_TRUE_COLOR_ALPHA \ - -o cursor.c \ - cursor.png - -# We need to manually replace the old constants because the image converter hasn't -# yet been updated to https://github.com/lvgl/lvgl/issues/4011 -sed 's/LV_IMG_CF_TRUE_COLOR_ALPHA/LV_COLOR_FORMAT_NATIVE_WITH_ALPHA/g' cursor.c \ - | sed '/.*LV_IMG_PX_SIZE_ALPHA_BYTE.*/d' \ - | sed '/.*header.always_zero.*/d' \ - | sed '/.*header.reserved.*/d'\ - > cursor.c.tmp -mv cursor.c.tmp cursor.c diff --git a/unl0kr/themes.c b/unl0kr/themes.c index 9f0a702..cdb2527 100644 --- a/unl0kr/themes.c +++ b/unl0kr/themes.c @@ -6,6 +6,8 @@ #include "themes.h" +#include + /** * Static variables