aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:27 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:50 -0500
commitaeda2e077f6184ecd26dc078c7b5db7f0dc54fd7 (patch)
tree0e84fc6ce2409ef5c60210efd18cb0981e3f9cf7 /sway/tree/container.c
parentMerge pull request #1472 from martinetd/wlroots (diff)
downloadsway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.gz
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.zst
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.zip
Add workspace to outputs
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 54bcf478..ac79356a 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -5,6 +5,8 @@
5#include "sway/container.h" 5#include "sway/container.h"
6#include "sway/layout.h" 6#include "sway/layout.h"
7#include "sway/output.h" 7#include "sway/output.h"
8#include "sway/workspace.h"
9#include "log.h"
8 10
9static swayc_t *new_swayc(enum swayc_types type) { 11static swayc_t *new_swayc(enum swayc_types type) {
10 // next id starts at 1 because 0 is assigned to root_container in layout.c 12 // next id starts at 1 because 0 is assigned to root_container in layout.c
@@ -27,8 +29,8 @@ static swayc_t *new_swayc(enum swayc_types type) {
27 29
28swayc_t *new_output(struct sway_output *sway_output) { 30swayc_t *new_output(struct sway_output *sway_output) {
29 struct wlr_box size; 31 struct wlr_box size;
30 wlr_output_effective_resolution(sway_output->wlr_output, 32 wlr_output_effective_resolution(
31 &size.width, &size.height); 33 sway_output->wlr_output, &size.width, &size.height);
32 const char *name = sway_output->wlr_output->name; 34 const char *name = sway_output->wlr_output->name;
33 35
34 swayc_t *output = new_swayc(C_OUTPUT); 36 swayc_t *output = new_swayc(C_OUTPUT);
@@ -39,7 +41,31 @@ swayc_t *new_output(struct sway_output *sway_output) {
39 41
40 add_child(&root_container, output); 42 add_child(&root_container, output);
41 43
42 // TODO: Create workspace 44 // Create workspace
43 45 char *ws_name = workspace_next_name(output->name);
46 sway_log(L_DEBUG, "Creating default workspace %s", ws_name);
47 new_workspace(output, ws_name);
48 free(ws_name);
44 return output; 49 return output;
45} 50}
51
52swayc_t *new_workspace(swayc_t *output, const char *name) {
53 if (!sway_assert(output, "new_workspace called with null output")) {
54 return NULL;
55 }
56 sway_log(L_DEBUG, "Added workspace %s for output %s", name, output->name);
57 swayc_t *workspace = new_swayc(C_WORKSPACE);
58
59 workspace->x = output->x;
60 workspace->y = output->y;
61 workspace->width = output->width;
62 workspace->height = output->height;
63 workspace->name = !name ? NULL : strdup(name);
64 workspace->prev_layout = L_NONE;
65 workspace->layout = default_layout(output);
66 workspace->workspace_layout = default_layout(output);
67
68 add_child(output, workspace);
69 sort_workspaces(output);
70 return workspace;
71}