mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-12 18:32:48 +01:00
layout: Implement spacing better
to no longer need overscan Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
1843e60a74
commit
0cd0d5e1a1
@ -122,16 +122,23 @@ kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
|
||||
|
||||
struct key *k = l->keys;
|
||||
double rowlength = kbd_get_row_length(k);
|
||||
double rowwidth = 0.0;
|
||||
while (k->type != Last) {
|
||||
if (k->type == EndRow) {
|
||||
y += l->keyheight;
|
||||
x = 0;
|
||||
rowwidth = 0.0;
|
||||
rowlength = kbd_get_row_length(k + 1);
|
||||
} else if (k->width > 0) {
|
||||
k->x = x;
|
||||
k->y = y;
|
||||
k->w = ((double)width / rowlength) * k->width;
|
||||
x += k->w;
|
||||
rowwidth += k->width;
|
||||
if (x < (rowwidth / rowlength) * (double)width) {
|
||||
k->w++;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
k->h = l->keyheight;
|
||||
k++;
|
||||
|
@ -5,9 +5,6 @@
|
||||
/* how tall the keyboard should be by default (can be overriden) */
|
||||
#define KBD_PIXEL_LANDSCAPE_HEIGHT 120
|
||||
|
||||
/* if your layout leaves an empty margin, increase this to fix it */
|
||||
#define KBD_PIXEL_OVERSCAN_WIDTH 5
|
||||
|
||||
/* spacing between keys */
|
||||
#define KBD_KEY_BORDER 2
|
||||
|
||||
|
4
main.c
4
main.c
@ -334,8 +334,8 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {}
|
||||
void
|
||||
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
uint32_t serial, uint32_t w, uint32_t h) {
|
||||
if ( keyboard.w != w + KBD_PIXEL_OVERSCAN_WIDTH || keyboard.h != h ) {
|
||||
keyboard.w = w + KBD_PIXEL_OVERSCAN_WIDTH;
|
||||
if (keyboard.w != w || keyboard.h != h) {
|
||||
keyboard.w = w;
|
||||
keyboard.h = h;
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user