mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	commands/move: maintain workspace_layout when moving
Fixes #5157.
(cherry picked from commit b4a75a1ab2)
			
			
This commit is contained in:
		
							parent
							
								
									c199c8d6ea
								
							
						
					
					
						commit
						83382f0b4e
					
				
					 2 changed files with 14 additions and 4 deletions
				
			
		| 
						 | 
					@ -275,12 +275,11 @@ static void workspace_rejigger(struct sway_workspace *ws,
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	container_detach(child);
 | 
						container_detach(child);
 | 
				
			||||||
	struct sway_container *new_parent = workspace_wrap_children(ws);
 | 
						workspace_wrap_children(ws);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int index =
 | 
						int index =
 | 
				
			||||||
		move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? 0 : 1;
 | 
							move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? 0 : 1;
 | 
				
			||||||
	workspace_insert_tiling(ws, child, index);
 | 
						workspace_insert_tiling(ws, child, index);
 | 
				
			||||||
	container_flatten(new_parent);
 | 
					 | 
				
			||||||
	ws->layout =
 | 
						ws->layout =
 | 
				
			||||||
		move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ?
 | 
							move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ?
 | 
				
			||||||
		L_HORIZ : L_VERT;
 | 
							L_HORIZ : L_VERT;
 | 
				
			||||||
| 
						 | 
					@ -349,8 +348,11 @@ static bool container_move_in_direction(struct sway_container *container,
 | 
				
			||||||
							container_insert_child(current->parent, container,
 | 
												container_insert_child(current->parent, container,
 | 
				
			||||||
									index + (offs < 0 ? 0 : 1));
 | 
														index + (offs < 0 ? 0 : 1));
 | 
				
			||||||
						} else {
 | 
											} else {
 | 
				
			||||||
							workspace_insert_tiling(current->workspace, container,
 | 
												struct sway_workspace *ws = current->workspace;
 | 
				
			||||||
									index + (offs < 0 ? 0 : 1));
 | 
												workspace_insert_tiling(ws,
 | 
				
			||||||
 | 
													container_split(container,
 | 
				
			||||||
 | 
														output_get_default_layout(ws->output)),
 | 
				
			||||||
 | 
													index + (offs < 0 ? 0 : 1));
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						return true;
 | 
											return true;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1329,6 +1329,14 @@ void container_detach(struct sway_container *child) {
 | 
				
			||||||
		container_update_representation(old_parent);
 | 
							container_update_representation(old_parent);
 | 
				
			||||||
		node_set_dirty(&old_parent->node);
 | 
							node_set_dirty(&old_parent->node);
 | 
				
			||||||
	} else if (old_workspace) {
 | 
						} else if (old_workspace) {
 | 
				
			||||||
 | 
							// We may have removed the last tiling child from the workspace. If the
 | 
				
			||||||
 | 
							// workspace layout was e.g. tabbed, then at this point it may be just
 | 
				
			||||||
 | 
							// H[]. So, reset it to the default (e.g. T[]) for next time.
 | 
				
			||||||
 | 
							if (!old_workspace->tiling->length) {
 | 
				
			||||||
 | 
								old_workspace->layout =
 | 
				
			||||||
 | 
									output_get_default_layout(old_workspace->output);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		workspace_update_representation(old_workspace);
 | 
							workspace_update_representation(old_workspace);
 | 
				
			||||||
		node_set_dirty(&old_workspace->node);
 | 
							node_set_dirty(&old_workspace->node);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue