mirror of
https://github.com/swaywm/sway.git
synced 2024-11-18 22:19:14 +00:00
fix nitpicks
This commit is contained in:
parent
62b7ab3959
commit
bd3ca70e3d
|
@ -16,15 +16,14 @@
|
||||||
int binding_order = 0;
|
int binding_order = 0;
|
||||||
|
|
||||||
void free_sway_binding(struct sway_binding *binding) {
|
void free_sway_binding(struct sway_binding *binding) {
|
||||||
|
if (!binding) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (binding->keys) {
|
if (binding->keys) {
|
||||||
for (int i = 0; i < binding->keys->length; i++) {
|
free_flat_list(binding->keys);
|
||||||
free(binding->keys->items[i]);
|
|
||||||
}
|
}
|
||||||
list_free(binding->keys);
|
|
||||||
}
|
|
||||||
if (binding->command) {
|
|
||||||
free(binding->command);
|
free(binding->command);
|
||||||
}
|
|
||||||
free(binding);
|
free(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_binding *binding = malloc(sizeof(struct sway_binding));
|
struct sway_binding *binding = calloc(1, sizeof(struct sway_binding));
|
||||||
if (!binding) {
|
if (!binding) {
|
||||||
return cmd_results_new(CMD_FAILURE, "bindsym",
|
return cmd_results_new(CMD_FAILURE, "bindsym",
|
||||||
"Unable to allocate binding");
|
"Unable to allocate binding");
|
||||||
|
@ -122,7 +121,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
||||||
free_flat_list(split);
|
free_flat_list(split);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t));
|
xkb_keysym_t *key = calloc(1, sizeof(xkb_keysym_t));
|
||||||
if (!key) {
|
if (!key) {
|
||||||
free_sway_binding(binding);
|
free_sway_binding(binding);
|
||||||
free_flat_list(split);
|
free_flat_list(split);
|
||||||
|
@ -165,7 +164,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_binding *binding = malloc(sizeof(struct sway_binding));
|
struct sway_binding *binding = calloc(1, sizeof(struct sway_binding));
|
||||||
if (!binding) {
|
if (!binding) {
|
||||||
return cmd_results_new(CMD_FAILURE, "bindsym",
|
return cmd_results_new(CMD_FAILURE, "bindsym",
|
||||||
"Unable to allocate binding");
|
"Unable to allocate binding");
|
||||||
|
@ -209,7 +208,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
||||||
list_free(split);
|
list_free(split);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
xkb_keycode_t *key = malloc(sizeof(xkb_keycode_t));
|
xkb_keycode_t *key = calloc(1, sizeof(xkb_keycode_t));
|
||||||
*key = keycode - 8;
|
*key = keycode - 8;
|
||||||
list_add(binding->keys, key);
|
list_add(binding->keys, key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,7 @@ static bool keyboard_execute_bindsym(struct sway_keyboard *keyboard,
|
||||||
list_t *keysym_bindings = config->current_mode->keysym_bindings;
|
list_t *keysym_bindings = config->current_mode->keysym_bindings;
|
||||||
for (int i = 0; i < keysym_bindings->length; ++i) {
|
for (int i = 0; i < keysym_bindings->length; ++i) {
|
||||||
struct sway_binding *binding = keysym_bindings->items[i];
|
struct sway_binding *binding = keysym_bindings->items[i];
|
||||||
sway_log(L_DEBUG, "@@ checking binding: %s", binding->command);
|
|
||||||
if (modifiers ^ binding->modifiers || n != binding->keys->length) {
|
if (modifiers ^ binding->modifiers || n != binding->keys->length) {
|
||||||
sway_log(L_DEBUG, "@@ modifiers or key num dont match");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +83,8 @@ static bool keyboard_execute_bindsym(struct sway_keyboard *keyboard,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
sway_log(L_DEBUG, "running command for binding: %s", binding->command);
|
sway_log(L_DEBUG, "running command for binding: %s",
|
||||||
|
binding->command);
|
||||||
struct cmd_results *results = handle_command(binding->command);
|
struct cmd_results *results = handle_command(binding->command);
|
||||||
if (results->status != CMD_SUCCESS) {
|
if (results->status != CMD_SUCCESS) {
|
||||||
sway_log(L_DEBUG, "could not run command for binding: %s",
|
sway_log(L_DEBUG, "could not run command for binding: %s",
|
||||||
|
@ -291,7 +290,6 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
// handle keycodes
|
// handle keycodes
|
||||||
handled = keyboard_execute_bindcode(keyboard);
|
handled = keyboard_execute_bindcode(keyboard);
|
||||||
sway_log(L_DEBUG, "@@ handled by bindcode? %d", handled);
|
|
||||||
|
|
||||||
// handle translated keysyms
|
// handle translated keysyms
|
||||||
const xkb_keysym_t *translated_keysyms;
|
const xkb_keysym_t *translated_keysyms;
|
||||||
|
@ -299,8 +297,8 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||||
size_t translated_keysyms_len =
|
size_t translated_keysyms_len =
|
||||||
keyboard_keysyms_translated(keyboard, keycode, &translated_keysyms,
|
keyboard_keysyms_translated(keyboard, keycode, &translated_keysyms,
|
||||||
&translated_modifiers);
|
&translated_modifiers);
|
||||||
pressed_keysyms_update(keyboard->pressed_keysyms_translated, translated_keysyms,
|
pressed_keysyms_update(keyboard->pressed_keysyms_translated,
|
||||||
translated_keysyms_len, event->state);
|
translated_keysyms, translated_keysyms_len, event->state);
|
||||||
if (event->state == WLR_KEY_PRESSED && !handled) {
|
if (event->state == WLR_KEY_PRESSED && !handled) {
|
||||||
handled = keyboard_execute_bindsym(keyboard,
|
handled = keyboard_execute_bindsym(keyboard,
|
||||||
keyboard->pressed_keysyms_translated, translated_modifiers,
|
keyboard->pressed_keysyms_translated, translated_modifiers,
|
||||||
|
@ -310,9 +308,10 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
|
||||||
// Handle raw keysyms
|
// Handle raw keysyms
|
||||||
const xkb_keysym_t *raw_keysyms;
|
const xkb_keysym_t *raw_keysyms;
|
||||||
uint32_t raw_modifiers;
|
uint32_t raw_modifiers;
|
||||||
size_t raw_keysyms_len = keyboard_keysyms_raw(keyboard, keycode, &raw_keysyms, &raw_modifiers);
|
size_t raw_keysyms_len =
|
||||||
pressed_keysyms_update(keyboard->pressed_keysyms_raw, raw_keysyms, raw_keysyms_len,
|
keyboard_keysyms_raw(keyboard, keycode, &raw_keysyms, &raw_modifiers);
|
||||||
event->state);
|
pressed_keysyms_update(keyboard->pressed_keysyms_raw, raw_keysyms,
|
||||||
|
raw_keysyms_len, event->state);
|
||||||
if (event->state == WLR_KEY_PRESSED && !handled) {
|
if (event->state == WLR_KEY_PRESSED && !handled) {
|
||||||
handled = keyboard_execute_bindsym(keyboard,
|
handled = keyboard_execute_bindsym(keyboard,
|
||||||
keyboard->pressed_keysyms_raw, raw_modifiers,
|
keyboard->pressed_keysyms_raw, raw_modifiers,
|
||||||
|
|
Loading…
Reference in a new issue