diff options
Diffstat (limited to 'include/sway')
-rw-r--r-- | include/sway/desktop/transaction.h | 67 | ||||
-rw-r--r-- | include/sway/input/seat.h | 11 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | include/sway/server.h | 9 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 34 | ||||
-rw-r--r-- | include/sway/tree/container.h | 48 | ||||
-rw-r--r-- | include/sway/tree/view.h | 22 |
7 files changed, 170 insertions, 23 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h new file mode 100644 index 00000000..7ab80eb8 --- /dev/null +++ b/include/sway/desktop/transaction.h @@ -0,0 +1,67 @@ +#ifndef _SWAY_TRANSACTION_H +#define _SWAY_TRANSACTION_H +#include <wlr/render/wlr_texture.h> +#include "sway/tree/container.h" + +/** + * Transactions enable us to perform atomic layout updates. + * + * When we want to make adjustments to the layout, we create a transaction. + * A transaction contains a list of affected containers and their new state. + * A state might contain a new size, or new border settings, or new parent/child + * relationships. + * + * Calling transaction_commit() makes sway notify of all the affected clients + * with their new sizes. We then wait for all the views to respond with their + * new surface sizes. When all are ready, or when a timeout has passed, we apply + * the updates all at the same time. + */ + +struct sway_transaction; + +/** + * Create a new transaction. + */ +struct sway_transaction *transaction_create(void); + +/** + * Add a container's pending state to the transaction. + */ +void transaction_add_container(struct sway_transaction *transaction, + struct sway_container *container); + +/** + * Submit a transaction to the client views for configuration. + */ +void transaction_commit(struct sway_transaction *transaction); + +/** + * Notify the transaction system that a view is ready for the new layout. + * + * When all views in the transaction are ready, the layout will be applied. + */ +void transaction_notify_view_ready(struct sway_view *view, uint32_t serial); + +/** + * Notify the transaction system that a view is ready for the new layout, but + * identifying the instruction by width and height rather than by serial. + * + * This is used by xwayland views, as they don't have serials. + */ +void transaction_notify_view_ready_by_size(struct sway_view *view, + int width, int height); + +/** + * Get the saved texture that should be rendered for a view. + * + * The addresses pointed at by the width and height pointers will be populated + * with the surface's dimensions, which may be different to the texture's + * dimensions if output scaling is used. + * + * This function should only be called if it is known that the view has + * instructions. + */ +struct wlr_texture *transaction_get_saved_texture(struct sway_view *view, + int *width, int *height); + +#endif diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 1f7792ba..0e440701 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -119,6 +119,17 @@ struct sway_container *seat_get_active_child(struct sway_seat *seat, struct sway_container *container); /** + * Return the immediate child of container which was most recently focused, with + * fallback to selecting the child in the parent's `current` (rendered) children + * list. + * + * This is useful for when a tabbed container and its children are destroyed but + * still being rendered, and we have to render an appropriate child. + */ +struct sway_container *seat_get_active_current_child(struct sway_seat *seat, + struct sway_container *container); + +/** * Iterate over the focus-inactive children of the container calling the * function on each. */ diff --git a/include/sway/output.h b/include/sway/output.h index 8180ce3d..19fc5e99 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -46,6 +46,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy, void output_damage_from_view(struct sway_output *output, struct sway_view *view); +void output_damage_box(struct sway_output *output, struct wlr_box *box); + void output_damage_whole_container(struct sway_output *output, struct sway_container *con); diff --git a/include/sway/server.h b/include/sway/server.h index b016aba8..1e1aa3cc 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -11,6 +11,7 @@ #include <wlr/types/wlr_xdg_shell.h> #include <wlr/render/wlr_renderer.h> // TODO WLR: make Xwayland optional +#include "list.h" #include "sway/xwayland.h" struct sway_server { @@ -40,6 +41,14 @@ struct sway_server { struct sway_xwayland xwayland; struct wl_listener xwayland_surface; struct wl_listener xwayland_ready; + + bool debug_txn_timings; + + list_t *transactions; + + // When a view is being destroyed and is waiting for a transaction to + // complete it will be stored here. + list_t *destroying_containers; }; struct sway_server server; diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index a14bc5dc..58235642 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,27 @@ 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. + * + * You must set the desired state of the container before calling + * arrange_windows, then don't change any state-tracked properties in the + * container until you've called transaction_commit. + */ +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..728daa84 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. + */ +void container_get_box(struct sway_container *container, struct wlr_box *box); + #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 91865232..b99044d3 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -29,8 +29,8 @@ 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_tiled)(struct sway_view *view, bool tiled); void (*set_fullscreen)(struct sway_view *view, bool fullscreen); @@ -69,6 +69,8 @@ struct sway_view { bool border_left; bool border_right; + bool destroying; + list_t *executed_criteria; // struct criteria * list_t *marks; // char * @@ -104,8 +106,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 { @@ -120,8 +120,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 { @@ -139,9 +137,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 { @@ -213,10 +208,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. */ @@ -242,6 +242,8 @@ 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); |