diff options
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r-- | sway/commands/focus.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c new file mode 100644 index 00000000..5286851f --- /dev/null +++ b/sway/commands/focus.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <wlr/util/log.h> | ||
2 | #include "log.h" | ||
3 | #include "sway/input/input-manager.h" | ||
4 | #include "sway/input/seat.h" | ||
5 | #include "sway/view.h" | ||
6 | #include "sway/commands.h" | ||
7 | |||
8 | struct cmd_results *cmd_focus(int argc, char **argv) { | ||
9 | swayc_t *con = config->handler_context.current_container; | ||
10 | struct sway_seat *seat = config->handler_context.seat; | ||
11 | |||
12 | if (!sway_assert(seat, "'focus' command called without seat context")) { | ||
13 | return cmd_results_new(CMD_FAILURE, "focus", | ||
14 | "Command 'focus' called without seat context (this is a bug in sway)"); | ||
15 | } | ||
16 | |||
17 | if (config->reading) { | ||
18 | return cmd_results_new(CMD_FAILURE, "focus", | ||
19 | "Command 'focus' cannot be used in the config file"); | ||
20 | } | ||
21 | if (con == NULL) { | ||
22 | wlr_log(L_DEBUG, "no container to focus"); | ||
23 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
24 | } | ||
25 | |||
26 | if (argc == 0) { | ||
27 | sway_seat_set_focus(seat, con); | ||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
29 | } | ||
30 | |||
31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
32 | } | ||