aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-02-04 13:39:10 -0500
committerTony Crisci <tony@dubstepdish.com>2018-02-04 14:08:54 -0500
commit515150229847c9ebdfd0cabb6f0026fca9d57a23 (patch)
tree8a50ce0ac8ce4dc2ec973c63c68dc45378c50737 /sway/tree/layout.c
parentb28602aa7425cf435150e6008624429737e037d3 (diff)
basic focus overhaul
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 41ff81b2..45f8c3ae 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -48,10 +48,12 @@ void init_layout(void) {
root_container.layout = L_NONE;
root_container.name = strdup("root");
root_container.children = create_list();
+ wl_signal_init(&root_container.events.destroy);
root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
root_container.sway_root->output_layout = wlr_output_layout_create();
wl_list_init(&root_container.sway_root->unmanaged_views);
+ wl_signal_init(&root_container.sway_root->events.new_container);
root_container.sway_root->output_layout_change.notify =
output_layout_change_notify;
@@ -59,6 +61,34 @@ void init_layout(void) {
&root_container.sway_root->output_layout_change);
}
+int index_child(const swayc_t *child) {
+ // TODO handle floating
+ swayc_t *parent = child->parent;
+ int i, len;
+ len = parent->children->length;
+ for (i = 0; i < len; ++i) {
+ if (parent->children->items[i] == child) {
+ break;
+ }
+ }
+
+ if (!sway_assert(i < len, "Stray container")) {
+ return -1;
+ }
+ return i;
+}
+
+swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) {
+ // TODO handle floating
+ swayc_t *parent = fixed->parent;
+ int i = index_child(fixed);
+ list_insert(parent->children, i + 1, active);
+ active->parent = parent;
+ // focus new child
+ parent->focused = active;
+ return active->parent;
+}
+
void add_child(swayc_t *parent, swayc_t *child) {
wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)",
child, child->type, child->width, child->height,