mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
fixed focus_parent, moved into move_focus() function
This commit is contained in:
parent
6f0a1cdcd1
commit
b43161fd45
|
@ -112,12 +112,7 @@ int cmd_focus(struct sway_config *config, int argc, char **argv) {
|
||||||
} else if (strcasecmp(argv[0], "down") == 0) {
|
} else if (strcasecmp(argv[0], "down") == 0) {
|
||||||
return move_focus(MOVE_DOWN);
|
return move_focus(MOVE_DOWN);
|
||||||
} else if (strcasecmp(argv[0], "parent") == 0) {
|
} else if (strcasecmp(argv[0], "parent") == 0) {
|
||||||
swayc_t *current = get_focused_container(&root_container);
|
return move_focus(MOVE_PARENT);
|
||||||
if (current && current->parent) {
|
|
||||||
current->parent->focused = NULL;
|
|
||||||
unfocus_all(current->parent);
|
|
||||||
focus_view(current->parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,20 @@ int move_focus(enum movement_direction direction) {
|
||||||
swayc_t *current = get_focused_container(&root_container);
|
swayc_t *current = get_focused_container(&root_container);
|
||||||
swayc_t *parent = current->parent;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sway_log(L_DEBUG, "Moving focus away from %p", current);
|
sway_log(L_DEBUG, "Moving focus away from %p", current);
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
enum movement_direction{
|
enum movement_direction {
|
||||||
MOVE_LEFT,
|
MOVE_LEFT,
|
||||||
MOVE_RIGHT,
|
MOVE_RIGHT,
|
||||||
MOVE_UP,
|
MOVE_UP,
|
||||||
MOVE_DOWN
|
MOVE_DOWN,
|
||||||
|
MOVE_PARENT
|
||||||
};
|
};
|
||||||
|
|
||||||
int move_focus(enum movement_direction direction);
|
int move_focus(enum movement_direction direction);
|
||||||
|
|
Loading…
Reference in a new issue