@ -144,38 +144,22 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
}
}
}
}
/**
static void arrange_children_of ( struct sway_container * parent ) ;
* If a container has been deleted from the pending tree state , we must add it
* to the transaction so it can be freed afterwards . To do this , we iterate the
* server ' s destroying_containers list and add all of them . We may add more than
* what we need to , but this is easy and has no negative consequences .
*/
static void add_deleted_containers ( struct sway_transaction * transaction ) {
for ( int i = 0 ; i < server . destroying_containers - > length ; + + i ) {
struct sway_container * child = server . destroying_containers - > items [ i ] ;
transaction_add_container ( transaction , child ) ;
}
}
static void arrange_children_of ( struct sway_container * parent ,
struct sway_transaction * transaction ) ;
static void arrange_floating ( struct sway_container * floating ,
static void arrange_floating ( struct sway_container * floating ) {
struct sway_transaction * transaction ) {
for ( int i = 0 ; i < floating - > children - > length ; + + i ) {
for ( int i = 0 ; i < floating - > children - > length ; + + i ) {
struct sway_container * floater = floating - > children - > items [ i ] ;
struct sway_container * floater = floating - > children - > items [ i ] ;
if ( floater - > type = = C_VIEW ) {
if ( floater - > type = = C_VIEW ) {
view_autoconfigure ( floater - > sway_view ) ;
view_autoconfigure ( floater - > sway_view ) ;
} else {
} else {
arrange_children_of ( floater , transaction );
arrange_children_of ( floater ) ;
}
}
transaction_add_container( transaction , floater ) ;
container_set_dirty ( floater ) ;
}
}
transaction_add_container( transaction , floating ) ;
container_set_dirty ( floating ) ;
}
}
static void arrange_children_of ( struct sway_container * parent ,
static void arrange_children_of ( struct sway_container * parent ) {
struct sway_transaction * transaction ) {
if ( config - > reloading ) {
if ( config - > reloading ) {
return ;
return ;
}
}
@ -198,7 +182,7 @@ static void arrange_children_of(struct sway_container *parent,
apply_horiz_layout ( parent ) ;
apply_horiz_layout ( parent ) ;
break ;
break ;
case L_FLOATING :
case L_FLOATING :
arrange_floating ( parent , transaction );
arrange_floating ( parent );
break ;
break ;
}
}
@ -213,14 +197,13 @@ static void arrange_children_of(struct sway_container *parent,
if ( child - > type = = C_VIEW ) {
if ( child - > type = = C_VIEW ) {
view_autoconfigure ( child - > sway_view ) ;
view_autoconfigure ( child - > sway_view ) ;
} else {
} else {
arrange_children_of ( child , transaction );
arrange_children_of ( child );
}
}
transaction_add_container( transaction , child ) ;
container_set_dirty( child ) ;
}
}
}
}
static void arrange_workspace ( struct sway_container * workspace ,
static void arrange_workspace ( struct sway_container * workspace ) {
struct sway_transaction * transaction ) {
if ( config - > reloading ) {
if ( config - > reloading ) {
return ;
return ;
}
}
@ -234,15 +217,14 @@ static void arrange_workspace(struct sway_container *workspace,
workspace - > x = output - > x + area - > x ;
workspace - > x = output - > x + area - > x ;
workspace - > y = output - > y + area - > y ;
workspace - > y = output - > y + area - > y ;
add_gaps ( workspace ) ;
add_gaps ( workspace ) ;
transaction_add_container( transaction , workspace ) ;
container_set_dirty( workspace ) ;
wlr_log ( WLR_DEBUG , " Arranging workspace '%s' at %f, %f " , workspace - > name ,
wlr_log ( WLR_DEBUG , " Arranging workspace '%s' at %f, %f " , workspace - > name ,
workspace - > x , workspace - > y ) ;
workspace - > x , workspace - > y ) ;
arrange_floating ( workspace - > sway_workspace - > floating , transaction );
arrange_floating ( workspace - > sway_workspace - > floating );
arrange_children_of ( workspace , transaction );
arrange_children_of ( workspace );
}
}
static void arrange_output ( struct sway_container * output ,
static void arrange_output ( struct sway_container * output ) {
struct sway_transaction * transaction ) {
if ( config - > reloading ) {
if ( config - > reloading ) {
return ;
return ;
}
}
@ -253,16 +235,16 @@ static void arrange_output(struct sway_container *output,
output - > y = output_box - > y ;
output - > y = output_box - > y ;
output - > width = output_box - > width ;
output - > width = output_box - > width ;
output - > height = output_box - > height ;
output - > height = output_box - > height ;
transaction_add_container( transaction , output ) ;
container_set_dirty( output ) ;
wlr_log ( WLR_DEBUG , " Arranging output '%s' at %f,%f " ,
wlr_log ( WLR_DEBUG , " Arranging output '%s' at %f,%f " ,
output - > name , output - > x , output - > y ) ;
output - > name , output - > x , output - > y ) ;
for ( int i = 0 ; i < output - > children - > length ; + + i ) {
for ( int i = 0 ; i < output - > children - > length ; + + i ) {
struct sway_container * workspace = output - > children - > items [ i ] ;
struct sway_container * workspace = output - > children - > items [ i ] ;
arrange_workspace ( workspace , transaction );
arrange_workspace ( workspace );
}
}
}
}
static void arrange_root ( struct sway_transaction * transaction ) {
static void arrange_root ( ) {
if ( config - > reloading ) {
if ( config - > reloading ) {
return ;
return ;
}
}
@ -274,43 +256,35 @@ static void arrange_root(struct sway_transaction *transaction) {
root_container . y = layout_box - > y ;
root_container . y = layout_box - > y ;
root_container . width = layout_box - > width ;
root_container . width = layout_box - > width ;
root_container . height = layout_box - > height ;
root_container . height = layout_box - > height ;
transaction_add_container( transaction , & root_container ) ;
container_set_dirty( & root_container ) ;
for ( int i = 0 ; i < root_container . children - > length ; + + i ) {
for ( int i = 0 ; i < root_container . children - > length ; + + i ) {
struct sway_container * output = root_container . children - > items [ i ] ;
struct sway_container * output = root_container . children - > items [ i ] ;
arrange_output ( output , transaction );
arrange_output ( output );
}
}
}
}
void arrange_windows ( struct sway_container * container ,
void arrange_windows ( struct sway_container * container ) {
struct sway_transaction * transaction ) {
switch ( container - > type ) {
switch ( container - > type ) {
case C_ROOT :
case C_ROOT :
arrange_root ( transaction ) ;
arrange_root ( ) ;
break ;
break ;
case C_OUTPUT :
case C_OUTPUT :
arrange_output ( container , transaction );
arrange_output ( container );
break ;
break ;
case C_WORKSPACE :
case C_WORKSPACE :
arrange_workspace ( container , transaction );
arrange_workspace ( container );
break ;
break ;
case C_CONTAINER :
case C_CONTAINER :
arrange_children_of ( container , transaction );
arrange_children_of ( container );
transaction_add_container( transaction , container ) ;
container_set_dirty( container ) ;
break ;
break ;
case C_VIEW :
case C_VIEW :
view_autoconfigure ( container - > sway_view ) ;
view_autoconfigure ( container - > sway_view ) ;
transaction_add_container( transaction , container ) ;
container_set_dirty( container ) ;
break ;
break ;
case C_TYPES :
case C_TYPES :
break ;
break ;
}
}
add_deleted_containers ( transaction ) ;
}
void arrange_and_commit ( struct sway_container * container ) {
struct sway_transaction * transaction = transaction_create ( ) ;
arrange_windows ( container , transaction ) ;
transaction_commit ( transaction ) ;
}
}
void remove_gaps ( struct sway_container * c ) {
void remove_gaps ( struct sway_container * c ) {