setlayout: Allow setlayout(main) (#677, #652)

There is presently no way to revert to the 'default' (no) layout.
This patch makes setlayout(main) functionally equivalent to clearing
the applied layout (if present).
master
Raheman Vaiya 2 years ago
parent 77d1d837eb
commit 31616d2532
  1. BIN
      data/keyd-application-mapper.1.gz
  2. BIN
      data/keyd.1.gz
  3. 4
      docs/keyd.scdoc
  4. 4
      src/config.c
  5. 7
      src/keyboard.c

Binary file not shown.

Binary file not shown.

@ -337,8 +337,8 @@ and not
A layout is a special kind of layer intended for modifying alpha keys. Unlike
layers, layouts cannot have any associated modifiers, and only one layout may
be active at a given time. The current layout can be set using the _setlayout_
action.
be active at a given time. The default layout is called 'main', and can be
changed using the _setlayout()_ action.
For convenience, keyd ships with a number of common letter layouts in
/usr/share/keyd/layouts. Before including these, it is instructive to inspect them.

@ -674,7 +674,9 @@ static int parse_descriptor(char *s,
break;
case ARG_LAYOUT:
arg->idx = config_get_layer_index(config, argstr);
if (arg->idx == -1 || config->layers[arg->idx].type != LT_LAYOUT) {
if (arg->idx == -1 ||
(arg->idx != 0 && //Treat main as a valid layout
config->layers[arg->idx].type != LT_LAYOUT)) {
err("%s is not a valid layout", argstr);
return -1;
}

@ -441,8 +441,11 @@ static void setlayout(struct keyboard *kbd, uint8_t idx)
kbd->layer_state[i].active = 0;
}
kbd->layer_state[idx].activation_time = 1;
kbd->layer_state[idx].active = 1;
// Setting the layout to main is equivalent to clearing all occluding layouts.
if (idx != 0) {
kbd->layer_state[idx].activation_time = 1;
kbd->layer_state[idx].active = 1;
}
kbd->output.on_layer_change(kbd, &kbd->config.layers[idx], 1);
}

Loading…
Cancel
Save