aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-19 17:04:28 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-19 17:04:28 -0500
commitdb4fb1c85c132e001fb1ae18f03f7585def1ae19 (patch)
tree91da84c9476e6ec34c65f3f8923961fd893fa721 /sway/tree/container.c
parentMove everything to sway/old/ (diff)
downloadsway-db4fb1c85c132e001fb1ae18f03f7585def1ae19.tar.gz
sway-db4fb1c85c132e001fb1ae18f03f7585def1ae19.tar.zst
sway-db4fb1c85c132e001fb1ae18f03f7585def1ae19.zip
Add outputs to the tree
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
new file mode 100644
index 00000000..54bcf478
--- /dev/null
+++ b/sway/tree/container.c
@@ -0,0 +1,45 @@
1#define _POSIX_C_SOURCE 200809L
2#include <stdint.h>
3#include <stdlib.h>
4#include <string.h>
5#include "sway/container.h"
6#include "sway/layout.h"
7#include "sway/output.h"
8
9static swayc_t *new_swayc(enum swayc_types type) {
10 // next id starts at 1 because 0 is assigned to root_container in layout.c
11 static size_t next_id = 1;
12 swayc_t *c = calloc(1, sizeof(swayc_t));
13 if (!c) {
14 return NULL;
15 }
16 c->id = next_id++;
17 c->layout = L_NONE;
18 c->workspace_layout = L_NONE;
19 c->type = type;
20 c->nb_master = 1;
21 c->nb_slave_groups = 1;
22 if (type != C_VIEW) {
23 c->children = create_list();
24 }
25 return c;
26}
27
28swayc_t *new_output(struct sway_output *sway_output) {
29 struct wlr_box size;
30 wlr_output_effective_resolution(sway_output->wlr_output,
31 &size.width, &size.height);
32 const char *name = sway_output->wlr_output->name;
33
34 swayc_t *output = new_swayc(C_OUTPUT);
35 output->sway_output = sway_output;
36 output->name = name ? strdup(name) : NULL;
37 output->width = size.width;
38 output->height = size.width;
39
40 add_child(&root_container, output);
41
42 // TODO: Create workspace
43
44 return output;
45}