summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2016-07-27 22:42:45 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2016-07-27 22:48:46 -0400
commit88b7cbe314aaefc9cc96884a655a2d9aea84ee0a (patch)
tree293bdbf27966b01a31574f40eb83f4b6ab834ba1
parentMerge pull request #790 from acrisci/bug/switch-focus-workspace-output (diff)
downloadsway-88b7cbe314aaefc9cc96884a655a2d9aea84ee0a.tar.gz
sway-88b7cbe314aaefc9cc96884a655a2d9aea84ee0a.tar.zst
sway-88b7cbe314aaefc9cc96884a655a2d9aea84ee0a.zip
Implement `focus child` command
The `focus child` command focuses the child container within the selected container.
-rw-r--r--include/focus.h3
-rw-r--r--sway/commands.c4
-rw-r--r--sway/focus.c2
-rw-r--r--sway/layout.c4
-rw-r--r--sway/sway.5.txt4
5 files changed, 12 insertions, 5 deletions
diff --git a/include/focus.h b/include/focus.h
index 602b6122..236d050b 100644
--- a/include/focus.h
+++ b/include/focus.h
@@ -5,7 +5,8 @@ enum movement_direction {
5 MOVE_RIGHT, 5 MOVE_RIGHT,
6 MOVE_UP, 6 MOVE_UP,
7 MOVE_DOWN, 7 MOVE_DOWN,
8 MOVE_PARENT 8 MOVE_PARENT,
9 MOVE_CHILD
9}; 10};
10 11
11#include "container.h" 12#include "container.h"
diff --git a/sway/commands.c b/sway/commands.c
index ed561764..56701634 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -864,6 +864,8 @@ static struct cmd_results *cmd_focus(int argc, char **argv) {
864 move_focus(MOVE_DOWN); 864 move_focus(MOVE_DOWN);
865 } else if (strcasecmp(argv[0], "parent") == 0) { 865 } else if (strcasecmp(argv[0], "parent") == 0) {
866 move_focus(MOVE_PARENT); 866 move_focus(MOVE_PARENT);
867 } else if (strcasecmp(argv[0], "child") == 0) {
868 move_focus(MOVE_CHILD);
867 } else if (strcasecmp(argv[0], "mode_toggle") == 0) { 869 } else if (strcasecmp(argv[0], "mode_toggle") == 0) {
868 int i; 870 int i;
869 swayc_t *workspace = swayc_active_workspace(); 871 swayc_t *workspace = swayc_active_workspace();
@@ -903,7 +905,7 @@ static struct cmd_results *cmd_focus(int argc, char **argv) {
903 } 905 }
904 } else { 906 } else {
905 return cmd_results_new(CMD_INVALID, "focus", 907 return cmd_results_new(CMD_INVALID, "focus",
906 "Expected 'focus <direction|parent|mode_toggle>' or 'focus output <direction|name>'"); 908 "Expected 'focus <direction|parent|child|mode_toggle>' or 'focus output <direction|name>'");
907 } 909 }
908 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 910 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
909} 911}
diff --git a/sway/focus.c b/sway/focus.c
index c7737a1d..0f629e1e 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -72,7 +72,7 @@ bool move_focus(enum movement_direction direction) {
72 return false; 72 return false;
73 } else if (new_view->type == C_OUTPUT) { 73 } else if (new_view->type == C_OUTPUT) {
74 return set_focused_container(swayc_active_workspace_for(new_view)); 74 return set_focused_container(swayc_active_workspace_for(new_view));
75 } else if (direction == MOVE_PARENT) { 75 } else if (direction == MOVE_PARENT || direction == MOVE_CHILD) {
76 return set_focused_container(new_view); 76 return set_focused_container(new_view);
77 } else if (config->mouse_warping) { 77 } else if (config->mouse_warping) {
78 swayc_t *old_op = old_view->type == C_OUTPUT ? 78 swayc_t *old_op = old_view->type == C_OUTPUT ?
diff --git a/sway/layout.c b/sway/layout.c
index 1d5944f8..cd5a31bc 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -1009,6 +1009,10 @@ static swayc_t *get_swayc_in_output_direction(swayc_t *output, enum movement_dir
1009} 1009}
1010 1010
1011swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit) { 1011swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit) {
1012 if (dir == MOVE_CHILD) {
1013 return container->focused;
1014 }
1015
1012 swayc_t *parent = container->parent; 1016 swayc_t *parent = container->parent;
1013 if (dir == MOVE_PARENT) { 1017 if (dir == MOVE_PARENT) {
1014 if (parent->type == C_OUTPUT) { 1018 if (parent->type == C_OUTPUT) {
diff --git a/sway/sway.5.txt b/sway/sway.5.txt
index 18b693f8..fdf5c0c1 100644
--- a/sway/sway.5.txt
+++ b/sway/sway.5.txt
@@ -59,8 +59,8 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**(
59 Make focused view floating, non-floating, or the opposite of what it is now. 59 Make focused view floating, non-floating, or the opposite of what it is now.
60 60
61**focus** <direction>:: 61**focus** <direction>::
62 Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The 62 Direction may be one of _up_, _down_, _left_, _right_, _parent_, or _child_.
63 directional focus commands will move the focus in that direction. The parent 63 The directional focus commands will move the focus in that direction. The parent
64 focus command will change the focus to the parent of the currently focused 64 focus command will change the focus to the parent of the currently focused
65 container, which is useful, for example, to open a sibling of the parent 65 container, which is useful, for example, to open a sibling of the parent
66 container, or to move the entire container around. 66 container, or to move the entire container around.