diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/sway/commands.c b/sway/commands.c index 42d6b173..6e1f1848 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -185,40 +185,23 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
185 | int i; | 185 | int i; |
186 | // Change from nonfloating to floating | 186 | // Change from nonfloating to floating |
187 | if (!view->is_floating) { | 187 | if (!view->is_floating) { |
188 | view->is_floating = true; | 188 | remove_child(view); |
189 | for (i = 0; i < view->parent->children->length; i++) { | 189 | add_floating(active_workspace,view); |
190 | if (view->parent->children->items[i] == view) { | 190 | view->x = (active_workspace->width - view->width)/2; |
191 | // Try to use desired geometry to set w/h | 191 | view->y = (active_workspace->height - view->height)/2; |
192 | if (view->desired_width != -1) { | 192 | arrange_windows(active_workspace, -1, -1); |
193 | view->width = view->desired_width; | 193 | if (view->desired_width != -1) { |
194 | } | 194 | view->width = view->desired_width; |
195 | if (view->desired_height != -1) { | 195 | } |
196 | view->height = view->desired_height; | 196 | if (view->desired_height != -1) { |
197 | } | 197 | view->height = view->desired_height; |
198 | |||
199 | // Swap from the list of whatever container the view was in | ||
200 | // to the workspace->floating list | ||
201 | list_del(view->parent->children, i); | ||
202 | list_add(active_workspace->floating, view); | ||
203 | destroy_container(view->parent); | ||
204 | |||
205 | // Set the new position of the container and arrange windows | ||
206 | view->x = (active_workspace->width - view->width)/2; | ||
207 | view->y = (active_workspace->height - view->height)/2; | ||
208 | sway_log(L_INFO, "Setting container %p to floating at coordinates X:%d Y:%d, W:%d, H:%d", view, view->x, view->y, view->width, view->height); | ||
209 | // Change parent to active_workspace | ||
210 | view->parent = active_workspace; | ||
211 | arrange_windows(active_workspace, -1, -1); | ||
212 | return true; | ||
213 | } | ||
214 | } | 198 | } |
215 | } else { | 199 | } else { |
216 | // Delete the view from the floating list and unset its is_floating flag | 200 | // Delete the view from the floating list and unset its is_floating flag |
217 | // Using length-1 as the index is safe because the view must be the currently | 201 | // Using length-1 as the index is safe because the view must be the currently |
218 | // focused floating output | 202 | // focused floating output |
219 | list_del(active_workspace->floating, active_workspace->floating->length - 1); | 203 | remove_child(view); |
220 | view->is_floating = false; | 204 | view->is_floating = false; |
221 | active_workspace->focused = NULL; | ||
222 | // Get the properly focused container, and add in the view there | 205 | // Get the properly focused container, and add in the view there |
223 | swayc_t *focused = container_under_pointer(); | 206 | swayc_t *focused = container_under_pointer(); |
224 | // If focused is null, it's because the currently focused container is a workspace | 207 | // If focused is null, it's because the currently focused container is a workspace |