suggestion picker: a persistent layer to complement virtual keyboards like wvkbd
| -rw-r--r-- | keyboard.h | 18 | ||||
| -rw-r--r-- | main.c | 40 |
2 files changed, 29 insertions, 29 deletions
@@ -104,7 +104,7 @@ uint8_t kbd_get_rows(struct layout *l) { void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) { uint32_t x = 0, y = 0; - fprintf(stderr, "Init layout\n"); + fprintf(stderr, "Init layout\n"); uint8_t rows = kbd_get_rows(l); l->keyheight = height / rows; @@ -174,12 +174,12 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) { create_and_upload_keymap(kb->layout->keymap_name, 0, 0); } kb->layout = kb->prevlayout; - if ((kb->mods & Shift) == Shift) kb->mods ^= Shift; - kbd_draw_layout(kb); + if ((kb->mods & Shift) == Shift) kb->mods ^= Shift; + kbd_draw_layout(kb); } else if ((kb->mods & Shift) == Shift) { - kb->mods ^= Shift; + kb->mods ^= Shift; kbd_draw_layout(kb); - } + } } } @@ -262,12 +262,12 @@ void kbd_draw_key(struct kbd *kb, struct key *k, bool pressed) { struct drwsurf *d = kb->surf; const char *label = (kb->mods & Shift) ? k->shift_label : k->label; - fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h, k->label); + fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h, k->label); struct clr_scheme * scheme = (k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1); Color *fill = pressed ? &scheme->high : &scheme->fg; draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, fill->color); uint32_t xoffset = k->w / (strlen(label) + 2); - fprintf(stderr, " xoffset=%d\n", xoffset); + fprintf(stderr, " xoffset=%d\n", xoffset); wld_draw_text(d->render, d->ctx->font, scheme->text.color, k->x + xoffset, k->y + (k->h / 2), label, -1, NULL); } @@ -277,7 +277,7 @@ kbd_draw_layout(struct kbd *kb) { struct drwsurf *d = kb->surf; struct key *next_key = kb->layout->keys; bool pressed = false; - fprintf(stderr, "Draw layout"); + fprintf(stderr, "Draw layout"); wld_fill_rectangle(d->render, kb->scheme.bg.color, 0, 0, kb->w, kb->h); @@ -294,7 +294,7 @@ kbd_draw_layout(struct kbd *kb) { void kbd_resize(struct kbd *kb, uint32_t w, uint32_t h, struct layout * layouts, uint8_t layoutcount) { - struct drwsurf *d = kb->surf; + struct drwsurf *d = kb->surf; kb->w = w; kb->h = h; @@ -98,35 +98,35 @@ static void create_and_upload_keymap(const char * name, uint32_t comp_unichr, ui /* event handlers */ static const struct wl_pointer_listener pointer_listener = { - .enter = wl_pointer_enter, - .leave = wl_pointer_leave, - .motion = wl_pointer_motion, - .button = wl_pointer_button, + .enter = wl_pointer_enter, + .leave = wl_pointer_leave, + .motion = wl_pointer_motion, + .button = wl_pointer_button, }; static const struct wl_touch_listener touch_listener = { - .down = wl_touch_down, - .up = wl_touch_up, - .motion = wl_touch_motion, - .frame = wl_touch_frame, - .cancel = wl_touch_cancel, - .shape = wl_touch_shape, - .orientation = wl_touch_orientation, + .down = wl_touch_down, + .up = wl_touch_up, + .motion = wl_touch_motion, + .frame = wl_touch_frame, + .cancel = wl_touch_cancel, + .shape = wl_touch_shape, + .orientation = wl_touch_orientation, }; static const struct wl_seat_listener seat_listener = { - .capabilities = seat_handle_capabilities, - .name = seat_handle_name, + .capabilities = seat_handle_capabilities, + .name = seat_handle_name, }; static const struct wl_registry_listener registry_listener = { - .global = handle_global, - .global_remove = handle_global_remove, + .global = handle_global, + .global_remove = handle_global_remove, }; static const struct zwlr_layer_surface_v1_listener layer_surface_listener = { - .configure = layer_surface_configure, - .closed = layer_surface_closed, + .configure = layer_surface_configure, + .closed = layer_surface_closed, }; /* configuration, allows nested code to access above variables */ @@ -278,8 +278,8 @@ layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface) { void create_and_upload_keymap(const char * name, uint32_t comp_unichr, uint32_t comp_shift_unichr) { - const char * keymap_str = get_keymap(name, comp_unichr, comp_shift_unichr); - size_t keymap_size = strlen(keymap_str) + 1; + const char * keymap_str = get_keymap(name, comp_unichr, comp_shift_unichr); + size_t keymap_size = strlen(keymap_str) + 1; int keymap_fd = os_create_anonymous_file(keymap_size); if (keymap_fd < 0) { die("could not create keymap fd\n"); @@ -292,7 +292,7 @@ create_and_upload_keymap(const char * name, uint32_t comp_unichr, uint32_t comp_ strcpy(ptr, keymap_str); zwp_virtual_keyboard_v1_keymap( keyboard.vkbd, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size); - free((void*) keymap_str); + free((void*) keymap_str); } int |