From 138d10d5d62a25c2e00bd9051c835b9e78a36de4 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 28 Sep 2018 21:58:23 +1000 Subject: Rename workspace_outputs to workspace_configs and fix memory leak When we eventually implement `workspace gaps inner|outer `, we'll need to store the gaps settings for workspaces before they're created. Rather than create a workspace_gaps struct, the approach I'm taking is to rename workspace_outputs to workspace_configs and then add gaps settings to that. I've added a lookup function workspace_find_config. Note that we have a similar thing for outputs (output_config struct and output_find_config). Lastly, when freeing config it would create a memory leak by freeing the list items but not the workspace or output names inside them. This has been rectified using a free_workspace_config function. --- include/sway/config.h | 13 +++++++------ include/sway/tree/workspace.h | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/sway/config.h b/include/sway/config.h index 35f0e708..af5c7a18 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -167,13 +167,12 @@ struct output_config { }; /** - * Maps a workspace name to an output name. - * - * Set via `workspace output ` + * Stores configuration for a workspace, regardless of whether the workspace + * exists. */ -struct workspace_output { - char *output; +struct workspace_config { char *workspace; + char *output; }; struct bar_config { @@ -327,7 +326,7 @@ struct sway_config { list_t *modes; list_t *bars; list_t *cmd_queue; - list_t *workspace_outputs; + list_t *workspace_configs; list_t *output_configs; list_t *input_configs; list_t *seat_configs; @@ -518,6 +517,8 @@ struct bar_config *default_bar_config(void); void free_bar_config(struct bar_config *bar); +void free_workspace_config(struct workspace_config *wsc); + /** * Updates the value of config->font_height based on the max title height * reported by each container. If recalculate is true, the containers will diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index e4b616d1..c8220b39 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -48,6 +48,8 @@ struct sway_workspace { extern char *prev_workspace_name; +struct workspace_config *workspace_find_config(const char *ws_name); + struct sway_output *workspace_get_initial_output(const char *name); struct sway_workspace *workspace_create(struct sway_output *output, -- cgit v1.2.3