Implement a murder command

The murder command destroys the client that a given surface is connected
to.
master
itycodes 4 weeks ago
parent 02ca18fe29
commit 0b50e4acef

@ -150,6 +150,7 @@ sway_cmd cmd_input;
sway_cmd cmd_seat; sway_cmd cmd_seat;
sway_cmd cmd_ipc; sway_cmd cmd_ipc;
sway_cmd cmd_kill; sway_cmd cmd_kill;
sway_cmd cmd_murder;
sway_cmd cmd_layout; sway_cmd cmd_layout;
sway_cmd cmd_log_colors; sway_cmd cmd_log_colors;
sway_cmd cmd_mark; sway_cmd cmd_mark;

@ -272,6 +272,8 @@ void view_set_tiled(struct sway_view *view, bool tiled);
void view_close(struct sway_view *view); void view_close(struct sway_view *view);
void view_murder(struct sway_view *view);
void view_close_popups(struct sway_view *view); void view_close_popups(struct sway_view *view);
// view implementation // view implementation

@ -124,6 +124,7 @@ static const struct cmd_handler command_handlers[] = {
{ "mark", cmd_mark }, { "mark", cmd_mark },
{ "max_render_time", cmd_max_render_time }, { "max_render_time", cmd_max_render_time },
{ "move", cmd_move }, { "move", cmd_move },
{ "murder", cmd_murder },
{ "nop", cmd_nop }, { "nop", cmd_nop },
{ "opacity", cmd_opacity }, { "opacity", cmd_opacity },
{ "reload", cmd_reload }, { "reload", cmd_reload },

@ -0,0 +1,31 @@
#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_murder(con->view);
}
}
struct cmd_results *cmd_murder(int argc, char **argv) {
if (!root->outputs->length) {
return cmd_results_new(CMD_INVALID,
"Can't run this command while there's no outputs connected.");
}
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);
}

@ -73,6 +73,7 @@ sway_sources = files(
'commands/inhibit_idle.c', 'commands/inhibit_idle.c',
'commands/kill.c', 'commands/kill.c',
'commands/mark.c', 'commands/mark.c',
'commands/murder.c',
'commands/max_render_time.c', 'commands/max_render_time.c',
'commands/opacity.c', 'commands/opacity.c',
'commands/include.c', 'commands/include.c',

@ -454,6 +454,11 @@ void view_close(struct sway_view *view) {
} }
} }
void view_murder(struct sway_view *view) {
struct wl_client *client = wl_resource_get_client(view->surface->resource);
wl_client_destroy(client);
}
void view_close_popups(struct sway_view *view) { void view_close_popups(struct sway_view *view) {
if (view->impl->close_popups) { if (view->impl->close_popups) {
view->impl->close_popups(view); view->impl->close_popups(view);

Loading…
Cancel
Save