Layer.move: Forcibly update all our caches

`Layer.move()` relied on `activate()` to update the caches, but `activate()`
worked under the assumption that we also `deactivate()` layers - which we did
not in `move()`, as we directly modified the state. Since we directly modify the
state, we can't rely on `activate()` either, and have to update the caches
ourselves.

Unlike `activate()`, we do this unconditionally, because there isn't a case
where we do not want to update them.

This makes `MoveToLayer()` play well with `Colormap`, and any other plugin that
rely on cached layer information, such as the topmost active layer.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/779/head
Gergely Nagy 5 years ago
parent 53993860f0
commit 5fcdd720cb
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -146,8 +146,20 @@ void Layer_::updateTopActiveLayer(void) {
} }
void Layer_::move(uint8_t layer) { void Layer_::move(uint8_t layer) {
// We do pretty much what activate() does, except we do everything
// unconditionally, to make sure all parts of the firmware are aware of the
// layer change.
layer_state_ = 0; layer_state_ = 0;
activate(layer);
if (layer >= layer_count) {
layer = 0;
}
bitSet(layer_state_, layer);
updateTopActiveLayer();
updateActiveLayers();
kaleidoscope::Hooks::onLayerChange();
} }
// Activate a given layer // Activate a given layer

Loading…
Cancel
Save