mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
Make all modifiers except capslock one shot and redraw keyboard when capslock pressed
This commit is contained in:
parent
2f72b176cb
commit
9d130e7fd2
20
keyboard.c
20
keyboard.c
@ -276,13 +276,21 @@ kbd_get_layer_index(struct kbd *kb, struct layout *l)
|
|||||||
void
|
void
|
||||||
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||||
{
|
{
|
||||||
bool unlatch_shift = false;
|
bool unlatch_shift, unlatch_ctrl, unlatch_alt, unlatch_super;
|
||||||
|
unlatch_shift = unlatch_ctrl = unlatch_alt = unlatch_super = false;
|
||||||
|
|
||||||
if (kb->last_press) {
|
if (kb->last_press) {
|
||||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||||
|
unlatch_ctrl = (kb->mods & Ctrl) == Ctrl;
|
||||||
|
unlatch_alt = (kb->mods & Alt) == Alt;
|
||||||
|
unlatch_super = (kb->mods & Super) == Super;
|
||||||
|
|
||||||
if (unlatch_shift) {
|
if (unlatch_shift) kb->mods ^= Shift;
|
||||||
kb->mods ^= Shift;
|
if (unlatch_ctrl) kb->mods ^= Ctrl;
|
||||||
|
if (unlatch_alt) kb->mods ^= Alt;
|
||||||
|
if (unlatch_super) kb->mods ^= Super;
|
||||||
|
|
||||||
|
if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super) {
|
||||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +312,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
|
|||||||
if (kb->compose >= 2) {
|
if (kb->compose >= 2) {
|
||||||
kb->compose = 0;
|
kb->compose = 0;
|
||||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||||
} else if (unlatch_shift) {
|
} else if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super) {
|
||||||
kbd_draw_layout(kb);
|
kbd_draw_layout(kb);
|
||||||
} else {
|
} else {
|
||||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||||
@ -418,7 +426,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
|
|||||||
break;
|
break;
|
||||||
case Mod:
|
case Mod:
|
||||||
kb->mods ^= k->code;
|
kb->mods ^= k->code;
|
||||||
if (k->code == Shift) {
|
if ((k->code == Shift) || (k->code == CapsLock)) {
|
||||||
kbd_draw_layout(kb);
|
kbd_draw_layout(kb);
|
||||||
} else {
|
} else {
|
||||||
if (kb->mods & k->code) {
|
if (kb->mods & k->code) {
|
||||||
@ -551,7 +559,7 @@ kbd_clear_last_popup(struct kbd *kb)
|
|||||||
void
|
void
|
||||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||||
{
|
{
|
||||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
const char *label = ((kb->mods & Shift)||(kb->mods & CapsLock)) ? k->shift_label : k->label;
|
||||||
if (kb->debug)
|
if (kb->debug)
|
||||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||||
label);
|
label);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user