aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-05-04 08:24:25 -0400
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commitf3ab895916ca1a0f004b5ceaefa90eee90676532 (patch)
treeaa572c41265fae21617b13b62b1c8d5df1f2d47d /sway/tree/layout.c
parentMerge pull request #2081 from RedSoxFan/fix-2077 (diff)
downloadsway-f3ab895916ca1a0f004b5ceaefa90eee90676532.tar.gz
sway-f3ab895916ca1a0f004b5ceaefa90eee90676532.tar.zst
sway-f3ab895916ca1a0f004b5ceaefa90eee90676532.zip
Implement `floating enable`
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 2f4ae667..7bbeb4b1 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -142,11 +142,26 @@ struct sway_container *container_remove_child(struct sway_container *child) {
142 } 142 }
143 143
144 struct sway_container *parent = child->parent; 144 struct sway_container *parent = child->parent;
145 for (int i = 0; i < parent->children->length; ++i) { 145 if (!child->is_floating) {
146 if (parent->children->items[i] == child) { 146 for (int i = 0; i < parent->children->length; ++i) {
147 list_del(parent->children, i); 147 if (parent->children->items[i] == child) {
148 break; 148 list_del(parent->children, i);
149 break;
150 }
151 }
152 } else {
153 if (!sway_assert(parent->type == C_WORKSPACE && child->type == C_VIEW,
154 "Found floating non-view and/or in non-workspace")) {
155 return parent;
156 }
157 struct sway_workspace *ws = parent->sway_workspace;
158 for (int i = 0; i < ws->floating->length; ++i) {
159 if (ws->floating->items[i] == child) {
160 list_del(ws->floating, i);
161 break;
162 }
149 } 163 }
164 child->is_floating = false;
150 } 165 }
151 child->parent = NULL; 166 child->parent = NULL;
152 container_notify_subtree_changed(parent); 167 container_notify_subtree_changed(parent);
@@ -154,6 +169,26 @@ struct sway_container *container_remove_child(struct sway_container *child) {
154 return parent; 169 return parent;
155} 170}
156 171
172void container_add_floating(struct sway_container *workspace,
173 struct sway_container *child) {
174 if (!sway_assert(workspace->type == C_WORKSPACE && child->type == C_VIEW,
175 "Attempted to float non-view and/or in non-workspace")) {
176 return;
177 }
178 if (!sway_assert(!child->parent,
179 "child already has a parent (invalid call)")) {
180 return;
181 }
182 if (!sway_assert(!child->is_floating,
183 "child is already floating (invalid state)")) {
184 return;
185 }
186 struct sway_workspace *ws = workspace->sway_workspace;
187 list_add(ws->floating, child);
188 child->parent = workspace;
189 child->is_floating = true;
190}
191
157void container_move_to(struct sway_container *container, 192void container_move_to(struct sway_container *container,
158 struct sway_container *destination) { 193 struct sway_container *destination) {
159 if (container == destination 194 if (container == destination