aboutsummaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/sway/container.c b/sway/container.c
index 3534721d..67132a48 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -39,17 +39,11 @@ static void free_swayc(swayc_t *c) {
39} 39}
40 40
41/* New containers */ 41/* New containers */
42static void add_output_widths(swayc_t *container, void *_width) {
43 int *width = _width;
44 if (container->type == C_OUTPUT) {
45 *width += container->width;
46 }
47}
48 42
49swayc_t *new_output(wlc_handle handle) { 43swayc_t *new_output(wlc_handle handle) {
50 const struct wlc_size* size = wlc_output_get_resolution(handle); 44 const struct wlc_size* size = wlc_output_get_resolution(handle);
51 const char *name = wlc_output_get_name(handle); 45 const char *name = wlc_output_get_name(handle);
52 sway_log(L_DEBUG, "Added output %u %s", (unsigned int)handle, name); 46 sway_log(L_DEBUG, "Added output %lu:%s", handle, name);
53 47
54 swayc_t *output = new_swayc(C_OUTPUT); 48 swayc_t *output = new_swayc(C_OUTPUT);
55 output->width = size->w; 49 output->width = size->w;
@@ -59,9 +53,12 @@ swayc_t *new_output(wlc_handle handle) {
59 53
60 add_child(&root_container, output); 54 add_child(&root_container, output);
61 55
62 //TODO something with this 56//TODO still dont know why this is here?
63 int total_width = 0; 57// int total_width = 0;
64 container_map(&root_container, add_output_widths, &total_width); 58// int i;
59// for (i = 0; i < root_container.children->length; ++i) {
60// total_width += ((swayc_t*)root_container.children->items[i])->width;
61// }
65 62
66 //Create workspace 63 //Create workspace
67 char *ws_name = NULL; 64 char *ws_name = NULL;
@@ -79,7 +76,10 @@ swayc_t *new_output(wlc_handle handle) {
79 if (!ws_name) { 76 if (!ws_name) {
80 ws_name = workspace_next_name(); 77 ws_name = workspace_next_name();
81 } 78 }
82 new_workspace(output, ws_name); 79 //create and initilize default workspace
80 swayc_t *ws = new_workspace(output, ws_name);
81 ws->is_focused = true;
82
83 free(ws_name); 83 free(ws_name);
84 84
85 return output; 85 return output;
@@ -139,14 +139,15 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
139} 139}
140 140
141swayc_t *new_view(swayc_t *sibling, wlc_handle handle) { 141swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
142 const char *title = wlc_view_get_title(handle); 142 const char *title = wlc_view_get_title(handle);
143 swayc_t *view = new_swayc(C_VIEW); 143 swayc_t *view = new_swayc(C_VIEW);
144 sway_log(L_DEBUG, "Adding new view %u:%s to container %p %d", 144 sway_log(L_DEBUG, "Adding new view %lu:%s to container %p %d",
145 (unsigned int)handle, title, sibling, sibling?sibling->type:0); 145 handle, title, sibling, sibling ? sibling->type : 0);
146 //Setup values 146 //Setup values
147 view->handle = handle; 147 view->handle = handle;
148 view->name = title ? strdup(title) : NULL; 148 view->name = title ? strdup(title) : NULL;
149 view->visible = true; 149 view->visible = true;
150 view->is_focused = true;
150 151
151 view->desired_width = -1; 152 view->desired_width = -1;
152 view->desired_height = -1; 153 view->desired_height = -1;
@@ -168,8 +169,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
168swayc_t *new_floating_view(wlc_handle handle) { 169swayc_t *new_floating_view(wlc_handle handle) {
169 const char *title = wlc_view_get_title(handle); 170 const char *title = wlc_view_get_title(handle);
170 swayc_t *view = new_swayc(C_VIEW); 171 swayc_t *view = new_swayc(C_VIEW);
171 sway_log(L_DEBUG, "Adding new view %u:%s as a floating view", 172 sway_log(L_DEBUG, "Adding new view %lu:%x:%s as a floating view",
172 (unsigned int)handle, title); 173 handle, wlc_view_get_type(handle), title);
173 //Setup values 174 //Setup values
174 view->handle = handle; 175 view->handle = handle;
175 view->name = title ? strdup(title) : NULL; 176 view->name = title ? strdup(title) : NULL;
@@ -197,6 +198,7 @@ swayc_t *new_floating_view(wlc_handle handle) {
197 return view; 198 return view;
198} 199}
199 200
201/* Destroy container */
200 202
201swayc_t *destroy_output(swayc_t *output) { 203swayc_t *destroy_output(swayc_t *output) {
202 if (output->children->length == 0) { 204 if (output->children->length == 0) {
@@ -300,3 +302,5 @@ void set_view_visibility(swayc_t *view, void *data) {
300 } 302 }
301 view->visible = (*p == 2); 303 view->visible = (*p == 2);
302} 304}
305
306