From 8e9adb0bc71cebc9a41d9103f4ec910461dda34f Mon Sep 17 00:00:00 2001 From: project-repo Date: Sun, 17 Sep 2023 09:56:41 +0200 Subject: [PATCH] Fix layout change on setting permanent --- output.c | 26 ++++++++++++++++++++++++-- seat.c | 1 + workspace.c | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/output.c b/output.c index 881d9e4..5d16699 100644 --- a/output.c +++ b/output.c @@ -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); diff --git a/seat.c b/seat.c index ee78e24..efa6129 100644 --- a/seat.c +++ b/seat.c @@ -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); } diff --git a/workspace.c b/workspace.c index 0bbbcf4..8be621d 100644 --- a/workspace.c +++ b/workspace.c @@ -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;