about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-06-29 22:50:53 -0400
committerZach DeCook <zachdecook@librem.one>2022-06-29 22:50:53 -0400
commit75c8fb0a3f817dfbcb04e73f0b43ba9d38456fb4 (patch)
tree10876c592d0d4ad55956b8b187a8a407e555600e
parentaf63ed2e6fea0b1b13e977d9eb8563119b8bbf2c (diff)
downloadsuggpicker-75c8fb0a3f817dfbcb04e73f0b43ba9d38456fb4.tar.gz
keyboard: Progressively allocate remainder pixels
So the keyboard always fills the width of the screen,
and the width is distributed evenly
-rw-r--r--keyboard.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/keyboard.c b/keyboard.c
index bfdfdc9..2b1506a 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -29,11 +29,16 @@ kbd_init_suggs(struct key *suggs, uint32_t width, uint32_t height) {
 
 	struct key *k = suggs;
 	double rowlength = kbd_get_row_length(k);
+	uint8_t i = 0;
 	while (k->label != NULL) {
 		k->x = x;
 		k->y = y;
 		k->w = width / rowlength;
 		x += k->w;
+		i++;
+		if (x < (width * i) / rowlength) {
+			k->w++; x++;
+		}
 		k->h = keyheight;
 		k++;
 	}