mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
Reduce duplicate code
This commit is contained in:
parent
6392abe35b
commit
14147ac056
|
@ -336,6 +336,17 @@ static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit s
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_binding_command(struct sway_binding *binding) {
|
||||||
|
struct sway_binding *binding_copy = sway_binding_dup(binding);
|
||||||
|
struct cmd_results *res = handle_command(binding->command);
|
||||||
|
if (res->status != CMD_SUCCESS) {
|
||||||
|
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
|
||||||
|
}
|
||||||
|
ipc_event_binding_keyboard(binding_copy);
|
||||||
|
free_cmd_results(res);
|
||||||
|
free_sway_binding(binding_copy);
|
||||||
|
}
|
||||||
|
|
||||||
static bool handle_bindsym(struct sway_binding *binding) {
|
static bool handle_bindsym(struct sway_binding *binding) {
|
||||||
bool match = false;
|
bool match = false;
|
||||||
int i;
|
int i;
|
||||||
|
@ -347,14 +358,7 @@ static bool handle_bindsym(struct sway_binding *binding) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
struct sway_binding *binding_copy = sway_binding_dup(binding);
|
handle_binding_command(binding);
|
||||||
struct cmd_results *res = handle_command(binding->command);
|
|
||||||
if (res->status != CMD_SUCCESS) {
|
|
||||||
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
|
|
||||||
}
|
|
||||||
ipc_event_binding_keyboard(binding_copy);
|
|
||||||
free_cmd_results(res);
|
|
||||||
free_sway_binding(binding_copy);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,14 +369,7 @@ static bool handle_bindsym_release(struct sway_binding *binding) {
|
||||||
if (binding->keys->length == 1) {
|
if (binding->keys->length == 1) {
|
||||||
xkb_keysym_t *key = binding->keys->items[0];
|
xkb_keysym_t *key = binding->keys->items[0];
|
||||||
if (check_released_key(*key)) {
|
if (check_released_key(*key)) {
|
||||||
struct sway_binding *binding_copy = sway_binding_dup(binding);
|
handle_binding_command(binding);
|
||||||
struct cmd_results *res = handle_command(binding->command);
|
|
||||||
if (res->status != CMD_SUCCESS) {
|
|
||||||
sway_log(L_ERROR, "Command '%s' failed: %s", res->input, res->error);
|
|
||||||
}
|
|
||||||
ipc_event_binding_keyboard(binding_copy);
|
|
||||||
free_cmd_results(res);
|
|
||||||
free_sway_binding(binding_copy);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue