From e67a5afce9c274327375c891b94d3db2bf1ea5c3 Mon Sep 17 00:00:00 2001 From: Pachulke Date: Fri, 6 Mar 2026 07:18:42 +0000 Subject: [PATCH] Add arguments to define different text color for pressed and swiped keys Signed-off-by: Maarten van Gompel --- config.mobintl.h | 4 ++++ keyboard.c | 13 ++++++++++--- keyboard.h | 2 ++ main.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/config.mobintl.h b/config.mobintl.h index 79d8854..fd6591a 100644 --- a/config.mobintl.h +++ b/config.mobintl.h @@ -14,6 +14,8 @@ struct clr_scheme schemes[] = { .high = {.bgra = {100, 100, 100, transparency}}, .swipe = {.bgra = {100, 255, 100, 64}}, .text = {.color = UINT32_MAX}, + .text_press = {.color = UINT32_MAX}, + .text_swipe = {.color = UINT32_MAX}, .font = DEFAULT_FONT, .rounding = DEFAULT_ROUNDING, }, @@ -23,6 +25,8 @@ struct clr_scheme schemes[] = { .fg = {.bgra = {32, 32, 32, transparency}}, .high = {.bgra = {100, 100, 100, transparency}}, .swipe = {.bgra = {100, 255, 100, 64}}, + .text_press = {.color = UINT32_MAX}, + .text_swipe = {.color = UINT32_MAX}, .text = {.color = UINT32_MAX}, .font = DEFAULT_FONT, .rounding = DEFAULT_ROUNDING, diff --git a/keyboard.c b/keyboard.c index 7b4235d..7e407e3 100644 --- a/keyboard.c +++ b/keyboard.c @@ -616,19 +616,26 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) case Unpress: draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->fg, scheme->rounding); + drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h, + KBD_KEY_BORDER, label, scheme->font_description); break; case Press: draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->high, scheme->rounding); + drw_draw_text(kb->surf, scheme->text_press, k->x, k->y, k->w, k->h, + KBD_KEY_BORDER, label, scheme->font_description); break; case Swipe: draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->swipe, scheme->rounding); + drw_draw_text(kb->surf, scheme->text_swipe, k->x, k->y, k->w, k->h, + KBD_KEY_BORDER, label, scheme->font_description); break; + default: + drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h, + KBD_KEY_BORDER, label, scheme->font_description); } - drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h, - KBD_KEY_BORDER, label, scheme->font_description); if (type == Press || type == Unpress) { kbd_clear_last_popup(kb); @@ -642,7 +649,7 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) kb->last_popup_y, k->w, k->h, scheme->rounding); draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h, KBD_KEY_BORDER, scheme->high, scheme->rounding); - drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y, + drw_draw_text(kb->popup_surf, scheme->text_press, k->x, kb->last_popup_y, k->w, k->h, KBD_KEY_BORDER, label, scheme->font_description); } diff --git a/keyboard.h b/keyboard.h index dfd0df1..3622da0 100644 --- a/keyboard.h +++ b/keyboard.h @@ -54,6 +54,8 @@ struct clr_scheme { Color high; Color swipe; Color text; + Color text_press; + Color text_swipe; char *font; int rounding; PangoFontDescription *font_description; diff --git a/main.c b/main.c index c722c97..ad0bf26 100644 --- a/main.c +++ b/main.c @@ -618,6 +618,14 @@ usage(char *argv0) fprintf(stderr, " --text [rrggbb|aa] - Set color of text on keys\n"); fprintf(stderr, " --text-sp [rrggbb|aa] - Set color of text on special keys\n"); + fprintf(stderr, + " --text-press [rrggbb|aa] - Set color of text on pressed keys\n"); + fprintf(stderr, + " --text-press-sp [rrggbb|aa] - Set color of text on pressed special keys\n"); + fprintf(stderr, + " --text-swipe [rrggbb|aa] - Set color of text on swiped keys\n"); + fprintf(stderr, + " --text-swipe-sp [rrggbb|aa] - Set color of text on swiped special keys\n"); fprintf(stderr, " --list-layers - Print the list of available layers\n"); fprintf(stderr, @@ -902,6 +910,34 @@ main(int argc, char **argv) exit(1); } set_kbd_colors(keyboard.schemes[1].text.bgra, argv[++i]); + } else if ((!strcmp(argv[i], "-text-press")) || + (!strcmp(argv[i], "--text-press"))) { + if (i >= argc - 1) { + usage(argv[0]); + exit(1); + } + set_kbd_colors(keyboard.schemes[0].text_press.bgra, argv[++i]); + } else if ((!strcmp(argv[i], "-text-press-sp")) || + (!strcmp(argv[i], "--text-press-sp"))) { + if (i >= argc - 1) { + usage(argv[0]); + exit(1); + } + set_kbd_colors(keyboard.schemes[1].text_press.bgra, argv[++i]); + } else if ((!strcmp(argv[i], "-text-swipe")) || + (!strcmp(argv[i], "--text-swipe"))) { + if (i >= argc - 1) { + usage(argv[0]); + exit(1); + } + set_kbd_colors(keyboard.schemes[0].text_swipe.bgra, argv[++i]); + } else if ((!strcmp(argv[i], "-text-swipe-sp")) || + (!strcmp(argv[i], "--text-swipe-sp"))) { + if (i >= argc - 1) { + usage(argv[0]); + exit(1); + } + set_kbd_colors(keyboard.schemes[1].text_swipe.bgra, argv[++i]); } else if (!strcmp(argv[i], "-H")) { if (i >= argc - 1) { usage(argv[0]);