@ -22,7 +22,7 @@ struct sway_container root_container;
static void output_layout_handle_change ( struct wl_listener * listener ,
static void output_layout_handle_change ( struct wl_listener * listener ,
void * data ) {
void * data ) {
arrange_ root( ) ;
arrange_ and_commit( & root_container ) ;
}
}
void layout_init ( void ) {
void layout_init ( void ) {
@ -56,18 +56,17 @@ static int index_child(const struct sway_container *child) {
return - 1 ;
return - 1 ;
}
}
static void container_handle_fullscreen_reparent ( struct sway_container * view con,
static void container_handle_fullscreen_reparent ( struct sway_container * con,
struct sway_container * old_parent ) {
struct sway_container * old_parent ) {
if ( view con- > type ! = C_VIEW | | ! view con- > sway_view - > is_fullscreen ) {
if ( con- > type ! = C_VIEW | | ! con- > sway_view - > is_fullscreen ) {
return ;
return ;
}
}
struct sway_view * view = view con- > sway_view ;
struct sway_view * view = con- > sway_view ;
struct sway_container * old_workspace = old_parent ;
struct sway_container * old_workspace = old_parent ;
if ( old_workspace & & old_workspace - > type ! = C_WORKSPACE ) {
if ( old_workspace & & old_workspace - > type ! = C_WORKSPACE ) {
old_workspace = container_parent ( old_workspace , C_WORKSPACE ) ;
old_workspace = container_parent ( old_workspace , C_WORKSPACE ) ;
}
}
struct sway_container * new_workspace = container_parent ( view - > swayc ,
struct sway_container * new_workspace = container_parent ( con , C_WORKSPACE ) ;
C_WORKSPACE ) ;
if ( old_workspace = = new_workspace ) {
if ( old_workspace = = new_workspace ) {
return ;
return ;
}
}
@ -78,15 +77,19 @@ static void container_handle_fullscreen_reparent(struct sway_container *viewcon,
// Mark the new workspace as fullscreen
// Mark the new workspace as fullscreen
if ( new_workspace - > sway_workspace - > fullscreen ) {
if ( new_workspace - > sway_workspace - > fullscreen ) {
view_set_fullscreen_raw (
view_set_fullscreen ( new_workspace - > sway_workspace - > fullscreen , false ) ;
new_workspace - > sway_workspace - > fullscreen , false ) ;
}
}
new_workspace - > sway_workspace - > fullscreen = view ;
new_workspace - > sway_workspace - > fullscreen = view ;
// Resize view to new output dimensions
// Resize view to new output dimensions
struct sway_container * output = new_workspace - > parent ;
struct sway_container * output = new_workspace - > parent ;
view_configure ( view , 0 , 0 , output - > width , output - > height ) ;
view - > x = output - > x ;
view - > swayc - > width = output - > width ;
view - > y = output - > y ;
view - > swayc - > height = output - > height ;
view - > width = output - > width ;
view - > height = output - > height ;
con - > x = output - > x ;
con - > y = output - > y ;
con - > width = output - > width ;
con - > height = output - > height ;
}
}
void container_insert_child ( struct sway_container * parent ,
void container_insert_child ( struct sway_container * parent ,
@ -188,18 +191,7 @@ void container_move_to(struct sway_container *container,
}
}
container_notify_subtree_changed ( old_parent ) ;
container_notify_subtree_changed ( old_parent ) ;
container_notify_subtree_changed ( new_parent ) ;
container_notify_subtree_changed ( new_parent ) ;
if ( old_parent ) {
if ( old_parent - > type = = C_OUTPUT ) {
arrange_output ( old_parent ) ;
} else {
arrange_children_of ( old_parent ) ;
}
}
if ( new_parent - > type = = C_OUTPUT ) {
arrange_output ( new_parent ) ;
} else {
arrange_children_of ( new_parent ) ;
}
// If view was moved to a fullscreen workspace, refocus the fullscreen view
// If view was moved to a fullscreen workspace, refocus the fullscreen view
struct sway_container * new_workspace = container ;
struct sway_container * new_workspace = container ;
if ( new_workspace - > type ! = C_WORKSPACE ) {
if ( new_workspace - > type ! = C_WORKSPACE ) {
@ -214,7 +206,8 @@ void container_move_to(struct sway_container *container,
if ( focus_ws - > type ! = C_WORKSPACE ) {
if ( focus_ws - > type ! = C_WORKSPACE ) {
focus_ws = container_parent ( focus_ws , C_WORKSPACE ) ;
focus_ws = container_parent ( focus_ws , C_WORKSPACE ) ;
}
}
seat_set_focus ( seat , new_workspace - > sway_workspace - > fullscreen - > swayc ) ;
seat_set_focus ( seat ,
new_workspace - > sway_workspace - > fullscreen - > swayc ) ;
if ( focus_ws ! = new_workspace ) {
if ( focus_ws ! = new_workspace ) {
seat_set_focus ( seat , focus ) ;
seat_set_focus ( seat , focus ) ;
}
}
@ -308,7 +301,6 @@ static void workspace_rejigger(struct sway_container *ws,
container_reap_empty_recursive ( original_parent ) ;
container_reap_empty_recursive ( original_parent ) ;
wl_signal_emit ( & child - > events . reparent , original_parent ) ;
wl_signal_emit ( & child - > events . reparent , original_parent ) ;
container_create_notify ( new_parent ) ;
container_create_notify ( new_parent ) ;
arrange_workspace ( ws ) ;
}
}
static void move_out_of_tabs_stacks ( struct sway_container * container ,
static void move_out_of_tabs_stacks ( struct sway_container * container ,
@ -319,11 +311,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container,
wlr_log ( L_DEBUG , " Changing layout of %zd " , current - > parent - > id ) ;
wlr_log ( L_DEBUG , " Changing layout of %zd " , current - > parent - > id ) ;
current - > parent - > layout = move_dir = =
current - > parent - > layout = move_dir = =
MOVE_LEFT | | move_dir = = MOVE_RIGHT ? L_HORIZ : L_VERT ;
MOVE_LEFT | | move_dir = = MOVE_RIGHT ? L_HORIZ : L_VERT ;
if ( current - > parent - > type = = C_WORKSPACE ) {
arrange_workspace ( current - > parent ) ;
} else {
arrange_children_of ( current - > parent ) ;
}
return ;
return ;
}
}
@ -339,11 +326,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container,
container_flatten ( new_parent - > parent ) ;
container_flatten ( new_parent - > parent ) ;
}
}
container_create_notify ( new_parent ) ;
container_create_notify ( new_parent ) ;
if ( is_workspace ) {
arrange_workspace ( new_parent - > parent ) ;
} else {
arrange_children_of ( new_parent ) ;
}
container_notify_subtree_changed ( new_parent ) ;
container_notify_subtree_changed ( new_parent ) ;
}
}
@ -367,10 +349,7 @@ void container_move(struct sway_container *container,
struct sway_container * new_parent = container_flatten ( parent ) ;
struct sway_container * new_parent = container_flatten ( parent ) ;
if ( new_parent ! = parent ) {
if ( new_parent ! = parent ) {
// Special case: we were the last one in this container, so flatten it
// Special case: we were the last one in this container, so leave
// and leave
arrange_children_of ( new_parent ) ;
update_debug_tree ( ) ;
return ;
return ;
}
}
@ -452,12 +431,9 @@ void container_move(struct sway_container *container,
wlr_log ( L_DEBUG , " Hit limit, "
wlr_log ( L_DEBUG , " Hit limit, "
" promoting descendant to sibling " ) ;
" promoting descendant to sibling " ) ;
// Special case
// Special case
struct sway_container * old_parent = container - > parent ;
container_insert_child ( current - > parent , container ,
container_insert_child ( current - > parent , container ,
index + ( offs < 0 ? 0 : 1 ) ) ;
index + ( offs < 0 ? 0 : 1 ) ) ;
container - > width = container - > height = 0 ;
container - > width = container - > height = 0 ;
arrange_children_of ( current - > parent ) ;
arrange_children_of ( old_parent ) ;
return ;
return ;
}
}
} else {
} else {
@ -491,14 +467,11 @@ void container_move(struct sway_container *container,
wlr_log ( L_DEBUG , " Swapping siblings " ) ;
wlr_log ( L_DEBUG , " Swapping siblings " ) ;
sibling - > parent - > children - > items [ index + offs ] = container ;
sibling - > parent - > children - > items [ index + offs ] = container ;
sibling - > parent - > children - > items [ index ] = sibling ;
sibling - > parent - > children - > items [ index ] = sibling ;
arrange_children_of ( sibling - > parent ) ;
} else {
} else {
wlr_log ( L_DEBUG , " Promoting to sibling of cousin " ) ;
wlr_log ( L_DEBUG , " Promoting to sibling of cousin " ) ;
container_insert_child ( sibling - > parent , container ,
container_insert_child ( sibling - > parent , container ,
index_child ( sibling ) + ( offs > 0 ? 0 : 1 ) ) ;
index_child ( sibling ) + ( offs > 0 ? 0 : 1 ) ) ;
container - > width = container - > height = 0 ;
container - > width = container - > height = 0 ;
arrange_children_of ( sibling - > parent ) ;
arrange_children_of ( old_parent ) ;
}
}
sibling = NULL ;
sibling = NULL ;
break ;
break ;
@ -512,8 +485,6 @@ void container_move(struct sway_container *container,
" (move dir: %d) " , limit , move_dir ) ;
" (move dir: %d) " , limit , move_dir ) ;
container_insert_child ( sibling , container , limit ) ;
container_insert_child ( sibling , container , limit ) ;
container - > width = container - > height = 0 ;
container - > width = container - > height = 0 ;
arrange_children_of ( sibling ) ;
arrange_children_of ( old_parent ) ;
sibling = NULL ;
sibling = NULL ;
} else {
} else {
wlr_log ( L_DEBUG , " Reparenting container (perpendicular) " ) ;
wlr_log ( L_DEBUG , " Reparenting container (perpendicular) " ) ;
@ -537,8 +508,6 @@ void container_move(struct sway_container *container,
container_add_child ( sibling , container ) ;
container_add_child ( sibling , container ) ;
}
}
container - > width = container - > height = 0 ;
container - > width = container - > height = 0 ;
arrange_children_of ( sibling ) ;
arrange_children_of ( old_parent ) ;
sibling = NULL ;
sibling = NULL ;
}
}
break ;
break ;
@ -863,7 +832,6 @@ struct sway_container *container_split(struct sway_container *child,
// Special case: this just behaves like splitt
// Special case: this just behaves like splitt
child - > prev_layout = child - > layout ;
child - > prev_layout = child - > layout ;
child - > layout = layout ;
child - > layout = layout ;
arrange_children_of ( child ) ;
return child ;
return child ;
}
}
@ -1044,9 +1012,6 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) {
prev_workspace_name = stored_prev_name ;
prev_workspace_name = stored_prev_name ;
}
}
arrange_children_of ( con1 - > parent ) ;
arrange_children_of ( con2 - > parent ) ;
if ( fs1 & & con2 - > type = = C_VIEW ) {
if ( fs1 & & con2 - > type = = C_VIEW ) {
view_set_fullscreen ( con2 - > sway_view , true ) ;
view_set_fullscreen ( con2 - > sway_view , true ) ;
}
}