mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
formatting
This commit is contained in:
parent
e464128eb2
commit
98bb2c80d3
1 changed files with 22 additions and 8 deletions
|
|
@ -470,7 +470,8 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
|
||||||
|
|
||||||
// translate keysyms into keycodes
|
// translate keysyms into keycodes
|
||||||
if (!translate_binding(binding)) {
|
if (!translate_binding(binding)) {
|
||||||
sway_log(SWAY_INFO,"Unable to translate bindsym into bindcode: %s", argv[0]);
|
sway_log(SWAY_INFO,
|
||||||
|
"Unable to translate bindsym into bindcode: %s", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
list_t *mode_bindings;
|
list_t *mode_bindings;
|
||||||
|
|
@ -726,6 +727,10 @@ bool translate_binding(struct sway_binding *binding) {
|
||||||
|
|
||||||
int num_syms = binding->keys->length;
|
int num_syms = binding->keys->length;
|
||||||
list_t **sym2code = malloc(num_syms * sizeof(list_t*));
|
list_t **sym2code = malloc(num_syms * sizeof(list_t*));
|
||||||
|
if (!sym2code) {
|
||||||
|
sway_log(SWAY_ERROR,
|
||||||
|
"Unable to allocate memory for symbol:keycode map");
|
||||||
|
}
|
||||||
// Collect all keycodes for all keysyms
|
// Collect all keycodes for all keysyms
|
||||||
for (int i = 0; i < num_syms; i++) {
|
for (int i = 0; i < num_syms; i++) {
|
||||||
struct keycode_matches matches = {
|
struct keycode_matches matches = {
|
||||||
|
|
@ -739,13 +744,18 @@ bool translate_binding(struct sway_binding *binding) {
|
||||||
add_matching_keycodes, &matches);
|
add_matching_keycodes, &matches);
|
||||||
|
|
||||||
if (matches.error) {
|
if (matches.error) {
|
||||||
sway_log(SWAY_ERROR, "Failed to allocate memory for keycodes while iterating for keysym %" PRIu32, *matches.keysym);
|
sway_log(SWAY_ERROR,
|
||||||
|
"Failed to allocate memory for keycodes while "
|
||||||
|
"iterating for keysym %" PRIu32,
|
||||||
|
*matches.keysym);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches.keycodes->length == 0) {
|
if (matches.keycodes->length == 0) {
|
||||||
sway_log(SWAY_INFO, "Unable to convert keysym %" PRIu32 " into"
|
sway_log(SWAY_INFO,
|
||||||
"any keycodes", *matches.keysym);
|
"Unable to convert keysym %" PRIu32 " into"
|
||||||
|
"any keycodes",
|
||||||
|
*matches.keysym);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -756,14 +766,18 @@ bool translate_binding(struct sway_binding *binding) {
|
||||||
xkb_keycode_t **combos = cartesian_product(sym2code, num_syms);
|
xkb_keycode_t **combos = cartesian_product(sym2code, num_syms);
|
||||||
|
|
||||||
for (int i = 0; i < num_syms; i++) {
|
for (int i = 0; i < num_syms; i++) {
|
||||||
struct sway_binding * copy_binding = malloc(sizeof(struct sway_binding));
|
struct sway_binding *copy_binding = malloc(sizeof(*copy_binding));
|
||||||
binding->type = BINDING_KEYCODE;
|
binding->type = BINDING_KEYCODE;
|
||||||
*copy_binding = *binding;
|
*copy_binding = *binding;
|
||||||
list_t *keys = create_list();
|
list_t *keys = create_list();
|
||||||
|
|
||||||
// copy the keys over
|
// copy the keys over
|
||||||
for (int j = 0; j < num_syms; j++) {
|
for (int j = 0; j < num_syms; j++) {
|
||||||
xkb_keycode_t * key = malloc(sizeof(xkb_keycode_t));
|
xkb_keycode_t *key = malloc(sizeof(*key));
|
||||||
|
if (!key) {
|
||||||
|
sway_log(SWAY_ERROR,
|
||||||
|
"Unable to allocate memory for key when translating");
|
||||||
|
}
|
||||||
*key = combos[i][j];
|
*key = combos[i][j];
|
||||||
list_add(keys, key);
|
list_add(keys, key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue