mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 21:14:10 +01:00
run all commands with focused container context
This commit is contained in:
parent
6a1d71b8b8
commit
1156523ccf
@ -11,6 +11,7 @@
|
||||
#include "sway/criteria.h"
|
||||
#include "sway/security.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "stringop.h"
|
||||
#include "log.h"
|
||||
|
||||
@ -271,7 +272,14 @@ struct cmd_results *handle_command(char *_exec) {
|
||||
}
|
||||
|
||||
if (!has_criteria) {
|
||||
config->handler_context.current_container = NULL;
|
||||
// without criteria, the command acts upon the focused
|
||||
// container
|
||||
struct sway_seat *seat = config->handler_context.seat;
|
||||
if (!seat) {
|
||||
seat = sway_input_manager_get_default_seat(input_manager);
|
||||
}
|
||||
if (seat) {
|
||||
config->handler_context.current_container = seat->focus;
|
||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
||||
if (res->status != CMD_SUCCESS) {
|
||||
free_argv(argc, argv);
|
||||
@ -282,8 +290,8 @@ struct cmd_results *handle_command(char *_exec) {
|
||||
goto cleanup;
|
||||
}
|
||||
free_cmd_results(res);
|
||||
}
|
||||
} else {
|
||||
wlr_log(L_DEBUG, "@@ running command on containers");
|
||||
for (int i = 0; i < containers->length; ++i) {
|
||||
config->handler_context.current_container = containers->items[i];
|
||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
||||
|
@ -1,29 +1,21 @@
|
||||
#include <wlr/util/log.h>
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "sway/view.h"
|
||||
#include "sway/commands.h"
|
||||
|
||||
struct cmd_results *cmd_kill(int argc, char **argv) {
|
||||
struct sway_seat *seat = config->handler_context.seat;
|
||||
if (!seat) {
|
||||
seat = sway_input_manager_get_default_seat(input_manager);
|
||||
if (!config->handler_context.current_container) {
|
||||
wlr_log(L_ERROR, "cmd_kill called without container context");
|
||||
return cmd_results_new(CMD_INVALID, NULL,
|
||||
"cmd_kill called without container context "
|
||||
"(this is a bug in sway)");
|
||||
}
|
||||
// TODO close arbitrary containers without a view
|
||||
struct sway_view *view =
|
||||
config->handler_context.current_container->sway_view;
|
||||
|
||||
// TODO context for arbitrary sway containers (when we get criteria
|
||||
// working) will make seat context not explicitly required
|
||||
if (!seat) {
|
||||
return cmd_results_new(CMD_FAILURE, NULL, "no seat context given");
|
||||
}
|
||||
|
||||
struct sway_view *view = NULL;
|
||||
|
||||
if (config->handler_context.current_container) {
|
||||
view = config->handler_context.current_container->sway_view;
|
||||
} else {
|
||||
view = seat->focus->sway_view;
|
||||
}
|
||||
|
||||
if (view->iface.close) {
|
||||
if (view && view->iface.close) {
|
||||
view->iface.close(view);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user