summaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2015-08-06 08:40:16 -0400
committerDrew DeVault <[email protected]>2015-08-06 08:40:16 -0400
commitc102f184994638155248991e50a7a8ae5c620c91 (patch)
tree2ee8ed6f0bf7e9a7249ff0a49fe83d8999fd01a1 /sway/layout.c
parent82bc36c6812b24fca27c2ec176e2c2998e4df6d5 (diff)
Add layout containers for new outputs
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/layout.c b/sway/layout.c
index aeb8167e..e61094e2 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -1,8 +1,46 @@
#include <stdlib.h>
#include <stdbool.h>
#include <wlc/wlc.h>
+#include "list.h"
#include "layout.h"
+list_t *outputs;
+
+void init_layout() {
+ outputs = create_list();
+}
+
+struct sway_container *get_container(wlc_handle output, int *index) {
+ int i;
+ for (i = 0; i < outputs->length; ++i) {
+ struct sway_container *c = outputs->items[i];
+ if (c->output == output) {
+ return c;
+ }
+ }
+ return NULL;
+}
+
+void add_output(wlc_handle output) {
+ struct sway_container *container = malloc(sizeof(struct sway_container));
+ // TODO: Get default layout from config
+ container->output = output;
+ container->children = create_list();
+ container->layout = LAYOUT_TILE_HORIZ;
+ list_add(outputs, container);
+}
+
+void destroy_output(wlc_handle output) {
+ int index;
+ struct sway_container *c = get_container(output, &index);
+ // TODO: Move all windows in this output somewhere else?
+ // I don't think this will ever be called unless we destroy the output ourselves
+ if (!c) {
+ return;
+ }
+ list_del(outputs, index);
+}
+
wlc_handle get_topmost(wlc_handle output, size_t offset) {
size_t memb;
const wlc_handle *views = wlc_output_get_views(output, &memb);