aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/kill.c
blob: 85ca0f339587f975f7702b33765e88e1f57b44ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <wlr/util/log.h>
#include "log.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
#include "sway/tree/container.h"
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "sway/commands.h"

static void close_container_iterator(struct sway_container *con, void *data) {
	if (con->view) {
		view_close(con->view);
	}
}

struct cmd_results *cmd_kill(int argc, char **argv) {
	struct sway_container *con = config->handler_context.container;
	struct sway_workspace *ws = config->handler_context.workspace;

	if (con) {
		close_container_iterator(con, NULL);
		container_for_each_child(con, close_container_iterator, NULL);
	} else {
		workspace_for_each_container(ws, close_container_iterator, NULL);
	}

	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}