aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/tree/container.h
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-29 23:41:33 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-29 23:41:33 -0400
commitdc8c9fbeb664518c76066cc28ee29452c6c30128 (patch)
tree88c2de0d08e00b2a30cb20cdfadfa6e53f5c59b4 /include/sway/tree/container.h
parentMerge pull request #1653 from swaywm/revert-1647-refactor-tree (diff)
downloadsway-dc8c9fbeb664518c76066cc28ee29452c6c30128.tar.gz
sway-dc8c9fbeb664518c76066cc28ee29452c6c30128.tar.zst
sway-dc8c9fbeb664518c76066cc28ee29452c6c30128.zip
Revert "Merge pull request #1653 from swaywm/revert-1647-refactor-tree"
Diffstat (limited to 'include/sway/tree/container.h')
-rw-r--r--include/sway/tree/container.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
new file mode 100644
index 00000000..16df3ee7
--- /dev/null
+++ b/include/sway/tree/container.h
@@ -0,0 +1,137 @@
1#ifndef _SWAY_CONTAINER_H
2#define _SWAY_CONTAINER_H
3#include <stdint.h>
4#include <sys/types.h>
5#include <wlr/types/wlr_box.h>
6#include <wlr/types/wlr_surface.h>
7#include "list.h"
8
9extern struct sway_container root_container;
10
11struct sway_view;
12struct sway_seat;
13
14/**
15 * Different kinds of containers.
16 *
17 * This enum is in order. A container will never be inside of a container below
18 * it on this list.
19 */
20enum sway_container_type {
21 C_ROOT,
22 C_OUTPUT,
23 C_WORKSPACE,
24 C_CONTAINER,
25 C_VIEW,
26
27 C_TYPES,
28};
29
30enum sway_container_layout {
31 L_NONE,
32 L_HORIZ,
33 L_VERT,
34 L_STACKED,
35 L_TABBED,
36 L_FLOATING,
37
38 // Keep last
39 L_LAYOUTS,
40};
41
42enum sway_container_border {
43 B_NONE,
44 B_PIXEL,
45 B_NORMAL,
46};
47
48struct sway_root;
49struct sway_output;
50struct sway_view;
51
52struct sway_container {
53 union {
54 // TODO: Encapsulate state for other node types as well like C_CONTAINER
55 struct sway_root *sway_root;
56 struct sway_output *sway_output;
57 struct sway_view *sway_view;
58 };
59
60 /**
61 * A unique ID to identify this container. Primarily used in the
62 * get_tree JSON output.
63 */
64 size_t id;
65
66 char *name;
67
68 enum sway_container_type type;
69 enum sway_container_layout layout;
70 enum sway_container_layout prev_layout;
71 enum sway_container_layout workspace_layout;
72
73 // TODO convert to layout coordinates
74 double x, y;
75
76 // does not include borders or gaps.
77 double width, height;
78
79 list_t *children;
80
81 struct sway_container *parent;
82
83 list_t *marks; // list of char*
84
85 struct {
86 struct wl_signal destroy;
87 } events;
88};
89
90// TODO only one container create function and pass the type?
91struct sway_container *container_output_create(
92 struct sway_output *sway_output);
93
94struct sway_container *container_workspace_create(
95 struct sway_container *output, const char *name);
96
97struct sway_container *container_view_create(
98 struct sway_container *sibling, struct sway_view *sway_view);
99
100struct sway_container *container_output_destroy(struct sway_container *output);
101
102struct sway_container *container_view_destroy(struct sway_container *view);
103
104struct sway_container *container_set_layout(struct sway_container *container,
105 enum sway_container_layout layout);
106
107void container_descendents(struct sway_container *root,
108 enum sway_container_type type,
109 void (*func)(struct sway_container *item, void *data), void *data);
110
111/**
112 * Finds a container based on test criteria. Returns the first container that
113 * passes the test.
114 */
115struct sway_container *container_find(struct sway_container *container,
116 bool (*test)(struct sway_container *view, void *data), void *data);
117
118/**
119 * Finds a parent container with the given struct sway_containerype.
120 */
121struct sway_container *container_parent(struct sway_container *container,
122 enum sway_container_type type);
123
124/**
125 * Find a container at the given coordinates.
126 */
127struct sway_container *container_at(struct sway_container *parent,
128 double lx, double ly, struct wlr_surface **surface,
129 double *sx, double *sy);
130
131/**
132 * Apply the function for each child of the container breadth first.
133 */
134void container_for_each_descendent(struct sway_container *container,
135 void (*f)(struct sway_container *container, void *data), void *data);
136
137#endif