summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-10 10:18:04 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-10 10:18:04 -0400
commitf9ae9ab6e37f1dab657527028f3123290f299406 (patch)
tree6e582145410b24851b41f0f3e3208920dac9eed3
parentNew readme screenshot (diff)
parentfixed style (diff)
downloadsway-f9ae9ab6e37f1dab657527028f3123290f299406.tar.gz
sway-f9ae9ab6e37f1dab657527028f3123290f299406.tar.zst
sway-f9ae9ab6e37f1dab657527028f3123290f299406.zip
Merge pull request #4 from taiyu-len/master
fixed focus_parent, moved into move_focus() function
-rw-r--r--sway/commands.c7
-rw-r--r--sway/movement.c14
-rw-r--r--sway/movement.h11
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..a55d0350 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
7enum movement_direction{ 7enum 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
14int move_focus(enum movement_direction direction); 15int move_focus(enum movement_direction direction);