Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed focus_parent, moved into move_focus() function #4

Merged
merged 2 commits into from
Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions sway/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ int cmd_focus(struct sway_config *config, int argc, char **argv) {
} else if (strcasecmp(argv[0], "down") == 0) {
return move_focus(MOVE_DOWN);
} else if (strcasecmp(argv[0], "parent") == 0) {
swayc_t *current = get_focused_container(&root_container);
if (current && current->parent) {
current->parent->focused = NULL;
unfocus_all(current->parent);
focus_view(current->parent);
}
return move_focus(MOVE_PARENT);
}
return 0;
}
Expand Down
14 changes: 14 additions & 0 deletions sway/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ int move_focus(enum movement_direction direction) {
swayc_t *current = get_focused_container(&root_container);
swayc_t *parent = current->parent;

if(direction == MOVE_PARENT) {
current = parent;
parent = parent->parent;
if(parent->type == C_ROOT) {
sway_log(L_DEBUG, "Focus cannot move to parent");
return 1;
} else {
sway_log(L_DEBUG, "Moving focus away from %p", current);
unfocus_all(parent);
focus_view (parent);
return 0;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style violations - add a space between if and (, and do not include a space between the function name and (.

while (true) {
sway_log(L_DEBUG, "Moving focus away from %p", current);

Expand Down
11 changes: 6 additions & 5 deletions sway/movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
#include <wlc/wlc.h>
#include "list.h"

enum movement_direction{
MOVE_LEFT,
MOVE_RIGHT,
MOVE_UP,
MOVE_DOWN
enum movement_direction {
MOVE_LEFT,
MOVE_RIGHT,
MOVE_UP,
MOVE_DOWN,
MOVE_PARENT
};

int move_focus(enum movement_direction direction);
Expand Down