diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-02-04 13:39:10 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-02-04 14:08:54 -0500 |
commit | 515150229847c9ebdfd0cabb6f0026fca9d57a23 (patch) | |
tree | 8a50ce0ac8ce4dc2ec973c63c68dc45378c50737 /sway/tree/layout.c | |
parent | Implement workspaces (diff) | |
download | sway-515150229847c9ebdfd0cabb6f0026fca9d57a23.tar.gz sway-515150229847c9ebdfd0cabb6f0026fca9d57a23.tar.zst sway-515150229847c9ebdfd0cabb6f0026fca9d57a23.zip |
basic focus overhaul
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 30 |
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) { | |||
48 | root_container.layout = L_NONE; | 48 | root_container.layout = L_NONE; |
49 | root_container.name = strdup("root"); | 49 | root_container.name = strdup("root"); |
50 | root_container.children = create_list(); | 50 | root_container.children = create_list(); |
51 | wl_signal_init(&root_container.events.destroy); | ||
51 | 52 | ||
52 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); | 53 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); |
53 | root_container.sway_root->output_layout = wlr_output_layout_create(); | 54 | root_container.sway_root->output_layout = wlr_output_layout_create(); |
54 | wl_list_init(&root_container.sway_root->unmanaged_views); | 55 | wl_list_init(&root_container.sway_root->unmanaged_views); |
56 | wl_signal_init(&root_container.sway_root->events.new_container); | ||
55 | 57 | ||
56 | root_container.sway_root->output_layout_change.notify = | 58 | root_container.sway_root->output_layout_change.notify = |
57 | output_layout_change_notify; | 59 | output_layout_change_notify; |
@@ -59,6 +61,34 @@ void init_layout(void) { | |||
59 | &root_container.sway_root->output_layout_change); | 61 | &root_container.sway_root->output_layout_change); |
60 | } | 62 | } |
61 | 63 | ||
64 | int index_child(const swayc_t *child) { | ||
65 | // TODO handle floating | ||
66 | swayc_t *parent = child->parent; | ||
67 | int i, len; | ||
68 | len = parent->children->length; | ||
69 | for (i = 0; i < len; ++i) { | ||
70 | if (parent->children->items[i] == child) { | ||
71 | break; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | if (!sway_assert(i < len, "Stray container")) { | ||
76 | return -1; | ||
77 | } | ||
78 | return i; | ||
79 | } | ||
80 | |||
81 | swayc_t *add_sibling(swayc_t *fixed, swayc_t *active) { | ||
82 | // TODO handle floating | ||
83 | swayc_t *parent = fixed->parent; | ||
84 | int i = index_child(fixed); | ||
85 | list_insert(parent->children, i + 1, active); | ||
86 | active->parent = parent; | ||
87 | // focus new child | ||
88 | parent->focused = active; | ||
89 | return active->parent; | ||
90 | } | ||
91 | |||
62 | void add_child(swayc_t *parent, swayc_t *child) { | 92 | void add_child(swayc_t *parent, swayc_t *child) { |
63 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", | 93 | wlr_log(L_DEBUG, "Adding %p (%d, %fx%f) to %p (%d, %fx%f)", |
64 | child, child->type, child->width, child->height, | 94 | child, child->type, child->width, child->height, |