diff options
Diffstat (limited to 'include/sway/tree')
-rw-r--r-- | include/sway/tree/arrange.h | 30 | ||||
-rw-r--r-- | include/sway/tree/container.h | 48 | ||||
-rw-r--r-- | include/sway/tree/view.h | 29 |
3 files changed, 82 insertions, 25 deletions
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index a14bc5dc..6c8c0dba 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h @@ -1,5 +1,6 @@ #ifndef _SWAY_ARRANGE_H #define _SWAY_ARRANGE_H +#include "sway/desktop/transaction.h" struct sway_container; @@ -9,16 +10,23 @@ void remove_gaps(struct sway_container *c); // Add gaps around container void add_gaps(struct sway_container *c); -// Determine the root container's geometry, then iterate to everything below -void arrange_root(void); - -// Determine the output's geometry, then iterate to everything below -void arrange_output(struct sway_container *output); - -// Determine the workspace's geometry, then iterate to everything below -void arrange_workspace(struct sway_container *workspace); - -// Arrange layout for all the children of the given workspace/container -void arrange_children_of(struct sway_container *parent); +/** + * Arrange layout for all the children of the given container, and add them to + * the given transaction. + * + * Use this function if you need to arrange multiple sections of the tree in one + * transaction. + */ +void arrange_windows(struct sway_container *container, + struct sway_transaction *transaction); + +/** + * Arrange layout for the given container and commit the transaction. + * + * This function is a wrapper around arrange_windows, and handles creating and + * committing the transaction for you. Use this function if you're only doing + * one arrange operation. + */ +void arrange_and_commit(struct sway_container *container); #endif diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index b3406bbe..7e78cbef 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -54,6 +54,37 @@ struct sway_output; struct sway_workspace; struct sway_view; +struct sway_container_state { + // Container/swayc properties + enum sway_container_layout layout; + double swayc_x, swayc_y; + double swayc_width, swayc_height; + + bool has_gaps; + double current_gaps; + double gaps_inner; + double gaps_outer; + + struct sway_container *parent; + list_t *children; + + // View properties + double view_x, view_y; + double view_width, view_height; + bool is_fullscreen; + + enum sway_container_border border; + int border_thickness; + bool border_top; + bool border_bottom; + bool border_left; + bool border_right; + + // Workspace properties + struct sway_view *ws_fullscreen; + struct sway_container *ws_floating; +}; + struct sway_container { union { // TODO: Encapsulate state for other node types as well like C_CONTAINER @@ -69,6 +100,10 @@ struct sway_container { */ size_t id; + // The pending state is the main container properties, and the current state is in the below struct. + // This means most places of the code can refer to the main variables (pending state) and it'll just work. + struct sway_container_state current; + char *name; // The view's title (unformatted) char *formatted_title; // The title displayed in the title bar @@ -97,8 +132,6 @@ struct sway_container { struct sway_container *parent; - list_t *marks; // list of char* - float alpha; struct wlr_texture *title_focused; @@ -107,6 +140,10 @@ struct sway_container { struct wlr_texture *title_urgent; size_t title_height; + list_t *instructions; // struct sway_transaction_instruction * + + bool destroying; + struct { struct wl_signal destroy; // Raised after the tree updates, but before arrange_windows @@ -150,6 +187,8 @@ 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); + struct sway_container *container_destroy(struct sway_container *container); struct sway_container *container_close(struct sway_container *container); @@ -253,4 +292,9 @@ void container_set_geometry_from_floating_view(struct sway_container *con); */ bool container_is_floating(struct sway_container *container); +/** + * Get a container's box in layout coordinates. + */ +struct wlr_box *container_get_box(struct sway_container *container); + #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3df38e2d..5a615b43 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -29,15 +29,15 @@ struct sway_view_impl { const char *(*get_string_prop)(struct sway_view *view, enum sway_view_prop prop); uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); - void (*configure)(struct sway_view *view, double lx, double ly, int width, - int height); + uint32_t (*configure)(struct sway_view *view, double lx, double ly, + int width, int height); void (*set_activated)(struct sway_view *view, bool activated); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); bool (*wants_floating)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); void (*close)(struct sway_view *view); - void (*destroy)(struct sway_view *view); + void (*free)(struct sway_view *view); }; struct sway_view { @@ -68,6 +68,8 @@ struct sway_view { bool border_left; bool border_right; + bool destroying; + list_t *executed_criteria; // struct criteria * list_t *marks; // char * @@ -103,8 +105,6 @@ struct sway_xdg_shell_v6_view { struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; - - int pending_width, pending_height; }; struct sway_xdg_shell_view { @@ -119,8 +119,6 @@ struct sway_xdg_shell_view { struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; - - int pending_width, pending_height; }; struct sway_xwayland_view { @@ -138,9 +136,6 @@ struct sway_xwayland_view { struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; - - int pending_lx, pending_ly; - int pending_width, pending_height; }; struct sway_xwayland_unmanaged { @@ -212,10 +207,15 @@ uint32_t view_get_window_type(struct sway_view *view); const char *view_get_shell(struct sway_view *view); -void view_configure(struct sway_view *view, double ox, double oy, int width, +uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, int height); /** + * Center the view in its workspace and build the swayc decorations around it. + */ +void view_init_floating(struct sway_view *view); + +/** * Configure the view's position and size based on the swayc's position and * size, taking borders into consideration. */ @@ -239,11 +239,16 @@ void view_for_each_surface(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_map(struct sway_view *view, struct wlr_surface *wlr_surface); -void view_unmap(struct sway_view *view); +/** + * Unmap the view and return the surviving parent (after reaping). + */ +struct sway_container *view_unmap(struct sway_view *view); void view_update_position(struct sway_view *view, double lx, double ly); |