mirror of
https://github.com/swaywm/sway.git
synced 2025-11-11 13:29:51 -05:00
Merge pull request #94 from taiyu-len/master
input_state.ch, and command conflicts resolved
This commit is contained in:
commit
14947c92aa
9 changed files with 243 additions and 172 deletions
|
|
@ -298,3 +298,53 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) {
|
||||
swayc_t *parent = container->parent;
|
||||
|
||||
if (dir == MOVE_PARENT) {
|
||||
if (parent->type == C_OUTPUT) {
|
||||
return NULL;
|
||||
} else {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
// Test if we can even make a difference here
|
||||
bool can_move = false;
|
||||
int diff = 0;
|
||||
if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
||||
if (parent->layout == L_HORIZ || parent->type == C_ROOT) {
|
||||
can_move = true;
|
||||
diff = dir == MOVE_LEFT ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
if (parent->layout == L_VERT) {
|
||||
can_move = true;
|
||||
diff = dir == MOVE_UP ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (can_move) {
|
||||
int i;
|
||||
for (i = 0; i < parent->children->length; ++i) {
|
||||
swayc_t *child = parent->children->items[i];
|
||||
if (child == container) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int desired = i + diff;
|
||||
if (desired < 0 || desired >= parent->children->length) {
|
||||
can_move = false;
|
||||
} else {
|
||||
return parent->children->items[desired];
|
||||
}
|
||||
}
|
||||
if (!can_move) {
|
||||
container = parent;
|
||||
parent = parent->parent;
|
||||
if (!parent) {
|
||||
// Nothing we can do
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue