diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-16 12:56:44 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-16 12:56:44 -0400 |
commit | 6c233bdb8f374d02832e94c310fc8415fe15535d (patch) | |
tree | 0f28748577726d502212600d8cc743cafaa4cc6f | |
parent | 6e8280e7fdc139ad14ea99ddd885ee02cba05b7b (diff) | |
parent | dfaf3a059f3ecb97806f33c9674d7895011d623d (diff) |
Merge pull request #42 from Luminarys/master
Added in kill command and better exit handling.
-rw-r--r-- | sway/commands.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 7ddbe17e..5cb661eb 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -12,6 +12,7 @@ #include "log.h" #include "workspace.h" #include "commands.h" +#include "container.h" struct modifier_key { char *name; @@ -152,11 +153,18 @@ static bool cmd_exec(struct sway_config *config, int argc, char **argv) { return cmd_exec_always(config, argc, argv); } +static void kill_views(swayc_t *container, void *data) { + if (container->type == C_VIEW) { + wlc_view_close(container->handle); + } +} + static bool cmd_exit(struct sway_config *config, int argc, char **argv) { if (!checkarg(argc, "exit", EXPECTED_EQUAL_TO, 0)) { return false; } - // TODO: Some kind of clean up is probably in order + // Close all views + container_map(&root_container, kill_views, NULL); exit(0); return true; } @@ -188,6 +196,12 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * return true; } +static bool cmd_kill(struct sway_config *config, int argc, char **argv) { + swayc_t *view = get_focused_container(&root_container); + wlc_view_close(view->handle); + return true; +} + static bool cmd_layout(struct sway_config *config, int argc, char **argv) { if (!checkarg(argc, "layout", EXPECTED_MORE_THAN, 0)) { return false; @@ -345,6 +359,7 @@ static struct cmd_handler handlers[] = { { "focus", cmd_focus }, { "focus_follows_mouse", cmd_focus_follows_mouse }, { "fullscreen", cmd_fullscreen }, + { "kill", cmd_kill }, { "layout", cmd_layout }, { "log_colors", cmd_log_colors }, { "reload", cmd_reload }, |