aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-02-14 16:47:23 -0500
committerTony Crisci <tony@dubstepdish.com>2018-02-14 16:47:23 -0500
commit52670c636cf5115560ce6d20e2aaab1d55c49d0b (patch)
treeccbd3fd4722758c5f5d7fb557f1c719cd51082aa /sway/commands
parent780d9fe1e3ee051a4d9eb08d1c049e19d72c1d6a (diff)
basic focus (without direction)
Diffstat (limited to 'sway/commands')
-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 @@
+#include <wlr/util/log.h>
+#include "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_focus(int argc, char **argv) {
+ swayc_t *con = config->handler_context.current_container;
+ struct sway_seat *seat = config->handler_context.seat;
+
+ if (!sway_assert(seat, "'focus' command called without seat context")) {
+ return cmd_results_new(CMD_FAILURE, "focus",
+ "Command 'focus' called without seat context (this is a bug in sway)");
+ }
+
+ if (config->reading) {
+ return cmd_results_new(CMD_FAILURE, "focus",
+ "Command 'focus' cannot be used in the config file");
+ }
+ if (con == NULL) {
+ wlr_log(L_DEBUG, "no container to focus");
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ }
+
+ if (argc == 0) {
+ sway_seat_set_focus(seat, con);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ }
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}