wvkbd

git clone https://git.tarina.org/wvkbd
Log | Files | Refs | README | LICENSE

commit e73316bd7c1a7e21ed5e2c948c79273316efc502
parent ff92a920863ffb15f1e5c0594b19a46e19a05fc3
Author: Stacy Harper <contact@stacyharper.net>
Date:   Thu, 26 Aug 2021 09:16:47 +0200

WIP refacto keyboard.c

Diffstat:
MMakefile | 2+-
Mconfig.def.h | 26++++++++++++++++++++++++++
Mkeyboard.c | 5+++++
Mlayout.mobintl.h | 35-----------------------------------
Mmain.c | 10+++++++++-
5 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/Makefile b/Makefile @@ -9,7 +9,7 @@ PKGS = wayland-client xkbcommon pangocairo WVKBD_SOURCES += $(wildcard $(SRC)/*.c) WVKBD_HEADERS += $(wildcard $(SRC)/*.h) -CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" +CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" -DKEYMAP=\"keymap.${LAYOUT}.h\" CFLAGS += $(shell pkg-config --cflags $(PKGS)) LDFLAGS =$(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt diff --git a/config.def.h b/config.def.h @@ -3,5 +3,31 @@ static const char *default_font = "Monospace 15"; +struct clr_scheme scheme = { + /* colors */ + .bg = {.bgra = {15, 15, 15, 225}}, + .fg = {.bgra = {45, 45, 45, 225}}, + .high = {.bgra = {100, 100, 100, 225}}, + .text = {.color = UINT32_MAX}, +}; +struct clr_scheme scheme1 = { + /* colors */ + .bg = {.bgra = {15, 15, 15, 225}}, + .fg = {.bgra = {32, 32, 32, 225}}, + .high = {.bgra = {100, 100, 100, 225}}, + .text = {.color = UINT32_MAX}, +}; + +/* layers is an ordered list of layouts, used to cycle through */ +static enum layout_id layers[] = { + Full, //First layout is the default layout on startup + Special, + Emoji, + Simple, + Cyrillic, + Arabic, + NumLayouts //signals the last item, may not be omitted +}; + #endif // config_def_h_INCLUDED diff --git a/keyboard.c b/keyboard.c @@ -13,6 +13,11 @@ fprintf(stderr, __VA_ARGS__); \ exit(1) +#ifndef KEYMAP +#error "make sure to define KEYMAP" +#endif +#include KEYMAP + void kbd_switch_layout(struct kbd *kb, struct layout *l) { kb->prevlayout = kb->layout; diff --git a/layout.mobintl.h b/layout.mobintl.h @@ -9,8 +9,6 @@ /* spacing between keys */ #define KBD_KEY_BORDER 2 -#include "keymap.mobintl.h" - /* layout declarations */ enum layout_id { Full = 0, @@ -61,17 +59,6 @@ enum layout_id { NumLayouts, }; -/* layers is an ordered list of layouts, used to cycle through */ -static enum layout_id layers[] = { - Full, //First layout is the default layout on startup - Special, - Emoji, - Simple, - Cyrillic, - Arabic, - NumLayouts //signals the last item, may not be omitted -}; - static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[], keys_arabic[], keys_emoji[], @@ -138,28 +125,6 @@ static struct layout layouts[NumLayouts] = { }; -/* keyboard settings */ -static struct kbd keyboard = { - /* default layout */ - .layers = (enum layout_id *) &layers, - .layer_index = 0, - .scheme = - { - /* colors */ - .bg = {.bgra = {15, 15, 15, 225}}, - .fg = {.bgra = {45, 45, 45, 225}}, - .high = {.bgra = {100, 100, 100, 225}}, - .text = {.color = UINT32_MAX}, - }, - .scheme1 = - { - /* colors */ - .bg = {.bgra = {15, 15, 15, 225}}, - .fg = {.bgra = {32, 32, 32, 225}}, - .high = {.bgra = {100, 100, 100, 225}}, - .text = {.color = UINT32_MAX}, - }, -}; /* key layouts * diff --git a/main.c b/main.c @@ -8,7 +8,6 @@ #include <wayland-client.h> #include <wchar.h> -#include "drw.h" #include "keyboard.h" #include "config.h" @@ -42,6 +41,7 @@ static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | /* application state */ static bool run_display = true; static int cur_x = -1, cur_y = -1; +static struct kbd keyboard; /* event handler prototypes */ static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, @@ -333,6 +333,14 @@ main(int argc, char **argv) { if ((tmp = getenv("WVKBD_HEIGHT"))) height = atoi(tmp); + /* keyboard settings */ + keyboard.layers = (enum layout_id *) &layers; + keyboard.scheme = scheme; + keyboard.layer_index = 0; + keyboard.scheme1 = scheme1; + keyboard.scheme1 = scheme1; + + int i; for (i = 1; argv[i]; i++) { if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {