Fix layout change on setting permanent

This commit is contained in:
project-repo 2023-09-17 09:56:41 +02:00
commit 8e9adb0bc7
3 changed files with 27 additions and 4 deletions

View file

@ -279,6 +279,8 @@ output_apply_config(struct cg_server *server, struct cg_output *output,
struct cg_output_config *config) {
struct wlr_output *wlr_output = output->wlr_output;
wlr_output_layout_get_box(server->output_layout, output->wlr_output,
&output->layout_box);
if(config->role != OUTPUT_ROLE_DEFAULT) {
output->role = config->role;
if((output->role == OUTPUT_ROLE_PERIPHERAL)&&(output->destroyed == true)) {
@ -317,8 +319,28 @@ output_apply_config(struct cg_server *server, struct cg_output *output,
config->pos.y);
/* Since the size of the output may have changed, we
* reinitialize all workspaces with a fullscreen layout */
for(unsigned int i = 0; i < output->server->nws; ++i) {
output_make_workspace_fullscreen(output, i);
if(output->layout_box.width!=config->pos.width||output->layout_box.height!=config->pos.height) {
for(unsigned int i = 0; i < output->server->nws; ++i) {
output_make_workspace_fullscreen(output, i);
}
} else {
wlr_output_layout_get_box(server->output_layout, output->wlr_output,
&output->layout_box);
for(unsigned int i = 0; i < server->nws; ++i) {
struct cg_workspace *ws=output->workspaces[i];
bool first = true;
for(struct cg_tile *tile = ws->focused_tile;
first || output->workspaces[i]->focused_tile != tile;
tile = tile->next) {
first = false;
if(tile->view != NULL) {
wlr_scene_node_set_position(
&tile->view->scene_tree->node,
tile->view->ox + output->layout_box.x,
output->layout_box.y);
}
}
}
}
} else {
wlr_output_layout_add_auto(server->output_layout, wlr_output);

1
seat.c
View file

@ -914,6 +914,7 @@ handle_destroy(struct wl_listener *listener, void *_data) {
wl_list_remove(&seat->request_set_cursor.link);
wl_list_remove(&seat->request_set_selection.link);
wl_list_remove(&seat->request_set_primary_selection.link);
seat->server->seat=NULL;
free(seat);
}

View file

@ -100,8 +100,8 @@ void
workspace_free_tiles(struct cg_workspace *workspace) {
workspace->focused_tile->prev->next = NULL;
while(workspace->focused_tile != NULL) {
if(!workspace->output->server->running ||
workspace->focused_tile == workspace->server->seat->cursor_tile) {
if(workspace->server->seat!=NULL&&(!workspace->output->server->running ||
workspace->focused_tile == workspace->server->seat->cursor_tile)) {
workspace->server->seat->cursor_tile = NULL;
}
struct cg_tile *next = workspace->focused_tile->next;