diff options
-rw-r--r-- | sway/commands.c | 7 | ||||
-rw-r--r-- | sway/movement.c | 14 | ||||
-rw-r--r-- | sway/movement.h | 11 |
3 files changed, 21 insertions, 11 deletions
diff --git a/sway/commands.c b/sway/commands.c index 40d9d353..64130fdc 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -112,12 +112,7 @@ int cmd_focus(struct sway_config *config, int argc, char **argv) { | |||
112 | } else if (strcasecmp(argv[0], "down") == 0) { | 112 | } else if (strcasecmp(argv[0], "down") == 0) { |
113 | return move_focus(MOVE_DOWN); | 113 | return move_focus(MOVE_DOWN); |
114 | } else if (strcasecmp(argv[0], "parent") == 0) { | 114 | } else if (strcasecmp(argv[0], "parent") == 0) { |
115 | swayc_t *current = get_focused_container(&root_container); | 115 | return move_focus(MOVE_PARENT); |
116 | if (current && current->parent) { | ||
117 | current->parent->focused = NULL; | ||
118 | unfocus_all(current->parent); | ||
119 | focus_view(current->parent); | ||
120 | } | ||
121 | } | 116 | } |
122 | return 0; | 117 | return 0; |
123 | } | 118 | } |
diff --git a/sway/movement.c b/sway/movement.c index 108e2588..4503a716 100644 --- a/sway/movement.c +++ b/sway/movement.c | |||
@@ -9,6 +9,20 @@ int move_focus(enum movement_direction direction) { | |||
9 | swayc_t *current = get_focused_container(&root_container); | 9 | swayc_t *current = get_focused_container(&root_container); |
10 | swayc_t *parent = current->parent; | 10 | swayc_t *parent = current->parent; |
11 | 11 | ||
12 | if(direction == MOVE_PARENT) { | ||
13 | current = parent; | ||
14 | parent = parent->parent; | ||
15 | if(parent->type == C_ROOT) { | ||
16 | sway_log(L_DEBUG, "Focus cannot move to parent"); | ||
17 | return 1; | ||
18 | } else { | ||
19 | sway_log(L_DEBUG, "Moving focus away from %p", current); | ||
20 | unfocus_all(parent); | ||
21 | focus_view (parent); | ||
22 | return 0; | ||
23 | } | ||
24 | } | ||
25 | |||
12 | while (true) { | 26 | while (true) { |
13 | sway_log(L_DEBUG, "Moving focus away from %p", current); | 27 | sway_log(L_DEBUG, "Moving focus away from %p", current); |
14 | 28 | ||
diff --git a/sway/movement.h b/sway/movement.h index 44e630ff..a527674c 100644 --- a/sway/movement.h +++ b/sway/movement.h | |||
@@ -4,11 +4,12 @@ | |||
4 | #include <wlc/wlc.h> | 4 | #include <wlc/wlc.h> |
5 | #include "list.h" | 5 | #include "list.h" |
6 | 6 | ||
7 | enum movement_direction{ | 7 | enum movement_direction { |
8 | MOVE_LEFT, | 8 | MOVE_LEFT, |
9 | MOVE_RIGHT, | 9 | MOVE_RIGHT, |
10 | MOVE_UP, | 10 | MOVE_UP, |
11 | MOVE_DOWN | 11 | MOVE_DOWN, |
12 | MOVE_PARENT | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | int move_focus(enum movement_direction direction); | 15 | int move_focus(enum movement_direction direction); |