aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-09-19 15:21:04 +0200
committerLibravatar emersion <contact@emersion.fr>2018-09-19 15:50:42 +0200
commitefc08ec8880b8078d35f687c7913f787efc85f72 (patch)
tree1c9d9c86ee1bc42cc6fb7f4af201babf04f4182f /sway/commands.c
parentMerge pull request #2670 from ianyfan/commands (diff)
downloadsway-efc08ec8880b8078d35f687c7913f787efc85f72.tar.gz
sway-efc08ec8880b8078d35f687c7913f787efc85f72.tar.zst
sway-efc08ec8880b8078d35f687c7913f787efc85f72.zip
Fix segfault when executing command without focus
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 41e1c653..32079492 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -215,18 +215,23 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
215 215
216static void set_config_node(struct sway_node *node) { 216static void set_config_node(struct sway_node *node) {
217 config->handler_context.node = node; 217 config->handler_context.node = node;
218 config->handler_context.container = NULL;
219 config->handler_context.workspace = NULL;
220
221 if (node == NULL) {
222 return;
223 }
224
218 switch (node->type) { 225 switch (node->type) {
219 case N_CONTAINER: 226 case N_CONTAINER:
220 config->handler_context.container = node->sway_container; 227 config->handler_context.container = node->sway_container;
221 config->handler_context.workspace = node->sway_container->workspace; 228 config->handler_context.workspace = node->sway_container->workspace;
222 break; 229 break;
223 case N_WORKSPACE: 230 case N_WORKSPACE:
224 config->handler_context.container = NULL;
225 config->handler_context.workspace = node->sway_workspace; 231 config->handler_context.workspace = node->sway_workspace;
226 break; 232 break;
227 default: 233 case N_ROOT:
228 config->handler_context.container = NULL; 234 case N_OUTPUT:
229 config->handler_context.workspace = NULL;
230 break; 235 break;
231 } 236 }
232} 237}