diff options
author | emersion <contact@emersion.fr> | 2018-10-06 14:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-06 14:53:09 +0200 |
commit | 0f45aa4ea9115f3f6a586efe7ff748e26d70bf7e (patch) | |
tree | e574ca18b226531da7fc67dbcc4720cbfa2eedbb | |
parent | Merge pull request #2771 from RyanDwyer/swaylock-seat-capabilities (diff) | |
parent | Move sticky containers when switching workspace via criteria (diff) | |
download | sway-0f45aa4ea9115f3f6a586efe7ff748e26d70bf7e.tar.gz sway-0f45aa4ea9115f3f6a586efe7ff748e26d70bf7e.tar.zst sway-0f45aa4ea9115f3f6a586efe7ff748e26d70bf7e.zip |
Merge pull request #2693 from RyanDwyer/move-sticky-in-seat
Move sticky containers when switching workspace via criteria
-rw-r--r-- | sway/input/seat.c | 30 | ||||
-rw-r--r-- | sway/tree/workspace.c | 22 |
2 files changed, 20 insertions, 32 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 675edb2d..f5cb2f9e 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -667,10 +667,8 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | |||
667 | } | 667 | } |
668 | 668 | ||
669 | // find new output's old workspace, which might have to be removed if empty | 669 | // find new output's old workspace, which might have to be removed if empty |
670 | struct sway_workspace *new_output_last_ws = NULL; | 670 | struct sway_workspace *new_output_last_ws = |
671 | if (new_output && last_output != new_output) { | 671 | new_output ? output_get_active_workspace(new_output) : NULL; |
672 | new_output_last_ws = output_get_active_workspace(new_output); | ||
673 | } | ||
674 | 672 | ||
675 | // Unfocus the previous focus | 673 | // Unfocus the previous focus |
676 | if (last_focus) { | 674 | if (last_focus) { |
@@ -719,8 +717,17 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | |||
719 | ipc_event_window(container, "focus"); | 717 | ipc_event_window(container, "focus"); |
720 | } | 718 | } |
721 | 719 | ||
722 | if (new_output_last_ws) { | 720 | // Move sticky containers to new workspace |
723 | workspace_consider_destroy(new_output_last_ws); | 721 | if (new_output_last_ws && new_workspace != new_output_last_ws) { |
722 | for (int i = 0; i < new_output_last_ws->floating->length; ++i) { | ||
723 | struct sway_container *floater = | ||
724 | new_output_last_ws->floating->items[i]; | ||
725 | if (floater->is_sticky) { | ||
726 | container_detach(floater); | ||
727 | workspace_add_floating(new_workspace, floater); | ||
728 | --i; | ||
729 | } | ||
730 | } | ||
724 | } | 731 | } |
725 | 732 | ||
726 | // Close any popups on the old focus | 733 | // Close any popups on the old focus |
@@ -754,11 +761,14 @@ void seat_set_focus_warp(struct sway_seat *seat, struct sway_node *node, | |||
754 | container_raise_floating(container); | 761 | container_raise_floating(container); |
755 | } | 762 | } |
756 | 763 | ||
757 | if (last_focus) { | 764 | if (new_output_last_ws) { |
758 | if (last_workspace) { | 765 | workspace_consider_destroy(new_output_last_ws); |
759 | workspace_consider_destroy(last_workspace); | 766 | } |
760 | } | 767 | if (last_workspace && last_workspace != new_output_last_ws) { |
768 | workspace_consider_destroy(last_workspace); | ||
769 | } | ||
761 | 770 | ||
771 | if (last_focus) { | ||
762 | if (config->mouse_warping && warp && new_output != last_output) { | 772 | if (config->mouse_warping && warp && new_output != last_output) { |
763 | double x = 0; | 773 | double x = 0; |
764 | double y = 0; | 774 | double y = 0; |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index e9e5dfa2..b357d83d 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -369,7 +369,6 @@ struct sway_workspace *workspace_prev(struct sway_workspace *current) { | |||
369 | bool workspace_switch(struct sway_workspace *workspace, | 369 | bool workspace_switch(struct sway_workspace *workspace, |
370 | bool no_auto_back_and_forth) { | 370 | bool no_auto_back_and_forth) { |
371 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 371 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
372 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); | ||
373 | struct sway_workspace *active_ws = seat_get_focused_workspace(seat); | 372 | struct sway_workspace *active_ws = seat_get_focused_workspace(seat); |
374 | 373 | ||
375 | if (!no_auto_back_and_forth && config->auto_back_and_forth | 374 | if (!no_auto_back_and_forth && config->auto_back_and_forth |
@@ -392,27 +391,6 @@ bool workspace_switch(struct sway_workspace *workspace, | |||
392 | strcpy(prev_workspace_name, active_ws->name); | 391 | strcpy(prev_workspace_name, active_ws->name); |
393 | } | 392 | } |
394 | 393 | ||
395 | // Move sticky containers to new workspace | ||
396 | struct sway_output *next_output = workspace->output; | ||
397 | struct sway_workspace *next_output_prev_ws = | ||
398 | output_get_active_workspace(next_output); | ||
399 | if (workspace != next_output_prev_ws) { | ||
400 | for (int i = 0; i < next_output_prev_ws->floating->length; ++i) { | ||
401 | struct sway_container *floater = | ||
402 | next_output_prev_ws->floating->items[i]; | ||
403 | if (floater->is_sticky) { | ||
404 | container_detach(floater); | ||
405 | workspace_add_floating(workspace, floater); | ||
406 | if (&floater->node == focus) { | ||
407 | seat_set_focus(seat, NULL); | ||
408 | seat_set_focus_container(seat, floater); | ||
409 | cursor_send_pointer_motion(seat->cursor, 0, true); | ||
410 | } | ||
411 | --i; | ||
412 | } | ||
413 | } | ||
414 | } | ||
415 | |||
416 | wlr_log(WLR_DEBUG, "Switching to workspace %p:%s", | 394 | wlr_log(WLR_DEBUG, "Switching to workspace %p:%s", |
417 | workspace, workspace->name); | 395 | workspace, workspace->name); |
418 | struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node); | 396 | struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node); |