diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/sway/commands.c b/sway/commands.c index ab24f6ae..cc51717b 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -186,43 +186,28 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
186 | if (view->type != C_VIEW) { | 186 | if (view->type != C_VIEW) { |
187 | return true; | 187 | return true; |
188 | } | 188 | } |
189 | int i; | ||
190 | // Change from nonfloating to floating | 189 | // Change from nonfloating to floating |
191 | if (!view->is_floating) { | 190 | if (!view->is_floating) { |
192 | view->is_floating = true; | 191 | //Remove view from its current location |
193 | for (i = 0; i < view->parent->children->length; i++) { | 192 | destroy_container(remove_child(view)); |
194 | if (view->parent->children->items[i] == view) { | 193 | |
195 | // Try to use desired geometry to set w/h | 194 | //and move it into workspace floating |
196 | if (view->desired_width != -1) { | 195 | add_floating(active_workspace,view); |
197 | view->width = view->desired_width; | 196 | view->x = (active_workspace->width - view->width)/2; |
198 | } | 197 | view->y = (active_workspace->height - view->height)/2; |
199 | if (view->desired_height != -1) { | 198 | if (view->desired_width != -1) { |
200 | view->height = view->desired_height; | 199 | view->width = view->desired_width; |
201 | } | 200 | } |
202 | 201 | if (view->desired_height != -1) { | |
203 | // Swap from the list of whatever container the view was in | 202 | view->height = view->desired_height; |
204 | // to the workspace->floating list | ||
205 | list_del(view->parent->children, i); | ||
206 | list_add(active_workspace->floating, view); | ||
207 | destroy_container(view->parent); | ||
208 | |||
209 | // Set the new position of the container and arrange windows | ||
210 | view->x = (active_workspace->width - view->width)/2; | ||
211 | view->y = (active_workspace->height - view->height)/2; | ||
212 | 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); | ||
213 | // Change parent to active_workspace | ||
214 | view->parent = active_workspace; | ||
215 | arrange_windows(active_workspace, -1, -1); | ||
216 | return true; | ||
217 | } | ||
218 | } | 203 | } |
204 | arrange_windows(active_workspace, -1, -1); | ||
219 | } else { | 205 | } else { |
220 | // Delete the view from the floating list and unset its is_floating flag | 206 | // Delete the view from the floating list and unset its is_floating flag |
221 | // Using length-1 as the index is safe because the view must be the currently | 207 | // Using length-1 as the index is safe because the view must be the currently |
222 | // focused floating output | 208 | // focused floating output |
223 | list_del(active_workspace->floating, active_workspace->floating->length - 1); | 209 | remove_child(view); |
224 | view->is_floating = false; | 210 | view->is_floating = false; |
225 | active_workspace->focused = NULL; | ||
226 | // Get the properly focused container, and add in the view there | 211 | // Get the properly focused container, and add in the view there |
227 | swayc_t *focused = container_under_pointer(); | 212 | swayc_t *focused = container_under_pointer(); |
228 | // If focused is null, it's because the currently focused container is a workspace | 213 | // If focused is null, it's because the currently focused container is a workspace |
@@ -242,10 +227,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
242 | add_sibling(focused, view); | 227 | add_sibling(focused, view); |
243 | } | 228 | } |
244 | // Refocus on the view once its been put back into the layout | 229 | // Refocus on the view once its been put back into the layout |
245 | set_focused_container(view); | ||
246 | arrange_windows(active_workspace, -1, -1); | 230 | arrange_windows(active_workspace, -1, -1); |
247 | return true; | 231 | return true; |
248 | } | 232 | } |
233 | set_focused_container(view); | ||
249 | } | 234 | } |
250 | 235 | ||
251 | return true; | 236 | return true; |