diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/sway/commands.c b/sway/commands.c index e90a40a3..e485cdb5 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -208,16 +208,16 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
208 | destroy_container(remove_child(view)); | 208 | destroy_container(remove_child(view)); |
209 | 209 | ||
210 | // and move it into workspace floating | 210 | // and move it into workspace floating |
211 | add_floating(active_workspace,view); | 211 | add_floating(swayc_active_workspace(),view); |
212 | view->x = (active_workspace->width - view->width)/2; | 212 | view->x = (swayc_active_workspace()->width - view->width)/2; |
213 | view->y = (active_workspace->height - view->height)/2; | 213 | view->y = (swayc_active_workspace()->height - view->height)/2; |
214 | if (view->desired_width != -1) { | 214 | if (view->desired_width != -1) { |
215 | view->width = view->desired_width; | 215 | view->width = view->desired_width; |
216 | } | 216 | } |
217 | if (view->desired_height != -1) { | 217 | if (view->desired_height != -1) { |
218 | view->height = view->desired_height; | 218 | view->height = view->desired_height; |
219 | } | 219 | } |
220 | arrange_windows(active_workspace, -1, -1); | 220 | arrange_windows(swayc_active_workspace(), -1, -1); |
221 | } else { | 221 | } else { |
222 | // Delete the view from the floating list and unset its is_floating flag | 222 | // Delete the view from the floating list and unset its is_floating flag |
223 | // Using length-1 as the index is safe because the view must be the currently | 223 | // Using length-1 as the index is safe because the view must be the currently |
@@ -228,7 +228,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
228 | swayc_t *focused = container_under_pointer(); | 228 | swayc_t *focused = container_under_pointer(); |
229 | // If focused is null, it's because the currently focused container is a workspace | 229 | // If focused is null, it's because the currently focused container is a workspace |
230 | if (focused == NULL) { | 230 | if (focused == NULL) { |
231 | focused = active_workspace; | 231 | focused = swayc_active_workspace(); |
232 | } | 232 | } |
233 | set_focused_container(focused); | 233 | set_focused_container(focused); |
234 | 234 | ||
@@ -244,7 +244,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { | |||
244 | } | 244 | } |
245 | // Refocus on the view once its been put back into the layout | 245 | // Refocus on the view once its been put back into the layout |
246 | view->width = view->height = 0; | 246 | view->width = view->height = 0; |
247 | arrange_windows(active_workspace, -1, -1); | 247 | arrange_windows(swayc_active_workspace(), -1, -1); |
248 | } | 248 | } |
249 | set_focused_container(view); | 249 | set_focused_container(view); |
250 | } | 250 | } |
@@ -293,37 +293,38 @@ static bool cmd_focus(struct sway_config *config, int argc, char **argv) { | |||
293 | return move_focus(MOVE_PARENT); | 293 | return move_focus(MOVE_PARENT); |
294 | } else if (strcasecmp(argv[0], "mode_toggle") == 0) { | 294 | } else if (strcasecmp(argv[0], "mode_toggle") == 0) { |
295 | int i; | 295 | int i; |
296 | swayc_t *focused = get_focused_view(active_workspace); | 296 | swayc_t *workspace = swayc_active_workspace(); |
297 | swayc_t *focused = get_focused_view(workspace); | ||
297 | if (focused->is_floating) { | 298 | if (focused->is_floating) { |
298 | if (active_workspace->children->length > 0) { | 299 | if (workspace->children->length > 0) { |
299 | for (i = 0;i < active_workspace->floating->length; i++) { | 300 | for (i = 0;i < workspace->floating->length; i++) { |
300 | if (active_workspace->floating->items[i] == focused) { | 301 | if (workspace->floating->items[i] == focused) { |
301 | floating_toggled_index = i; | 302 | floating_toggled_index = i; |
302 | break; | 303 | break; |
303 | } | 304 | } |
304 | } | 305 | } |
305 | if (active_workspace->children->length > tiled_toggled_index) { | 306 | if (workspace->children->length > tiled_toggled_index) { |
306 | set_focused_container(get_focused_view(active_workspace->children->items[tiled_toggled_index])); | 307 | set_focused_container(get_focused_view(workspace->children->items[tiled_toggled_index])); |
307 | } else { | 308 | } else { |
308 | set_focused_container(get_focused_view(active_workspace->children->items[0])); | 309 | set_focused_container(get_focused_view(workspace->children->items[0])); |
309 | tiled_toggled_index = 0; | 310 | tiled_toggled_index = 0; |
310 | } | 311 | } |
311 | } | 312 | } |
312 | } else { | 313 | } else { |
313 | if (active_workspace->floating->length > 0) { | 314 | if (workspace->floating->length > 0) { |
314 | for (i = 0;i < active_workspace->children->length; i++) { | 315 | for (i = 0;i < workspace->children->length; i++) { |
315 | if (active_workspace->children->items[i] == focused) { | 316 | if (workspace->children->items[i] == focused) { |
316 | tiled_toggled_index = i; | 317 | tiled_toggled_index = i; |
317 | break; | 318 | break; |
318 | } | 319 | } |
319 | } | 320 | } |
320 | if (active_workspace->floating->length > floating_toggled_index) { | 321 | if (workspace->floating->length > floating_toggled_index) { |
321 | swayc_t *floating = active_workspace->floating->items[floating_toggled_index]; | 322 | swayc_t *floating = workspace->floating->items[floating_toggled_index]; |
322 | set_focused_container(get_focused_view(floating)); | 323 | set_focused_container(get_focused_view(floating)); |
323 | } else { | 324 | } else { |
324 | swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length - 1]; | 325 | swayc_t *floating = workspace->floating->items[workspace->floating->length - 1]; |
325 | set_focused_container(get_focused_view(floating)); | 326 | set_focused_container(get_focused_view(floating)); |
326 | tiled_toggled_index = active_workspace->floating->length - 1; | 327 | tiled_toggled_index = workspace->floating->length - 1; |
327 | } | 328 | } |
328 | } | 329 | } |
329 | } | 330 | } |
@@ -459,7 +460,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
459 | amount *= -1; | 460 | amount *= -1; |
460 | } | 461 | } |
461 | 462 | ||
462 | swayc_t *parent = get_focused_view(active_workspace); | 463 | swayc_t *parent = get_focused_view(swayc_active_workspace()); |
463 | swayc_t *focused = parent; | 464 | swayc_t *focused = parent; |
464 | swayc_t *sibling; | 465 | swayc_t *sibling; |
465 | if (!parent) { | 466 | if (!parent) { |
@@ -529,7 +530,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
529 | } | 530 | } |
530 | // Recursive resize does not handle positions, let arrange_windows | 531 | // Recursive resize does not handle positions, let arrange_windows |
531 | // take care of that. | 532 | // take care of that. |
532 | arrange_windows(active_workspace, -1, -1); | 533 | arrange_windows(swayc_active_workspace(), -1, -1); |
533 | return true; | 534 | return true; |
534 | } else if (strcmp(argv[1], "height") == 0) { | 535 | } else if (strcmp(argv[1], "height") == 0) { |
535 | int tnumber = 0; | 536 | int tnumber = 0; |
@@ -589,7 +590,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
589 | } | 590 | } |
590 | } | 591 | } |
591 | } | 592 | } |
592 | arrange_windows(active_workspace, -1, -1); | 593 | arrange_windows(swayc_active_workspace(), -1, -1); |
593 | return true; | 594 | return true; |
594 | } | 595 | } |
595 | return true; | 596 | return true; |
@@ -616,8 +617,12 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay | |||
616 | } | 617 | } |
617 | swayc_t *focused = get_focused_container(&root_container); | 618 | swayc_t *focused = get_focused_container(&root_container); |
618 | 619 | ||
620 | // Case of floating window, dont split | ||
621 | if (focused->is_floating) { | ||
622 | return true; | ||
623 | } | ||
624 | /* Case that focus is on an workspace with 0/1 children.change its layout */ | ||
619 | if (focused->type == C_WORKSPACE && focused->children->length <= 1) { | 625 | if (focused->type == C_WORKSPACE && focused->children->length <= 1) { |
620 | /* Case that focus is on an workspace with 0/1 children.change its layout */ | ||
621 | sway_log(L_DEBUG, "changing workspace layout"); | 626 | sway_log(L_DEBUG, "changing workspace layout"); |
622 | focused->layout = layout; | 627 | focused->layout = layout; |
623 | } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { | 628 | } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { |
@@ -632,7 +637,6 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay | |||
632 | set_focused_container(focused); | 637 | set_focused_container(focused); |
633 | arrange_windows(parent, -1, -1); | 638 | arrange_windows(parent, -1, -1); |
634 | } | 639 | } |
635 | |||
636 | return true; | 640 | return true; |
637 | } | 641 | } |
638 | 642 | ||
@@ -721,7 +725,7 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) { | |||
721 | return true; | 725 | return true; |
722 | } | 726 | } |
723 | 727 | ||
724 | swayc_t *workspace = workspace_find_by_name(argv[0]); | 728 | swayc_t *workspace = workspace_by_name(argv[0]); |
725 | if (!workspace) { | 729 | if (!workspace) { |
726 | workspace = workspace_create(argv[0]); | 730 | workspace = workspace_create(argv[0]); |
727 | } | 731 | } |