aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-06-11 21:41:02 -0400
committerSimon Ser <contact@emersion.fr>2019-06-12 07:56:41 +0300
commit9670ccee683ab985e89eb04302fb998c4161f2d6 (patch)
treef7cafeaf55a7c139e97a920b0b43bcb080d3a27c /sway/commands
parent2b5bf78fafdf027624ca88e1f703bc9e577f4690 (diff)
bindings: defer while initiailizing
This adds the logic to defer binding execution while sway is still initializing. Without this, the binding command would be executed, but the command handler would return CMD_DEFER, which was being treated as a failure to run. To avoid partial executions, this will defer all bindings while config->active is false.
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/bind.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index d43c87fb..49b511ad 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -559,8 +559,20 @@ struct cmd_results *cmd_unbindswitch(int argc, char **argv) {
* Execute the command associated to a binding
*/
void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) {
- sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command);
+ if (!config->active) {
+ sway_log(SWAY_DEBUG, "deferring command for binding: %s",
+ binding->command);
+ struct sway_binding *deferred = calloc(1, sizeof(struct sway_binding));
+ if (!deferred) {
+ sway_log(SWAY_ERROR, "Failed to allocate deferred binding");
+ return;
+ }
+ memcpy(deferred, binding, sizeof(struct sway_binding));
+ list_add(seat->deferred_bindings, deferred);
+ return;
+ }
+ sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command);
struct sway_container *con = NULL;
if (binding->type == BINDING_MOUSESYM
|| binding->type == BINDING_MOUSECODE) {