aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-23 10:39:24 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-06 19:16:41 +1000
commitc620f76bea08bdab6cfa17a5b3128a4924c6df4d (patch)
treee574ca18b226531da7fc67dbcc4720cbfa2eedbb /sway/input/seat.c
parentMerge pull request #2771 from RyanDwyer/swaylock-seat-capabilities (diff)
downloadsway-c620f76bea08bdab6cfa17a5b3128a4924c6df4d.tar.gz
sway-c620f76bea08bdab6cfa17a5b3128a4924c6df4d.tar.zst
sway-c620f76bea08bdab6cfa17a5b3128a4924c6df4d.zip
Move sticky containers when switching workspace via criteria
* Create a view on workspace 1 * Switch to workspace 2 (on the same output) and create a floating sticky view * Use criteria to focus the view on workspace 1 Previously, we only moved the sticky containers when using workspace_switch, but the above method of focusing doesn't call it. This patch relocates the sticky-moving code into seat_set_focus_warp. A side effect of this patch is that if you have a sticky container focused and then switch workspaces, the sticky container will no longer be focused. It would previously retain focus. In seat_set_focus_warp, new_output_last_ws was only set when changing outputs, but now it's always set. This means new_output_last_ws and last_workspace might point to the same workspace, which means we have to make sure we don't destroy it twice. It now checks to make sure they're different, and to make this more obvious I've moved both calls to workspace_consider_destroy to be next to each other.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c30
1 files changed, 20 insertions, 10 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;