aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/focus.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-02-14 16:47:23 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-02-14 16:47:23 -0500
commit52670c636cf5115560ce6d20e2aaab1d55c49d0b (patch)
treeccbd3fd4722758c5f5d7fb557f1c719cd51082aa /sway/commands/focus.c
parentcleanup layout.c (diff)
downloadsway-52670c636cf5115560ce6d20e2aaab1d55c49d0b.tar.gz
sway-52670c636cf5115560ce6d20e2aaab1d55c49d0b.tar.zst
sway-52670c636cf5115560ce6d20e2aaab1d55c49d0b.zip
basic focus (without direction)
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r--sway/commands/focus.c32
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
8struct 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}