@@ -256,7 +256,26 @@ static void container_move_to_container(struct sway_container *container,
256
256
if (destination -> view ) {
257
257
container_add_sibling (destination , container , 1 );
258
258
} else {
259
- container_add_child (destination , container );
259
+ /* For split containers, we use the currently focused container within it.
260
+ * This allows setting marks on, e.g., tabbed containers which will move
261
+ * con to a new tab behind the focused tab. */
262
+ sway_log (SWAY_DEBUG , "target is a split container, descending to the currently focused child." );
263
+ struct sway_node * focused = seat_get_active_tiling_child (
264
+ config -> handler_context .seat , & destination -> node );
265
+ if (!focused || focused == & destination -> node ) {
266
+ // The container has no children
267
+ container_add_child (destination , container );
268
+ return ;
269
+ }
270
+ struct sway_container * target = focused -> sway_container ;
271
+ int index = container_sibling_index (target ) + 1 ;
272
+ if (target -> pending .parent ) {
273
+ container_insert_child (target -> pending .parent , container , index );
274
+ } else {
275
+ // TODO: This branch is unreachable until workspaces can be marked.
276
+ // Issue url: https://github.com/swaywm/sway/issues/8474
277
+ workspace_insert_tiling (target -> pending .workspace , container , index );
278
+ }
260
279
}
261
280
262
281
if (container -> view ) {
0 commit comments