Skip to content

Commit 3e26353

Browse files
committed
Make move_to_container insert at the correct index.
1 parent bff991d commit 3e26353

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

sway/commands/move.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,25 @@ static void container_move_to_container(struct sway_container *container,
257257
if (destination->view) {
258258
container_add_sibling(destination, container, 1);
259259
} else {
260-
container_add_child(destination, container);
260+
/* For split containers, we use the currently focused container within it.
261+
* This allows setting marks on, e.g., tabbed containers which will move
262+
* con to a new tab behind the focused tab. */
263+
sway_log(SWAY_DEBUG, "target is a split container, descending to the currently focused child.");
264+
struct sway_node *focused = seat_get_active_tiling_child(
265+
config->handler_context.seat, &destination->node);
266+
if (!focused || focused == &destination->node) {
267+
// The container has no children
268+
container_add_child(destination, container);
269+
return;
270+
}
271+
struct sway_container *target = focused->sway_container;
272+
int index = container_sibling_index(target) + 1;
273+
if (target->pending.parent) {
274+
container_insert_child(target->pending.parent, container, index);
275+
} else {
276+
// FIXME: This would work except 'Only containers can have marks'.
277+
workspace_insert_tiling(target->pending.workspace, container, index);
278+
}
261279
}
262280

263281
if (container->view) {

0 commit comments

Comments
 (0)