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 | Config errors should not be fatal (diff) | |
parent | Added in better exit handling (diff) | |
download | sway-6c233bdb8f374d02832e94c310fc8415fe15535d.tar.gz sway-6c233bdb8f374d02832e94c310fc8415fe15535d.tar.zst sway-6c233bdb8f374d02832e94c310fc8415fe15535d.zip |
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 @@ | |||
12 | #include "log.h" | 12 | #include "log.h" |
13 | #include "workspace.h" | 13 | #include "workspace.h" |
14 | #include "commands.h" | 14 | #include "commands.h" |
15 | #include "container.h" | ||
15 | 16 | ||
16 | struct modifier_key { | 17 | struct modifier_key { |
17 | char *name; | 18 | char *name; |
@@ -152,11 +153,18 @@ static bool cmd_exec(struct sway_config *config, int argc, char **argv) { | |||
152 | return cmd_exec_always(config, argc, argv); | 153 | return cmd_exec_always(config, argc, argv); |
153 | } | 154 | } |
154 | 155 | ||
156 | static void kill_views(swayc_t *container, void *data) { | ||
157 | if (container->type == C_VIEW) { | ||
158 | wlc_view_close(container->handle); | ||
159 | } | ||
160 | } | ||
161 | |||
155 | static bool cmd_exit(struct sway_config *config, int argc, char **argv) { | 162 | static bool cmd_exit(struct sway_config *config, int argc, char **argv) { |
156 | if (!checkarg(argc, "exit", EXPECTED_EQUAL_TO, 0)) { | 163 | if (!checkarg(argc, "exit", EXPECTED_EQUAL_TO, 0)) { |
157 | return false; | 164 | return false; |
158 | } | 165 | } |
159 | // TODO: Some kind of clean up is probably in order | 166 | // Close all views |
167 | container_map(&root_container, kill_views, NULL); | ||
160 | exit(0); | 168 | exit(0); |
161 | return true; | 169 | return true; |
162 | } | 170 | } |
@@ -188,6 +196,12 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * | |||
188 | return true; | 196 | return true; |
189 | } | 197 | } |
190 | 198 | ||
199 | static bool cmd_kill(struct sway_config *config, int argc, char **argv) { | ||
200 | swayc_t *view = get_focused_container(&root_container); | ||
201 | wlc_view_close(view->handle); | ||
202 | return true; | ||
203 | } | ||
204 | |||
191 | static bool cmd_layout(struct sway_config *config, int argc, char **argv) { | 205 | static bool cmd_layout(struct sway_config *config, int argc, char **argv) { |
192 | if (!checkarg(argc, "layout", EXPECTED_MORE_THAN, 0)) { | 206 | if (!checkarg(argc, "layout", EXPECTED_MORE_THAN, 0)) { |
193 | return false; | 207 | return false; |
@@ -345,6 +359,7 @@ static struct cmd_handler handlers[] = { | |||
345 | { "focus", cmd_focus }, | 359 | { "focus", cmd_focus }, |
346 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 360 | { "focus_follows_mouse", cmd_focus_follows_mouse }, |
347 | { "fullscreen", cmd_fullscreen }, | 361 | { "fullscreen", cmd_fullscreen }, |
362 | { "kill", cmd_kill }, | ||
348 | { "layout", cmd_layout }, | 363 | { "layout", cmd_layout }, |
349 | { "log_colors", cmd_log_colors }, | 364 | { "log_colors", cmd_log_colors }, |
350 | { "reload", cmd_reload }, | 365 | { "reload", cmd_reload }, |