aboutsummaryrefslogtreecommitdiff
path: root/include/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/tree')
-rw-r--r--include/sway/tree/container.h76
-rw-r--r--include/sway/tree/layout.h26
-rw-r--r--include/sway/tree/view.h59
3 files changed, 119 insertions, 42 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 6aa66da0..464f80c4 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -70,9 +70,10 @@ struct sway_container {
enum sway_container_layout prev_layout;
enum sway_container_layout workspace_layout;
- // TODO convert to layout coordinates
+ // For C_ROOT, this has no meaning
+ // For C_OUTPUT, this is the output position in layout coordinates
+ // For other types, this is the position in output-local coordinates
double x, y;
-
// does not include borders or gaps.
double width, height;
@@ -84,38 +85,67 @@ struct sway_container {
struct {
struct wl_signal destroy;
+ // Raised after the tree updates, but before arrange_windows
+ // Passed the previous parent
+ struct wl_signal reparent;
} events;
};
+// TODO make private and use the container-specific create functions
+struct sway_container *container_create(enum sway_container_type type);
+
+const char *container_type_to_str(enum sway_container_type type);
+
// TODO only one container create function and pass the type?
struct sway_container *container_output_create(
struct sway_output *sway_output);
-struct sway_container *container_workspace_create(
- struct sway_container *output, const char *name);
+/**
+ * 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();
-struct sway_container *container_view_create(
- struct sway_container *sibling, struct sway_view *sway_view);
+/**
+ * Create a new output. Outputs are children of the root container and have no
+ * order in the tree structure.
+ */
+struct sway_container *container_output_create(struct sway_output *sway_output);
-struct sway_container *container_output_destroy(struct sway_container *output);
+/**
+ * Create a new workspace container. Workspaces are children of an output
+ * container and are ordered alphabetically by name.
+ */
+struct sway_container *container_workspace_create(struct sway_container *output, const char *name);
-struct sway_container *container_workspace_destroy(
- struct sway_container *workspace);
+/*
+ * 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.
+ */
+// TODO view containers should be created in a detached state.
+struct sway_container *container_view_create(
+ struct sway_container *sibling, struct sway_view *sway_view);
-struct sway_container *container_view_destroy(struct sway_container *view);
+// TODO don't return the parent on destroy
+struct sway_container *container_destroy(struct sway_container *container);
-struct sway_container *container_destroy(struct sway_container *cont);
+struct sway_container *container_workspace_destroy(struct sway_container *container);
+struct sway_container *container_output_destroy(struct sway_container *container);
+struct sway_container *container_view_destroy(struct sway_container *container);
+// TODO move to layout.c
struct sway_container *container_set_layout(struct sway_container *container,
enum sway_container_layout layout);
+// TODO rename to container_descendants_for_each()
void container_descendants(struct sway_container *root,
enum sway_container_type type,
void (*func)(struct sway_container *item, void *data), void *data);
/**
- * Finds a container based on test criteria. Returns the first container that
- * passes the test.
+ * Search a container's descendants a container based on test criteria. Returns
+ * the first container that passes the test.
*/
struct sway_container *container_find(struct sway_container *container,
bool (*test)(struct sway_container *view, void *data), void *data);
@@ -123,18 +153,21 @@ struct sway_container *container_find(struct sway_container *container,
/**
* Finds a parent container with the given struct sway_containerype.
*/
+// TODO rename to container_parent_of_type()
struct sway_container *container_parent(struct sway_container *container,
enum sway_container_type type);
/**
- * Find a container at the given coordinates.
+ * 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 *parent,
+struct sway_container *container_at(struct sway_container *container,
double lx, double ly, struct wlr_surface **surface,
double *sx, double *sy);
/**
- * Apply the function for each child of the container breadth first.
+ * Apply the function for each descendant of the container breadth first.
*/
void container_for_each_descendant_bfs(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
@@ -145,7 +178,16 @@ void container_for_each_descendant_bfs(struct sway_container *container,
void container_for_each_descendant_dfs(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
-bool container_has_anscestor(struct sway_container *descendant,
+/**
+ * Returns true if the given container is an ancestor of this container.
+ */
+bool container_has_anscestor(struct sway_container *container,
struct sway_container *anscestor);
+/**
+ * Returns true if the given container is a child descendant of this container.
+ */
+bool container_has_child(struct sway_container *con,
+ struct sway_container *child);
+
#endif
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
index 0a904c4b..8badb244 100644
--- a/include/sway/tree/layout.h
+++ b/include/sway/tree/layout.h
@@ -11,9 +11,6 @@ enum movement_direction {
MOVE_DOWN,
MOVE_PARENT,
MOVE_CHILD,
- MOVE_NEXT,
- MOVE_PREV,
- MOVE_FIRST
};
struct sway_container;
@@ -23,7 +20,7 @@ struct sway_root {
struct wl_listener output_layout_change;
- struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
+ struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
struct {
struct wl_signal new_container;
@@ -32,26 +29,43 @@ struct sway_root {
void layout_init(void);
-void container_add_child(struct sway_container *parent, struct sway_container *child);
+// TODO move to tree.h
+void container_add_child(struct sway_container *parent,
+ struct sway_container *child);
+// TODO move to tree.h
struct sway_container *container_add_sibling(struct sway_container *parent,
struct sway_container *child);
+// TODO move to tree.h
struct sway_container *container_remove_child(struct sway_container *child);
+// TODO PRIVATE in tree.h
struct sway_container *container_reap_empty(struct sway_container *container);
+// TODO move to tree.h
void container_move_to(struct sway_container* container,
struct sway_container* destination);
-enum sway_container_layout container_get_default_layout(struct sway_container *output);
+void container_move(struct sway_container *container,
+ enum movement_direction dir, int move_amt);
+
+// TODO move to output.c
+enum sway_container_layout container_get_default_layout(
+ struct sway_container *output);
+// TODO move to output.c
void container_sort_workspaces(struct sway_container *output);
void arrange_windows(struct sway_container *container,
double width, double height);
+// TODO move to container.h
struct sway_container *container_get_in_direction(struct sway_container
*container, struct sway_seat *seat, enum movement_direction dir);
+// TODO move to tree.h
+struct sway_container *container_split(struct sway_container *child,
+ enum sway_container_layout layout);
+
#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 3965d2b7..4b84205e 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -4,6 +4,8 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/xwayland.h>
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
struct sway_container;
struct sway_view;
@@ -37,6 +39,13 @@ struct sway_xwayland_surface {
int pending_width, pending_height;
};
+struct sway_xwayland_unmanaged {
+ struct wlr_xwayland_surface *wlr_xwayland_surface;
+ struct wl_list link;
+
+ struct wl_listener destroy;
+};
+
struct sway_wl_shell_surface {
struct sway_view *view;
@@ -64,10 +73,21 @@ enum sway_view_prop {
VIEW_PROP_INSTANCE,
};
+struct sway_view_impl {
+ const char *(*get_prop)(struct sway_view *view,
+ enum sway_view_prop prop);
+ void (*configure)(struct sway_view *view, double ox, double oy, int width,
+ int height);
+ void (*set_activated)(struct sway_view *view, bool activated);
+ void (*close)(struct sway_view *view);
+};
+
struct sway_view {
enum sway_view_type type;
- struct sway_container *swayc;
- struct wlr_surface *surface;
+ const struct sway_view_impl *impl;
+
+ struct sway_container *swayc; // NULL for unmanaged views
+ struct wlr_surface *surface; // NULL for unmapped views
int width, height;
union {
@@ -82,21 +102,15 @@ struct sway_view {
struct sway_wl_shell_surface *sway_wl_shell_surface;
};
- struct {
- const char *(*get_prop)(struct sway_view *view,
- enum sway_view_prop prop);
- void (*set_size)(struct sway_view *view,
- int width, int height);
- void (*set_position)(struct sway_view *view,
- double ox, double oy);
- void (*set_activated)(struct sway_view *view, bool activated);
- void (*close)(struct sway_view *view);
- } iface;
-
// only used for unmanaged views (shell specific)
- struct wl_list unmanaged_view_link; // sway_root::unmanaged views
+ struct wl_list unmanaged_view_link; // sway_root::unmanaged_views
};
+struct sway_view *view_create(enum sway_view_type type,
+ const struct sway_view_impl *impl);
+
+void view_destroy(struct sway_view *view);
+
const char *view_get_title(struct sway_view *view);
const char *view_get_app_id(struct sway_view *view);
@@ -105,18 +119,25 @@ const char *view_get_class(struct sway_view *view);
const char *view_get_instance(struct sway_view *view);
-void view_set_size(struct sway_view *view, int width, int height);
-
-void view_set_position(struct sway_view *view, double ox, double oy);
+void view_configure(struct sway_view *view, double ox, double oy, int width,
+ int height);
void view_set_activated(struct sway_view *view, bool activated);
void view_close(struct sway_view *view);
-void view_update_outputs(struct sway_view *view, const struct wlr_box *before);
-
void view_damage_whole(struct sway_view *view);
void view_damage_from(struct sway_view *view);
+// view implementation
+
+void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
+
+void view_unmap(struct sway_view *view);
+
+void view_update_position(struct sway_view *view, double ox, double oy);
+
+void view_update_size(struct sway_view *view, int width, int height);
+
#endif