mirror of
https://github.com/swaywm/sway.git
synced 2025-11-02 09:01:40 -05:00
Refactor destroy functions and save workspaces when there's no outputs
This changes the destroy functions to the following: * output_begin_destroy * output_destroy * workspace_begin_destroy * workspace_destroy * container_begin_destroy * container_destroy * view_begin_destroy * view_destroy The terminology was `destroy` and `free`, and it has been changed to `begin_destroy` and `destroy` respectively. When the last output is disconnected, its workspaces will now be stashed in the root. Upon connection of a new output they will be restored. There is a new function `workspace_consider_destroy` which decides whether the given workspace should be destroyed or not (ie. empty and not visible). Calling container_begin_destroy will no longer automatically reap the parents. In some places we want to reap the parents and in some we don't, so this is left to the caller. container_reap_empty_recursive and container_reap_empty have been combined into one function and it will recurse up the tree.
This commit is contained in:
parent
f53c28d52a
commit
b6058703fa
19 changed files with 267 additions and 308 deletions
|
|
@ -39,6 +39,12 @@ struct sway_output {
|
|||
} events;
|
||||
};
|
||||
|
||||
struct sway_container *output_create(struct sway_output *sway_output);
|
||||
|
||||
void output_destroy(struct sway_container *output);
|
||||
|
||||
void output_begin_destroy(struct sway_container *output);
|
||||
|
||||
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
|
||||
struct wlr_surface *surface, struct wlr_box *box, float rotation,
|
||||
void *user_data);
|
||||
|
|
|
|||
|
|
@ -176,27 +176,6 @@ struct sway_container *container_create(enum sway_container_type type);
|
|||
|
||||
const char *container_type_to_str(enum sway_container_type type);
|
||||
|
||||
struct sway_container *output_create(struct sway_output *sway_output);
|
||||
|
||||
/**
|
||||
* Create a new container container. A container container can be a a child of
|
||||
* a workspace container or another container container.
|
||||
*/
|
||||
struct sway_container *container_container_create();
|
||||
|
||||
/**
|
||||
* Create a new output. Outputs are children of the root container and have no
|
||||
* order in the tree structure.
|
||||
*/
|
||||
struct sway_container *output_create(struct sway_output *sway_output);
|
||||
|
||||
/**
|
||||
* Create a new workspace container. Workspaces are children of an output
|
||||
* container and are ordered alphabetically by name.
|
||||
*/
|
||||
struct sway_container *workspace_create(struct sway_container *output,
|
||||
const char *name);
|
||||
|
||||
/*
|
||||
* Create a new view container. A view can be a child of a workspace container
|
||||
* or a container container and are rendered in the order and structure of
|
||||
|
|
@ -205,9 +184,9 @@ struct sway_container *workspace_create(struct sway_container *output,
|
|||
struct sway_container *container_view_create(
|
||||
struct sway_container *sibling, struct sway_view *sway_view);
|
||||
|
||||
void container_free(struct sway_container *cont);
|
||||
void container_destroy(struct sway_container *con);
|
||||
|
||||
struct sway_container *container_destroy(struct sway_container *container);
|
||||
void container_begin_destroy(struct sway_container *con);
|
||||
|
||||
struct sway_container *container_close(struct sway_container *container);
|
||||
|
||||
|
|
@ -255,10 +234,7 @@ void container_update_textures_recursive(struct sway_container *con);
|
|||
|
||||
void container_damage_whole(struct sway_container *container);
|
||||
|
||||
bool container_reap_empty(struct sway_container *con);
|
||||
|
||||
struct sway_container *container_reap_empty_recursive(
|
||||
struct sway_container *con);
|
||||
struct sway_container *container_reap_empty(struct sway_container *con);
|
||||
|
||||
struct sway_container *container_flatten(struct sway_container *container);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ struct sway_root {
|
|||
struct wl_list outputs; // sway_output::link
|
||||
|
||||
list_t *scratchpad; // struct sway_container
|
||||
list_t *saved_workspaces; // For when there's no connected outputs
|
||||
|
||||
struct {
|
||||
struct wl_signal new_container;
|
||||
|
|
|
|||
|
|
@ -284,10 +284,10 @@ void view_for_each_popup(struct sway_view *view,
|
|||
void view_init(struct sway_view *view, enum sway_view_type type,
|
||||
const struct sway_view_impl *impl);
|
||||
|
||||
void view_free(struct sway_view *view);
|
||||
|
||||
void view_destroy(struct sway_view *view);
|
||||
|
||||
void view_begin_destroy(struct sway_view *view);
|
||||
|
||||
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
|
||||
|
||||
void view_unmap(struct sway_view *view);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@ extern char *prev_workspace_name;
|
|||
|
||||
struct sway_container *workspace_get_initial_output(const char *name);
|
||||
|
||||
struct sway_container *workspace_create(struct sway_container *output,
|
||||
const char *name);
|
||||
|
||||
void workspace_destroy(struct sway_container *workspace);
|
||||
|
||||
void workspace_begin_destroy(struct sway_container *workspace);
|
||||
|
||||
void workspace_consider_destroy(struct sway_container *ws);
|
||||
|
||||
char *workspace_next_name(const char *output_name);
|
||||
|
||||
bool workspace_switch(struct sway_container *workspace,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue