diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/config.h | 7 | ||||
-rw-r--r-- | include/sway/desktop/transaction.h | 4 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 4 | ||||
-rw-r--r-- | include/sway/input/seat.h | 35 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 4 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 4 | ||||
-rw-r--r-- | include/sway/output.h | 59 | ||||
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 9 | ||||
-rw-r--r-- | include/sway/tree/container.h | 148 | ||||
-rw-r--r-- | include/sway/tree/node.h | 74 | ||||
-rw-r--r-- | include/sway/tree/root.h | 28 | ||||
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | include/sway/tree/workspace.h | 105 |
14 files changed, 286 insertions, 201 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 6024f0f6..2fef0081 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -407,7 +407,9 @@ struct sway_config { struct output_config *output_config; struct seat_config *seat_config; struct sway_seat *seat; - struct sway_container *current_container; + struct sway_node *node; + struct sway_container *container; + struct sway_workspace *workspace; bool using_criteria; struct { int argc; @@ -486,8 +488,7 @@ struct output_config *new_output_config(const char *name); void merge_output_config(struct output_config *dst, struct output_config *src); -void apply_output_config(struct output_config *oc, - struct sway_container *output); +void apply_output_config(struct output_config *oc, struct sway_output *output); struct output_config *store_output_config(struct output_config *oc); diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index 7ac924e7..66e8c9a2 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h @@ -1,7 +1,6 @@ #ifndef _SWAY_TRANSACTION_H #define _SWAY_TRANSACTION_H -#include <wlr/render/wlr_texture.h> -#include "sway/tree/container.h" +#include <stdint.h> /** * Transactions enable us to perform atomic layout updates. @@ -21,6 +20,7 @@ */ struct sway_transaction_instruction; +struct sway_view; /** * Find all dirty containers, create and commit a transaction containing them, diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index aa2f6f19..bde3cf46 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -37,10 +37,10 @@ struct sway_input_manager { struct sway_input_manager *input_manager_create(struct sway_server *server); bool input_manager_has_focus(struct sway_input_manager *input, - struct sway_container *container); + struct sway_node *node); void input_manager_set_focus(struct sway_input_manager *input, - struct sway_container *container); + struct sway_node *node); void input_manager_configure_xcursor(struct sway_input_manager *input); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 5c404ecd..8a7e5450 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -13,9 +13,9 @@ struct sway_seat_device { struct wl_list link; // sway_seat::devices }; -struct sway_seat_container { +struct sway_seat_node { struct sway_seat *seat; - struct sway_container *container; + struct sway_node *node; struct wl_list link; // sway_seat::focus_stack @@ -76,7 +76,7 @@ struct sway_seat { uint32_t last_button_serial; struct wl_listener focus_destroy; - struct wl_listener new_container; + struct wl_listener new_node; struct wl_listener new_drag_icon; struct wl_list devices; // sway_seat_device::link @@ -100,10 +100,10 @@ void seat_remove_device(struct sway_seat *seat, void seat_configure_xcursor(struct sway_seat *seat); -void seat_set_focus(struct sway_seat *seat, struct sway_container *container); +void seat_set_focus(struct sway_seat *seat, struct sway_node *node); void seat_set_focus_warp(struct sway_seat *seat, - struct sway_container *container, bool warp, bool notify); + struct sway_node *node, bool warp, bool notify); void seat_set_focus_surface(struct sway_seat *seat, struct wlr_surface *surface, bool unfocus); @@ -114,7 +114,11 @@ void seat_set_focus_layer(struct sway_seat *seat, void seat_set_exclusive_client(struct sway_seat *seat, struct wl_client *client); -struct sway_container *seat_get_focus(struct sway_seat *seat); +struct sway_node *seat_get_focus(struct sway_seat *seat); + +struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat); + +struct sway_container *seat_get_focused_container(struct sway_seat *seat); /** * Return the last container to be focused for the seat (or the most recently @@ -125,32 +129,31 @@ struct sway_container *seat_get_focus(struct sway_seat *seat); * is destroyed, or focus moves to a container with children and we need to * descend into the next leaf in focus order. */ -struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, - struct sway_container *container); +struct sway_node *seat_get_focus_inactive(struct sway_seat *seat, + struct sway_node *node); struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat, - struct sway_container *container); + struct sway_workspace *workspace); /** * Descend into the focus stack to find the focus-inactive view. Useful for * container placement when they change position in the tree. */ struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, - struct sway_container *container); + struct sway_node *ancestor); /** * Return the immediate child of container which was most recently focused. */ -struct sway_container *seat_get_active_child(struct sway_seat *seat, - struct sway_container *container); +struct sway_node *seat_get_active_child(struct sway_seat *seat, + struct sway_node *parent); /** * Iterate over the focus-inactive children of the container calling the * function on each. */ -void seat_focus_inactive_children_for_each(struct sway_seat *seat, - struct sway_container *container, - void (*f)(struct sway_container *container, void *data), void *data); +void seat_for_each_node(struct sway_seat *seat, + void (*f)(struct sway_node *node, void *data), void *data); void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); @@ -173,7 +176,7 @@ void seat_begin_resize_tiling(struct sway_seat *seat, struct sway_container *con, uint32_t button, enum wlr_edges edge); struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, - struct sway_container *container); + struct sway_workspace *workspace); void seat_end_mouse_operation(struct sway_seat *seat); diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index eaaa2164..fef243e3 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h @@ -7,8 +7,8 @@ json_object *ipc_json_get_version(); json_object *ipc_json_describe_disabled_output(struct sway_output *o); -json_object *ipc_json_describe_container(struct sway_container *c); -json_object *ipc_json_describe_container_recursive(struct sway_container *c); +json_object *ipc_json_describe_node(struct sway_node *node); +json_object *ipc_json_describe_node_recursive(struct sway_node *node); json_object *ipc_json_describe_input(struct sway_input_device *device); json_object *ipc_json_describe_seat(struct sway_seat *seat); json_object *ipc_json_describe_bar_config(struct bar_config *bar); diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index 4b6d0e25..80180ec4 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h @@ -11,8 +11,8 @@ void ipc_init(struct sway_server *server); struct sockaddr_un *ipc_user_sockaddr(void); -void ipc_event_workspace(struct sway_container *old, - struct sway_container *new, const char *change); +void ipc_event_workspace(struct sway_workspace *old, + struct sway_workspace *new, const char *change); void ipc_event_window(struct sway_container *window, const char *change); void ipc_event_barconfig_update(struct bar_config *bar); void ipc_event_mode(const char *mode, bool pango); diff --git a/include/sway/output.h b/include/sway/output.h index 651fdfe7..540ed8a0 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -6,14 +6,20 @@ #include <wlr/types/wlr_box.h> #include <wlr/types/wlr_output.h> #include "config.h" +#include "sway/tree/node.h" #include "sway/tree/view.h" struct sway_server; struct sway_container; +struct sway_output_state { + list_t *workspaces; + struct sway_workspace *active_workspace; +}; + struct sway_output { + struct sway_node node; struct wlr_output *wlr_output; - struct sway_container *swayc; struct sway_server *server; struct wl_list layers[4]; // sway_layer_surface::link @@ -22,11 +28,15 @@ struct sway_output { struct timespec last_frame; struct wlr_output_damage *damage; + bool enabled; + list_t *workspaces; + + struct sway_output_state current; + struct wl_listener destroy; struct wl_listener mode; struct wl_listener transform; struct wl_listener scale; - struct wl_listener damage_destroy; struct wl_listener damage_frame; @@ -39,13 +49,19 @@ struct sway_output { } events; }; -struct sway_container *output_create(struct sway_output *sway_output); +struct sway_output *output_create(struct wlr_output *wlr_output); + +void output_destroy(struct sway_output *output); + +void output_begin_destroy(struct sway_output *output); -void output_destroy(struct sway_container *output); +struct sway_output *output_from_wlr_output(struct wlr_output *output); -void output_begin_destroy(struct sway_container *output); +struct sway_output *output_get_in_direction(struct sway_output *reference, + enum movement_direction direction); -struct sway_container *output_from_wlr_output(struct wlr_output *output); +void output_add_workspace(struct sway_output *output, + struct sway_workspace *workspace); typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct wlr_surface *surface, struct wlr_box *box, float rotation, @@ -64,15 +80,19 @@ 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); -struct sway_container *output_by_name(const char *name); +struct sway_output *output_by_name(const char *name); -void output_sort_workspaces(struct sway_container *output); +void output_sort_workspaces(struct sway_output *output); -void output_enable(struct sway_output *output); +struct output_config *output_find_config(struct sway_output *output); + +void output_enable(struct sway_output *output, struct output_config *oc); + +void output_disable(struct sway_output *output); bool output_has_opaque_overlay_layer_surface(struct sway_output *output); -struct sway_container *output_get_active_workspace(struct sway_output *output); +struct sway_workspace *output_get_active_workspace(struct sway_output *output); void output_render(struct sway_output *output, struct timespec *when, pixman_region32_t *damage); @@ -103,16 +123,23 @@ void output_drag_icons_for_each_surface(struct sway_output *output, struct wl_list *drag_icons, sway_surface_iterator_func_t iterator, void *user_data); -void output_for_each_workspace(struct sway_container *output, - void (*f)(struct sway_container *con, void *data), void *data); +void output_for_each_workspace(struct sway_output *output, + void (*f)(struct sway_workspace *ws, void *data), void *data); -void output_for_each_container(struct sway_container *output, +void output_for_each_container(struct sway_output *output, void (*f)(struct sway_container *con, void *data), void *data); -struct sway_container *output_find_workspace(struct sway_container *output, - bool (*test)(struct sway_container *con, void *data), void *data); +struct sway_workspace *output_find_workspace(struct sway_output *output, + bool (*test)(struct sway_workspace *ws, void *data), void *data); -struct sway_container *output_find_container(struct sway_container *output, +struct sway_container *output_find_container(struct sway_output *output, bool (*test)(struct sway_container *con, void *data), void *data); +void output_get_box(struct sway_output *output, struct wlr_box *box); + +enum sway_container_layout output_get_default_layout( + struct sway_output *output); + +void output_add_listeners(struct sway_output *output); + #endif diff --git a/include/sway/server.h b/include/sway/server.h index 1e20f2c8..07e0949a 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -56,7 +56,7 @@ struct sway_server { size_t txn_timeout_ms; list_t *transactions; - list_t *dirty_containers; + list_t *dirty_nodes; }; struct sway_server server; diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index f47e8db5..06a2279c 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h @@ -1,16 +1,19 @@ #ifndef _SWAY_ARRANGE_H #define _SWAY_ARRANGE_H +struct sway_output; +struct sway_workspace; struct sway_container; +struct sway_node; void arrange_container(struct sway_container *container); -void arrange_workspace(struct sway_container *workspace); +void arrange_workspace(struct sway_workspace *workspace); -void arrange_output(struct sway_container *output); +void arrange_output(struct sway_output *output); void arrange_root(void); -void arrange_windows(struct sway_container *container); +void arrange_node(struct sway_node *node); #endif diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e4071cfe..c51425c9 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -5,8 +5,7 @@ #include <wlr/types/wlr_box.h> #include <wlr/types/wlr_surface.h> #include "list.h" - -extern struct sway_container root_container; +#include "sway/tree/node.h" struct sway_view; struct sway_seat; @@ -17,23 +16,6 @@ struct sway_seat; #define TITLEBAR_H_PADDING 3 #define TITLEBAR_V_PADDING 4 -/** - * Different kinds of containers. - * - * This enum is in order. A container will never be inside of a container below - * it on this list. - */ -enum sway_container_type { - C_ROOT, - C_OUTPUT, - C_WORKSPACE, - C_CONTAINER, - C_VIEW, - - // Keep last - C_TYPES, -}; - enum sway_container_layout { L_NONE, L_HORIZ, @@ -57,18 +39,14 @@ enum movement_direction; enum wlr_direction; struct sway_container_state { - // Container/swayc properties + // Container properties enum sway_container_layout layout; - double swayc_x, swayc_y; - double swayc_width, swayc_height; + double con_x, con_y; + double con_width, con_height; bool is_fullscreen; - bool has_gaps; - double current_gaps; - double gaps_inner; - double gaps_outer; - + struct sway_workspace *workspace; struct sway_container *parent; list_t *children; @@ -86,35 +64,19 @@ struct sway_container_state { bool border_left; bool border_right; bool using_csd; - - // Workspace properties - struct sway_container *ws_fullscreen; - list_t *ws_floating; }; struct sway_container { - union { - // TODO: Encapsulate state for other node types as well like C_CONTAINER - struct sway_root *sway_root; - struct sway_output *sway_output; - struct sway_workspace *sway_workspace; - struct sway_view *sway_view; - }; - - /** - * A unique ID to identify this container. Primarily used in the - * get_tree JSON output. - */ - size_t id; + struct sway_node node; + struct sway_view *view; // 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 *title; // The view's title (unformatted) char *formatted_title; // The title displayed in the title bar - enum sway_container_type type; enum sway_container_layout layout; enum sway_container_layout prev_split_layout; @@ -132,14 +94,13 @@ struct sway_container { // The gaps currently applied to the container. double current_gaps; - bool has_gaps; double gaps_inner; double gaps_outer; - list_t *children; - - struct sway_container *parent; + struct sway_workspace *workspace; // NULL when hidden in the scratchpad + struct sway_container *parent; // NULL if container in root of workspace + list_t *children; // struct sway_container // Outputs currently being intersected list_t *outputs; // struct sway_output @@ -157,42 +118,17 @@ struct sway_container { struct wlr_texture *title_urgent; size_t title_height; - // The number of transactions which reference this container. - size_t ntxnrefs; - - // If this container is a view and is waiting for the client to respond to a - // configure then this will be populated, otherwise NULL. - struct sway_transaction_instruction *instruction; - - bool destroying; - - // If true, indicates that the container has pending state that differs from - // the current. - bool dirty; - struct { struct wl_signal destroy; } events; }; -struct sway_container *container_create(enum sway_container_type type); - -const char *container_type_to_str(enum sway_container_type type); - -/* - * 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 - * how they are attached to the tree. - */ -struct sway_container *container_view_create( - struct sway_container *sibling, struct sway_view *sway_view); +struct sway_container *container_create(struct sway_view *view); void container_destroy(struct sway_container *con); void container_begin_destroy(struct sway_container *con); -struct sway_container *container_close(struct sway_container *container); - /** * Search a container's descendants a container based on test criteria. Returns * the first container that passes the test. @@ -201,22 +137,16 @@ struct sway_container *container_find_child(struct sway_container *container, bool (*test)(struct sway_container *view, void *data), void *data); /** - * Finds a parent container with the given struct sway_containerype. - */ -struct sway_container *container_parent(struct sway_container *container, - enum sway_container_type type); - -/** * Find a container at the given coordinates. Returns the the surface and * surface-local coordinates of the given layout coordinates if the container * is a view and the view contains a surface at those coordinates. */ -struct sway_container *container_at(struct sway_container *workspace, +struct sway_container *container_at(struct sway_workspace *workspace, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy); struct sway_container *tiling_container_at( - struct sway_container *con, double lx, double ly, + struct sway_node *parent, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy); void container_for_each_child(struct sway_container *container, @@ -228,16 +158,11 @@ void container_for_each_child(struct sway_container *container, bool container_has_ancestor(struct sway_container *container, struct sway_container *ancestor); -int container_count_descendants_of_type(struct sway_container *con, - enum sway_container_type type); - -void container_create_notify(struct sway_container *container); - void container_update_textures_recursive(struct sway_container *con); void container_damage_whole(struct sway_container *container); -struct sway_container *container_reap_empty(struct sway_container *con); +void container_reap_empty(struct sway_container *con); struct sway_container *container_flatten(struct sway_container *container); @@ -248,11 +173,10 @@ void container_update_title_textures(struct sway_container *container); */ void container_calculate_title_height(struct sway_container *container); -/** - * Notify a container that a tree modification has changed in its children, - * so the container can update its tree representation. - */ -void container_notify_subtree_changed(struct sway_container *container); +size_t container_build_representation(enum sway_container_layout layout, + list_t *children, char *buffer); + +void container_update_representation(struct sway_container *container); /** * Return the height of a regular title bar. @@ -288,8 +212,7 @@ void container_floating_translate(struct sway_container *con, /** * Choose an output for the floating container's new position. */ -struct sway_container *container_floating_find_output( - struct sway_container *con); +struct sway_output *container_floating_find_output(struct sway_container *con); /** * Move a floating container to a new layout-local position. @@ -302,12 +225,6 @@ void container_floating_move_to(struct sway_container *con, */ void container_floating_move_to_center(struct sway_container *con); -/** - * Mark a container as dirty if it isn't already. Dirty containers will be - * included in the next transaction then unmarked as dirty. - */ -void container_set_dirty(struct sway_container *container); - bool container_has_urgent_child(struct sway_container *container); /** @@ -342,10 +259,18 @@ void container_remove_gaps(struct sway_container *container); void container_add_gaps(struct sway_container *container); +enum sway_container_layout container_parent_layout(struct sway_container *con); + +enum sway_container_layout container_current_parent_layout( + struct sway_container *con); + +list_t *container_get_siblings(const struct sway_container *container); + int container_sibling_index(const struct sway_container *child); -void container_handle_fullscreen_reparent(struct sway_container *con, - struct sway_container *old_parent); +list_t *container_get_current_siblings(struct sway_container *container); + +void container_handle_fullscreen_reparent(struct sway_container *con); void container_add_child(struct sway_container *parent, struct sway_container *child); @@ -353,19 +278,16 @@ void container_add_child(struct sway_container *parent, void container_insert_child(struct sway_container *parent, struct sway_container *child, int i); -struct sway_container *container_add_sibling(struct sway_container *parent, - struct sway_container *child); +void container_add_sibling(struct sway_container *parent, + struct sway_container *child, int offset); -struct sway_container *container_remove_child(struct sway_container *child); +void container_detach(struct sway_container *child); -struct sway_container *container_replace_child(struct sway_container *child, - struct sway_container *new_child); +void container_replace(struct sway_container *container, + struct sway_container *replacement); bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); -enum sway_container_layout container_get_default_layout( - struct sway_container *con); - struct sway_container *container_split(struct sway_container *child, enum sway_container_layout layout); diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h new file mode 100644 index 00000000..5b8c1909 --- /dev/null +++ b/include/sway/tree/node.h @@ -0,0 +1,74 @@ +#ifndef _SWAY_NODE_H +#define _SWAY_NODE_H +#include <stdbool.h> +#include "list.h" + +struct sway_root; +struct sway_output; +struct sway_workspace; +struct sway_container; +struct sway_transaction_instruction; +struct wlr_box; + +enum sway_node_type { + N_ROOT, + N_OUTPUT, + N_WORKSPACE, + N_CONTAINER, +}; + +struct sway_node { + enum sway_node_type type; + union { + struct sway_root *sway_root; + struct sway_output *sway_output; + struct sway_workspace *sway_workspace; + struct sway_container *sway_container; + }; + + /** + * A unique ID to identify this node. + * Primarily used in the get_tree JSON output. + */ + size_t id; + + struct sway_transaction_instruction *instruction; + size_t ntxnrefs; + bool destroying; + + // If true, indicates that the container has pending state that differs from + // the current. + bool dirty; + + struct { + struct wl_signal destroy; + } events; +}; + +void node_init(struct sway_node *node, enum sway_node_type type, void *thing); + +const char *node_type_to_str(enum sway_node_type type); + +/** + * Mark a node as dirty if it isn't already. Dirty nodes will be included in the + * next transaction then unmarked as dirty. + */ +void node_set_dirty(struct sway_node *node); + +bool node_is_view(struct sway_node *node); + +char *node_get_name(struct sway_node *node); + +void node_get_box(struct sway_node *node, struct wlr_box *box); + +struct sway_output *node_get_output(struct sway_node *node); + +enum sway_container_layout node_get_layout(struct sway_node *node); + +struct sway_node *node_get_parent(struct sway_node *node); + +list_t *node_get_children(struct sway_node *node); + +bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); + +#endif diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index ec6516c9..a2d464f9 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h @@ -5,12 +5,14 @@ #include <wlr/types/wlr_output_layout.h> #include <wlr/render/wlr_texture.h> #include "sway/tree/container.h" +#include "sway/tree/node.h" #include "config.h" #include "list.h" -extern struct sway_container root_container; +extern struct sway_root *root; struct sway_root { + struct sway_node node; struct wlr_output_layout *output_layout; struct wl_listener output_layout_change; @@ -24,17 +26,21 @@ struct sway_root { // Includes disabled outputs struct wl_list all_outputs; // sway_output::link + double x, y; + double width, height; + + list_t *outputs; // struct sway_output list_t *scratchpad; // struct sway_container list_t *saved_workspaces; // For when there's no connected outputs struct { - struct wl_signal new_container; + struct wl_signal new_node; } events; }; -void root_create(void); +struct sway_root *root_create(void); -void root_destroy(void); +void root_destroy(struct sway_root *root); /** * Move a container to the scratchpad. @@ -56,23 +62,25 @@ void root_scratchpad_show(struct sway_container *con); */ void root_scratchpad_hide(struct sway_container *con); -struct sway_container *root_workspace_for_pid(pid_t pid); +struct sway_workspace *root_workspace_for_pid(pid_t pid); void root_record_workspace_pid(pid_t pid); -void root_for_each_workspace(void (*f)(struct sway_container *con, void *data), +void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data), void *data); void root_for_each_container(void (*f)(struct sway_container *con, void *data), void *data); -struct sway_container *root_find_output( - bool (*test)(struct sway_container *con, void *data), void *data); +struct sway_output *root_find_output( + bool (*test)(struct sway_output *output, void *data), void *data); -struct sway_container *root_find_workspace( - bool (*test)(struct sway_container *con, void *data), void *data); +struct sway_workspace *root_find_workspace( + bool (*test)(struct sway_workspace *ws, void *data), void *data); struct sway_container *root_find_container( bool (*test)(struct sway_container *con, void *data), void *data); +void root_get_box(struct sway_root *root, struct wlr_box *box); + #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 30d3e742..439dc1bf 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -58,7 +58,7 @@ struct sway_view { enum sway_view_type type; const struct sway_view_impl *impl; - struct sway_container *swayc; // NULL for unmapped views + struct sway_container *container; // NULL if unmapped and transactions finished struct wlr_surface *surface; // NULL for unmapped views // Geometry of the view itself (excludes borders) in layout coordinates @@ -254,7 +254,7 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, int height); /** - * Configure the view's position and size based on the swayc's position and + * Configure the view's position and size based on the container's position and * size, taking borders into consideration. */ void view_autoconfigure(struct sway_view *view); diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 04325919..af9a071a 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -3,66 +3,98 @@ #include <stdbool.h> #include "sway/tree/container.h" +#include "sway/tree/node.h" struct sway_view; +struct sway_workspace_state { + struct sway_container *fullscreen; + double x, y; + int width, height; + enum sway_container_layout layout; + struct sway_output *output; + list_t *floating; + list_t *tiling; + + struct sway_container *focused_inactive_child; + bool focused; +}; + struct sway_workspace { - struct sway_container *swayc; + struct sway_node node; struct sway_container *fullscreen; - list_t *floating; // struct sway_container + + char *name; + char *representation; + + double x, y; + int width, height; + enum sway_container_layout layout; + enum sway_container_layout prev_split_layout; + + double current_gaps; + bool has_gaps; + double gaps_inner; + double gaps_outer; + + struct sway_output *output; // NULL if no outputs are connected + list_t *floating; // struct sway_container + list_t *tiling; // struct sway_container list_t *output_priority; bool urgent; + + struct sway_workspace_state current; }; extern char *prev_workspace_name; -struct sway_container *workspace_get_initial_output(const char *name); +struct sway_output *workspace_get_initial_output(const char *name); -struct sway_container *workspace_create(struct sway_container *output, +struct sway_workspace *workspace_create(struct sway_output *output, const char *name); -void workspace_destroy(struct sway_container *workspace); +void workspace_destroy(struct sway_workspace *workspace); -void workspace_begin_destroy(struct sway_container *workspace); +void workspace_begin_destroy(struct sway_workspace *workspace); -void workspace_consider_destroy(struct sway_container *ws); +void workspace_consider_destroy(struct sway_workspace *ws); char *workspace_next_name(const char *output_name); -bool workspace_switch(struct sway_container *workspace, +bool workspace_switch(struct sway_workspace *workspace, bool no_auto_back_and_forth); -struct sway_container *workspace_by_number(const char* name); +struct sway_workspace *workspace_by_number(const char* name); -struct sway_container *workspace_by_name(const char*); +struct sway_workspace *workspace_by_name(const char*); -struct sway_container *workspace_output_next(struct sway_container *current); +struct sway_workspace *workspace_output_next(struct sway_workspace *current); -struct sway_container *workspace_next(struct sway_container *current); +struct sway_workspace *workspace_next(struct sway_workspace *current); -struct sway_container *workspace_output_prev(struct sway_container *current); +struct sway_workspace *workspace_output_prev(struct sway_workspace *current); -struct sway_container *workspace_prev(struct sway_container *current); +struct sway_workspace *workspace_prev(struct sway_workspace *current); -bool workspace_is_visible(struct sway_container *ws); +bool workspace_is_visible(struct sway_workspace *ws); -bool workspace_is_empty(struct sway_container *ws); +bool workspace_is_empty(struct sway_workspace *ws); -void workspace_output_raise_priority(struct sway_container *workspace, - struct sway_container *old_output, struct sway_container *new_output); +void workspace_output_raise_priority(struct sway_workspace *workspace, + struct sway_output *old_output, struct sway_output *new_output); -void workspace_output_add_priority(struct sway_container *workspace, - struct sway_container *output); +void workspace_output_add_priority(struct sway_workspace *workspace, + struct sway_output *output); -struct sway_container *workspace_output_get_highest_available( - struct sway_container *ws, struct sway_container *exclude); +struct sway_output *workspace_output_get_highest_available( + struct sway_workspace *ws, struct sway_output *exclude); -void workspace_detect_urgent(struct sway_container *workspace); +void workspace_detect_urgent(struct sway_workspace *workspace); -void workspace_for_each_container(struct sway_container *ws, +void workspace_for_each_container(struct sway_workspace *ws, void (*f)(struct sway_container *con, void *data), void *data); -struct sway_container *workspace_find_container(struct sway_container *ws, +struct sway_container *workspace_find_container(struct sway_workspace *ws, bool (*test)(struct sway_container *con, void *data), void *data); /** @@ -70,13 +102,28 @@ struct sway_container *workspace_find_container(struct sway_container *ws, * The new container will be the only direct tiling child of the workspace. * The new container is returned. */ -struct sway_container *workspace_wrap_children(struct sway_container *ws); +struct sway_container *workspace_wrap_children(struct sway_workspace *ws); -void workspace_add_floating(struct sway_container *workspace, +void workspace_detach(struct sway_workspace *workspace); + +void workspace_add_tiling(struct sway_workspace *workspace, + struct sway_container *con); + +void workspace_add_floating(struct sway_workspace *workspace, struct sway_container *con); -void workspace_remove_gaps(struct sway_container *ws); +void workspace_insert_tiling(struct sway_workspace *workspace, + struct sway_container *con, int index); + +void workspace_remove_gaps(struct sway_workspace *ws); + +void workspace_add_gaps(struct sway_workspace *ws); + +struct sway_container *workspace_split(struct sway_workspace *workspace, + enum sway_container_layout layout); + +void workspace_update_representation(struct sway_workspace *ws); -void workspace_add_gaps(struct sway_container *ws); +void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box); #endif |