diff options
Diffstat (limited to 'include/sway/tree')
-rw-r--r-- | include/sway/tree/container.h | 66 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 15 | ||||
-rw-r--r-- | include/sway/tree/view.h | 59 | ||||
-rw-r--r-- | include/sway/tree/workspace.h | 6 |
4 files changed, 116 insertions, 30 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index ca7a3288..c3942e9e 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -60,6 +60,8 @@ struct sway_container_state { double swayc_x, swayc_y; double swayc_width, swayc_height; + bool is_fullscreen; + bool has_gaps; double current_gaps; double gaps_inner; @@ -74,7 +76,6 @@ struct sway_container_state { // View properties double view_x, view_y; double view_width, view_height; - bool is_fullscreen; enum sway_container_border border; int border_thickness; @@ -84,7 +85,7 @@ struct sway_container_state { bool border_right; // Workspace properties - struct sway_view *ws_fullscreen; + struct sway_container *ws_fullscreen; struct sway_container *ws_floating; }; @@ -124,6 +125,8 @@ struct sway_container { double saved_x, saved_y; double saved_width, saved_height; + bool is_fullscreen; + // The gaps currently applied to the container. double current_gaps; @@ -135,6 +138,11 @@ struct sway_container { struct sway_container *parent; + // Indicates that the container is a scratchpad container. + // Both hidden and visible scratchpad containers have scratchpad=true. + // Hidden scratchpad containers have a NULL parent. + bool scratchpad; + float alpha; struct wlr_texture *title_focused; @@ -222,16 +230,13 @@ struct sway_container *container_parent(struct sway_container *container, * 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 *container, - double ox, double oy, struct wlr_surface **surface, +struct sway_container *container_at(struct sway_container *workspace, + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy); -/** - * Same as container_at, but only checks floating views and expects coordinates - * to be layout coordinates, as that's what floating views use. - */ -struct sway_container *floating_container_at(double lx, double ly, - struct wlr_surface **surface, double *sx, double *sy); +struct sway_container *container_at_view(struct sway_container *view, + double lx, double ly, struct wlr_surface **surface, + double *sx, double *sy); /** * Apply the function for each descendant of the container breadth first. @@ -262,6 +267,8 @@ int container_count_descendants_of_type(struct sway_container *con, 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); bool container_reap_empty(struct sway_container *con); @@ -289,6 +296,11 @@ void container_notify_subtree_changed(struct sway_container *container); */ size_t container_titlebar_height(void); +/** + * Resize and center the container in its workspace. + */ +void container_init_floating(struct sway_container *container); + void container_set_floating(struct sway_container *container, bool enable); void container_set_geometry_from_floating_view(struct sway_container *con); @@ -305,6 +317,12 @@ bool container_is_floating(struct sway_container *container); void container_get_box(struct sway_container *container, struct wlr_box *box); /** + * Move a floating container by the specified amount. + */ +void container_floating_translate(struct sway_container *con, + double x_amount, double y_amount); + +/** * Move a floating container to a new layout-local position. */ void container_floating_move_to(struct sway_container *con, @@ -318,4 +336,32 @@ void container_set_dirty(struct sway_container *container); bool container_has_urgent_child(struct sway_container *container); +/** + * If the container is involved in a drag or resize operation via a mouse, this + * ends the operation. + */ +void container_end_mouse_operation(struct sway_container *container); + +void container_set_fullscreen(struct sway_container *container, bool enable); + +/** + * Return true if the container is floating, or a child of a floating split + * container. + */ +bool container_is_floating_or_child(struct sway_container *container); + +/** + * Return true if the container is fullscreen, or a child of a fullscreen split + * container. + */ +bool container_is_fullscreen_or_child(struct sway_container *container); + +/** + * Wrap the children of parent in a new container. The new container will be the + * only child of parent. + * + * The new container is returned. + */ +struct sway_container *container_wrap_children(struct sway_container *parent); + #endif diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index ba265623..a4c31bf6 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -3,6 +3,7 @@ #include <wlr/types/wlr_output_layout.h> #include <wlr/render/wlr_texture.h> #include "sway/tree/container.h" +#include "config.h" enum movement_direction { MOVE_LEFT, @@ -14,10 +15,11 @@ enum movement_direction { }; enum resize_edge { - RESIZE_EDGE_LEFT, - RESIZE_EDGE_RIGHT, - RESIZE_EDGE_TOP, - RESIZE_EDGE_BOTTOM, + RESIZE_EDGE_NONE = 0, + RESIZE_EDGE_LEFT = 1, + RESIZE_EDGE_RIGHT = 2, + RESIZE_EDGE_TOP = 4, + RESIZE_EDGE_BOTTOM = 8, }; struct sway_container; @@ -26,14 +28,17 @@ struct sway_root { struct wlr_output_layout *output_layout; struct wl_listener output_layout_change; - +#ifdef HAVE_XWAYLAND struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link +#endif struct wl_list drag_icons; // sway_drag_icon::link struct wlr_texture *debug_tree; struct wl_list outputs; // sway_output::link + list_t *scratchpad; // struct sway_container + struct { struct wl_signal new_container; } events; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 068d92c6..37fd02bc 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -3,7 +3,10 @@ #include <wayland-server.h> #include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_xdg_shell_v6.h> +#include "config.h" +#ifdef HAVE_XWAYLAND #include <wlr/xwayland.h> +#endif #include "sway/input/input-manager.h" #include "sway/input/seat.h" @@ -12,7 +15,9 @@ struct sway_container; enum sway_view_type { SWAY_VIEW_XDG_SHELL_V6, SWAY_VIEW_XDG_SHELL, +#ifdef HAVE_XWAYLAND SWAY_VIEW_XWAYLAND, +#endif }; enum sway_view_prop { @@ -22,10 +27,14 @@ enum sway_view_prop { VIEW_PROP_INSTANCE, VIEW_PROP_WINDOW_TYPE, VIEW_PROP_WINDOW_ROLE, +#ifdef HAVE_XWAYLAND VIEW_PROP_X11_WINDOW_ID, +#endif }; struct sway_view_impl { + void (*get_constraints)(struct sway_view *view, double *min_width, + double *max_width, double *min_height, double *max_height); 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); @@ -38,7 +47,10 @@ struct sway_view_impl { bool (*has_client_side_decorations)(struct sway_view *view); void (*for_each_surface)(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); + void (*for_each_popup)(struct sway_view *view, + wlr_surface_iterator_func_t iterator, void *user_data); void (*close)(struct sway_view *view); + void (*close_popups)(struct sway_view *view); void (*destroy)(struct sway_view *view); }; @@ -60,8 +72,6 @@ struct sway_view { // Used when changing a view from tiled to floating. int natural_width, natural_height; - bool is_fullscreen; - char *title_format; enum sway_container_border border; int border_thickness; @@ -75,6 +85,9 @@ struct sway_view { bool allow_request_urgent; struct wl_event_source *urgent_timer; + struct wlr_buffer *saved_buffer; + int saved_buffer_width, saved_buffer_height; + bool destroying; list_t *executed_criteria; // struct criteria * @@ -88,7 +101,9 @@ struct sway_view { union { struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; struct wlr_xdg_surface *wlr_xdg_surface; +#ifdef HAVE_XWAYLAND struct wlr_xwayland_surface *wlr_xwayland_surface; +#endif struct wlr_wl_shell_surface *wlr_wl_shell_surface; }; @@ -108,6 +123,8 @@ struct sway_xdg_shell_v6_view { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; + struct wl_listener set_title; + struct wl_listener set_app_id; struct wl_listener new_popup; struct wl_listener map; struct wl_listener unmap; @@ -122,12 +139,14 @@ struct sway_xdg_shell_view { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_fullscreen; + struct wl_listener set_title; + struct wl_listener set_app_id; struct wl_listener new_popup; struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; }; - +#ifdef HAVE_XWAYLAND struct sway_xwayland_view { struct sway_view view; @@ -159,7 +178,7 @@ struct sway_xwayland_unmanaged { struct wl_listener unmap; struct wl_listener destroy; }; - +#endif struct sway_view_child; struct sway_view_child_impl { @@ -215,15 +234,13 @@ uint32_t view_get_window_type(struct sway_view *view); const char *view_get_shell(struct sway_view *view); +void view_get_constraints(struct sway_view *view, double *min_width, + double *max_width, double *min_height, double *max_height); + 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. */ @@ -233,17 +250,24 @@ void view_set_activated(struct sway_view *view, bool activated); void view_set_tiled(struct sway_view *view, bool tiled); -void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); - -void view_set_fullscreen(struct sway_view *view, bool fullscreen); - void view_close(struct sway_view *view); +void view_close_popups(struct sway_view *view); + void view_damage_from(struct sway_view *view); +/** + * Iterate all surfaces of a view (toplevels + popups). + */ void view_for_each_surface(struct sway_view *view, wlr_surface_iterator_func_t iterator, void *user_data); +/** + * Iterate all popups recursively. + */ +void view_for_each_popup(struct sway_view *view, + wlr_surface_iterator_func_t iterator, void *user_data); + // view implementation void view_init(struct sway_view *view, enum sway_view_type type, @@ -272,9 +296,10 @@ struct sway_view *view_from_wlr_xdg_surface( struct wlr_xdg_surface *xdg_surface); struct sway_view *view_from_wlr_xdg_surface_v6( struct wlr_xdg_surface_v6 *xdg_surface_v6); +#ifdef HAVE_XWAYLAND struct sway_view *view_from_wlr_xwayland_surface( struct wlr_xwayland_surface *xsurface); - +#endif struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); /** @@ -303,6 +328,8 @@ void view_clear_marks(struct sway_view *view); bool view_has_mark(struct sway_view *view, char *mark); +void view_add_mark(struct sway_view *view, char *mark); + void view_update_marks_textures(struct sway_view *view); /** @@ -315,4 +342,8 @@ void view_set_urgent(struct sway_view *view, bool enable); bool view_is_urgent(struct sway_view *view); +void view_remove_saved_buffer(struct sway_view *view); + +void view_save_buffer(struct sway_view *view); + #endif diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index bc95317a..5ae0ae3a 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -7,7 +7,7 @@ struct sway_view; struct sway_workspace { struct sway_container *swayc; - struct sway_view *fullscreen; + struct sway_container *fullscreen; struct sway_container *floating; list_t *output_priority; bool urgent; @@ -44,6 +44,10 @@ void workspace_output_add_priority(struct sway_container *workspace, struct sway_container *workspace_output_get_highest_available( struct sway_container *ws, struct sway_container *exclude); +struct sway_container *workspace_for_pid(pid_t pid); + +void workspace_record_pid(pid_t pid); + void workspace_detect_urgent(struct sway_container *workspace); #endif |