switch layers: fix crash

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
Zach DeCook 2023-09-02 07:48:11 -04:00 committed by Maarten van Gompel
parent 24e354ce9e
commit 9e03e120c3

View File

@ -66,20 +66,20 @@ kbd_next_layer(struct kbd *kb, struct key *k, bool invert) {
} else {
// normal behaviour: switch to the next layout in the layer sequence
layer_index++;
size_t layercount = 0;
for (size_t i = 0; layercount == 0; i++) {
if (kb->landscape) {
if (kb->landscape_layers[i] == NumLayouts) layercount = i;
} else {
if (kb->layers[i] == NumLayouts) layercount = i;
}
}
if (layer_index >= layercount) {
if (kb->debug)
fprintf(stderr, "wrapping layer_index back to start\n");
layer_index = 0;
}
size_t layercount = 0;
for (size_t i = 0; layercount == 0; i++) {
if (kb->landscape) {
if (kb->landscape_layers[i] == NumLayouts) layercount = i;
} else {
if (kb->layers[i] == NumLayouts) layercount = i;
}
}
if (layer_index >= layercount) {
if (kb->debug)
fprintf(stderr, "wrapping layer_index back to start\n");
layer_index = 0;
}
enum layout_id layer;
if (kb->landscape) {
layer = kb->landscape_layers[layer_index];