diff options
-rw-r--r-- | include/sway/input/seat.h | 5 | ||||
-rw-r--r-- | sway/commands/floating.c | 5 | ||||
-rw-r--r-- | sway/commands/focus.c | 4 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 7 | ||||
-rw-r--r-- | sway/commands/layout.c | 6 | ||||
-rw-r--r-- | sway/commands/move.c | 9 | ||||
-rw-r--r-- | sway/commands/split.c | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 9 | ||||
-rw-r--r-- | sway/desktop/render.c | 3 | ||||
-rw-r--r-- | sway/input/seat.c | 50 | ||||
-rw-r--r-- | sway/tree/container.c | 92 | ||||
-rw-r--r-- | sway/tree/node.c | 8 | ||||
-rw-r--r-- | sway/tree/root.c | 14 | ||||
-rw-r--r-- | sway/tree/view.c | 62 |
14 files changed, 220 insertions, 57 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index f2af1066..eb6c09a1 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -143,6 +143,11 @@ struct sway_node *seat_get_focus(struct sway_seat *seat); | |||
143 | 143 | ||
144 | struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat); | 144 | struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat); |
145 | 145 | ||
146 | // If a scratchpad container is fullscreen global, this can be used to try to | ||
147 | // determine the last focused workspace. Otherwise, this should yield the same | ||
148 | // results as seat_get_focused_workspace. | ||
149 | struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat); | ||
150 | |||
146 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); | 151 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); |
147 | 152 | ||
148 | /** | 153 | /** |
diff --git a/sway/commands/floating.c b/sway/commands/floating.c index 5df9b1bf..ce123345 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c | |||
@@ -32,6 +32,11 @@ struct cmd_results *cmd_floating(int argc, char **argv) { | |||
32 | seat_set_focus_container(config->handler_context.seat, container); | 32 | seat_set_focus_container(config->handler_context.seat, container); |
33 | } | 33 | } |
34 | 34 | ||
35 | if (container_is_scratchpad_hidden(container)) { | ||
36 | return cmd_results_new(CMD_INVALID, | ||
37 | "Can't change floating on hidden scratchpad container"); | ||
38 | } | ||
39 | |||
35 | // If the container is in a floating split container, | 40 | // If the container is in a floating split container, |
36 | // operate on the split container instead of the child. | 41 | // operate on the split container instead of the child. |
37 | if (container_is_floating_or_child(container)) { | 42 | if (container_is_floating_or_child(container)) { |
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 14e90955..8baa616d 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -182,6 +182,10 @@ static struct sway_node *node_get_in_direction_floating( | |||
182 | double closest_distance = DBL_MAX; | 182 | double closest_distance = DBL_MAX; |
183 | struct sway_container *closest_con = NULL; | 183 | struct sway_container *closest_con = NULL; |
184 | 184 | ||
185 | if (!con->workspace) { | ||
186 | return NULL; | ||
187 | } | ||
188 | |||
185 | for (int i = 0; i < con->workspace->floating->length; i++) { | 189 | for (int i = 0; i < con->workspace->floating->length; i++) { |
186 | struct sway_container *floater = con->workspace->floating->items[i]; | 190 | struct sway_container *floater = con->workspace->floating->items[i]; |
187 | if (floater == con) { | 191 | if (floater == con) { |
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 52248ce4..a268ba03 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c | |||
@@ -26,6 +26,13 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { | |||
26 | "Can't fullscreen an empty workspace"); | 26 | "Can't fullscreen an empty workspace"); |
27 | } | 27 | } |
28 | 28 | ||
29 | // If in the scratchpad, operate on the highest container | ||
30 | if (container && !container->workspace) { | ||
31 | while (container->parent) { | ||
32 | container = container->parent; | ||
33 | } | ||
34 | } | ||
35 | |||
29 | bool is_fullscreen = container && | 36 | bool is_fullscreen = container && |
30 | container->fullscreen_mode != FULLSCREEN_NONE; | 37 | container->fullscreen_mode != FULLSCREEN_NONE; |
31 | bool global = false; | 38 | bool global = false; |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 7d61c3be..32f8fb52 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -147,7 +147,11 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
147 | workspace->layout = new_layout; | 147 | workspace->layout = new_layout; |
148 | workspace_update_representation(workspace); | 148 | workspace_update_representation(workspace); |
149 | } | 149 | } |
150 | arrange_workspace(workspace); | 150 | if (root->fullscreen_global) { |
151 | arrange_root(); | ||
152 | } else { | ||
153 | arrange_workspace(workspace); | ||
154 | } | ||
151 | } | 155 | } |
152 | 156 | ||
153 | return cmd_results_new(CMD_SUCCESS, NULL); | 157 | return cmd_results_new(CMD_SUCCESS, NULL); |
diff --git a/sway/commands/move.c b/sway/commands/move.c index f642f023..4ebc949b 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -395,6 +395,11 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { | |||
395 | container = workspace_wrap_children(workspace); | 395 | container = workspace_wrap_children(workspace); |
396 | } | 396 | } |
397 | 397 | ||
398 | if (container->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
399 | return cmd_results_new(CMD_FAILURE, | ||
400 | "Can't move fullscreen global container"); | ||
401 | } | ||
402 | |||
398 | bool no_auto_back_and_forth = false; | 403 | bool no_auto_back_and_forth = false; |
399 | while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) { | 404 | while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) { |
400 | no_auto_back_and_forth = true; | 405 | no_auto_back_and_forth = true; |
@@ -646,6 +651,10 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) { | |||
646 | } | 651 | } |
647 | 652 | ||
648 | struct sway_workspace *workspace = config->handler_context.workspace; | 653 | struct sway_workspace *workspace = config->handler_context.workspace; |
654 | if (!workspace) { | ||
655 | return cmd_results_new(CMD_FAILURE, "No workspace to move"); | ||
656 | } | ||
657 | |||
649 | struct sway_output *old_output = workspace->output; | 658 | struct sway_output *old_output = workspace->output; |
650 | int center_x = workspace->width / 2 + workspace->x, | 659 | int center_x = workspace->width / 2 + workspace->x, |
651 | center_y = workspace->height / 2 + workspace->y; | 660 | center_y = workspace->height / 2 + workspace->y; |
diff --git a/sway/commands/split.c b/sway/commands/split.c index e9670722..8702f39e 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -13,7 +13,8 @@ static struct cmd_results *do_split(int layout) { | |||
13 | struct sway_container *con = config->handler_context.container; | 13 | struct sway_container *con = config->handler_context.container; |
14 | struct sway_workspace *ws = config->handler_context.workspace; | 14 | struct sway_workspace *ws = config->handler_context.workspace; |
15 | if (con) { | 15 | if (con) { |
16 | if (container_is_scratchpad_hidden(con)) { | 16 | if (container_is_scratchpad_hidden(con) && |
17 | con->fullscreen_mode != FULLSCREEN_GLOBAL) { | ||
17 | return cmd_results_new(CMD_FAILURE, | 18 | return cmd_results_new(CMD_FAILURE, |
18 | "Cannot split a hidden scratchpad container"); | 19 | "Cannot split a hidden scratchpad container"); |
19 | } | 20 | } |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0b3e1edb..b1e3464a 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -251,14 +251,11 @@ static void output_for_each_surface(struct sway_output *output, | |||
251 | }; | 251 | }; |
252 | 252 | ||
253 | struct sway_workspace *workspace = output_get_active_workspace(output); | 253 | struct sway_workspace *workspace = output_get_active_workspace(output); |
254 | if (!workspace) { | ||
255 | return; | ||
256 | } | ||
257 | struct sway_container *fullscreen_con = root->fullscreen_global; | 254 | struct sway_container *fullscreen_con = root->fullscreen_global; |
258 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { | ||
259 | fullscreen_con = NULL; | ||
260 | } | ||
261 | if (!fullscreen_con) { | 255 | if (!fullscreen_con) { |
256 | if (!workspace) { | ||
257 | return; | ||
258 | } | ||
262 | fullscreen_con = workspace->current.fullscreen; | 259 | fullscreen_con = workspace->current.fullscreen; |
263 | } | 260 | } |
264 | if (fullscreen_con) { | 261 | if (fullscreen_con) { |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 7216e30b..771bd908 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -997,9 +997,6 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
997 | } | 997 | } |
998 | 998 | ||
999 | struct sway_container *fullscreen_con = root->fullscreen_global; | 999 | struct sway_container *fullscreen_con = root->fullscreen_global; |
1000 | if (fullscreen_con && container_is_scratchpad_hidden(fullscreen_con)) { | ||
1001 | fullscreen_con = NULL; | ||
1002 | } | ||
1003 | if (!fullscreen_con) { | 1000 | if (!fullscreen_con) { |
1004 | fullscreen_con = workspace->current.fullscreen; | 1001 | fullscreen_con = workspace->current.fullscreen; |
1005 | } | 1002 | } |
diff --git a/sway/input/seat.c b/sway/input/seat.c index bdab8b81..ce009d7e 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -172,14 +172,14 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) { | |||
172 | 172 | ||
173 | seat_node_destroy(seat_node); | 173 | seat_node_destroy(seat_node); |
174 | 174 | ||
175 | if (!parent) { | 175 | if (!parent && !needs_new_focus) { |
176 | // Destroying a container that is no longer in the tree | 176 | // Destroying a container that is no longer in the tree |
177 | return; | 177 | return; |
178 | } | 178 | } |
179 | 179 | ||
180 | // Find new focus_inactive (ie. sibling, or workspace if no siblings left) | 180 | // Find new focus_inactive (ie. sibling, or workspace if no siblings left) |
181 | struct sway_node *next_focus = NULL; | 181 | struct sway_node *next_focus = NULL; |
182 | while (next_focus == NULL) { | 182 | while (next_focus == NULL && parent != NULL) { |
183 | struct sway_container *con = | 183 | struct sway_container *con = |
184 | seat_get_focus_inactive_view(seat, parent); | 184 | seat_get_focus_inactive_view(seat, parent); |
185 | next_focus = con ? &con->node : NULL; | 185 | next_focus = con ? &con->node : NULL; |
@@ -192,6 +192,16 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) { | |||
192 | parent = node_get_parent(parent); | 192 | parent = node_get_parent(parent); |
193 | } | 193 | } |
194 | 194 | ||
195 | if (!next_focus) { | ||
196 | struct sway_workspace *ws = seat_get_last_known_workspace(seat); | ||
197 | if (!ws) { | ||
198 | return; | ||
199 | } | ||
200 | struct sway_container *con = | ||
201 | seat_get_focus_inactive_view(seat, &ws->node); | ||
202 | next_focus = con ? &(con->node) : &(ws->node); | ||
203 | } | ||
204 | |||
195 | if (next_focus->type == N_WORKSPACE && | 205 | if (next_focus->type == N_WORKSPACE && |
196 | !workspace_is_visible(next_focus->sway_workspace)) { | 206 | !workspace_is_visible(next_focus->sway_workspace)) { |
197 | // Do not change focus to a non-visible workspace | 207 | // Do not change focus to a non-visible workspace |
@@ -199,6 +209,10 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) { | |||
199 | } | 209 | } |
200 | 210 | ||
201 | if (needs_new_focus) { | 211 | if (needs_new_focus) { |
212 | // Make sure the workspace IPC event gets sent | ||
213 | if (node->type == N_CONTAINER && node->sway_container->scratchpad) { | ||
214 | seat_set_focus(seat, NULL); | ||
215 | } | ||
202 | // The structure change might have caused it to move up to the top of | 216 | // The structure change might have caused it to move up to the top of |
203 | // the focus stack without sending focus notifications to the view | 217 | // the focus stack without sending focus notifications to the view |
204 | seat_send_focus(next_focus, seat); | 218 | seat_send_focus(next_focus, seat); |
@@ -207,7 +221,7 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) { | |||
207 | // Setting focus_inactive | 221 | // Setting focus_inactive |
208 | focus = seat_get_focus_inactive(seat, &root->node); | 222 | focus = seat_get_focus_inactive(seat, &root->node); |
209 | seat_set_raw_focus(seat, next_focus); | 223 | seat_set_raw_focus(seat, next_focus); |
210 | if (focus->type == N_CONTAINER) { | 224 | if (focus->type == N_CONTAINER && focus->sway_container->workspace) { |
211 | seat_set_raw_focus(seat, &focus->sway_container->workspace->node); | 225 | seat_set_raw_focus(seat, &focus->sway_container->workspace->node); |
212 | } | 226 | } |
213 | seat_set_raw_focus(seat, focus); | 227 | seat_set_raw_focus(seat, focus); |
@@ -795,7 +809,13 @@ void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node) { | |||
795 | wl_list_remove(&seat_node->link); | 809 | wl_list_remove(&seat_node->link); |
796 | wl_list_insert(&seat->focus_stack, &seat_node->link); | 810 | wl_list_insert(&seat->focus_stack, &seat_node->link); |
797 | node_set_dirty(node); | 811 | node_set_dirty(node); |
798 | node_set_dirty(node_get_parent(node)); | 812 | |
813 | // If focusing a scratchpad container that is fullscreen global, parent | ||
814 | // will be NULL | ||
815 | struct sway_node *parent = node_get_parent(node); | ||
816 | if (parent) { | ||
817 | node_set_dirty(parent); | ||
818 | } | ||
799 | } | 819 | } |
800 | 820 | ||
801 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | 821 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { |
@@ -850,7 +870,8 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
850 | } | 870 | } |
851 | } | 871 | } |
852 | 872 | ||
853 | struct sway_output *new_output = new_workspace->output; | 873 | struct sway_output *new_output = |
874 | new_workspace ? new_workspace->output : NULL; | ||
854 | 875 | ||
855 | if (last_workspace != new_workspace && new_output) { | 876 | if (last_workspace != new_workspace && new_output) { |
856 | node_set_dirty(&new_output->node); | 877 | node_set_dirty(&new_output->node); |
@@ -894,7 +915,8 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
894 | } | 915 | } |
895 | 916 | ||
896 | // Move sticky containers to new workspace | 917 | // Move sticky containers to new workspace |
897 | if (new_output_last_ws && new_workspace != new_output_last_ws) { | 918 | if (new_workspace && new_output_last_ws |
919 | && new_workspace != new_output_last_ws) { | ||
898 | for (int i = 0; i < new_output_last_ws->floating->length; ++i) { | 920 | for (int i = 0; i < new_output_last_ws->floating->length; ++i) { |
899 | struct sway_container *floater = | 921 | struct sway_container *floater = |
900 | new_output_last_ws->floating->items[i]; | 922 | new_output_last_ws->floating->items[i]; |
@@ -940,7 +962,7 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) { | |||
940 | 962 | ||
941 | seat->has_focus = true; | 963 | seat->has_focus = true; |
942 | 964 | ||
943 | if (config->smart_gaps) { | 965 | if (config->smart_gaps && new_workspace) { |
944 | // When smart gaps is on, gaps may change when the focus changes so | 966 | // When smart gaps is on, gaps may change when the focus changes so |
945 | // the workspace needs to be arranged | 967 | // the workspace needs to be arranged |
946 | arrange_workspace(new_workspace); | 968 | arrange_workspace(new_workspace); |
@@ -1134,6 +1156,20 @@ struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat) { | |||
1134 | return NULL; // output doesn't have a workspace yet | 1156 | return NULL; // output doesn't have a workspace yet |
1135 | } | 1157 | } |
1136 | 1158 | ||
1159 | struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat) { | ||
1160 | struct sway_seat_node *current; | ||
1161 | wl_list_for_each(current, &seat->focus_stack, link) { | ||
1162 | struct sway_node *node = current->node; | ||
1163 | if (node->type == N_CONTAINER && | ||
1164 | node->sway_container->workspace) { | ||
1165 | return node->sway_container->workspace; | ||
1166 | } else if (node->type == N_WORKSPACE) { | ||
1167 | return node->sway_workspace; | ||
1168 | } | ||
1169 | } | ||
1170 | return NULL; | ||
1171 | } | ||
1172 | |||
1137 | struct sway_container *seat_get_focused_container(struct sway_seat *seat) { | 1173 | struct sway_container *seat_get_focused_container(struct sway_seat *seat) { |
1138 | struct sway_node *focus = seat_get_focus(seat); | 1174 | struct sway_node *focus = seat_get_focus(seat); |
1139 | if (focus && focus->type == N_CONTAINER) { | 1175 | if (focus && focus->type == N_CONTAINER) { |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 02b4d1b0..11ed4f98 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -95,6 +95,10 @@ void container_begin_destroy(struct sway_container *con) { | |||
95 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE && con->workspace) { | 95 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE && con->workspace) { |
96 | con->workspace->fullscreen = NULL; | 96 | con->workspace->fullscreen = NULL; |
97 | } | 97 | } |
98 | if (con->scratchpad && con->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
99 | container_fullscreen_disable(con); | ||
100 | } | ||
101 | |||
98 | wl_signal_emit(&con->node.events.destroy, &con->node); | 102 | wl_signal_emit(&con->node.events.destroy, &con->node); |
99 | 103 | ||
100 | container_end_mouse_operation(con); | 104 | container_end_mouse_operation(con); |
@@ -128,7 +132,9 @@ void container_reap_empty(struct sway_container *con) { | |||
128 | container_begin_destroy(con); | 132 | container_begin_destroy(con); |
129 | con = parent; | 133 | con = parent; |
130 | } | 134 | } |
131 | workspace_consider_destroy(ws); | 135 | if (ws) { |
136 | workspace_consider_destroy(ws); | ||
137 | } | ||
132 | } | 138 | } |
133 | 139 | ||
134 | struct sway_container *container_flatten(struct sway_container *container) { | 140 | struct sway_container *container_flatten(struct sway_container *container) { |
@@ -954,18 +960,20 @@ static void container_fullscreen_workspace(struct sway_container *con) { | |||
954 | set_fullscreen_iterator(con, &enable); | 960 | set_fullscreen_iterator(con, &enable); |
955 | container_for_each_child(con, set_fullscreen_iterator, &enable); | 961 | container_for_each_child(con, set_fullscreen_iterator, &enable); |
956 | 962 | ||
957 | con->workspace->fullscreen = con; | ||
958 | con->saved_x = con->x; | 963 | con->saved_x = con->x; |
959 | con->saved_y = con->y; | 964 | con->saved_y = con->y; |
960 | con->saved_width = con->width; | 965 | con->saved_width = con->width; |
961 | con->saved_height = con->height; | 966 | con->saved_height = con->height; |
962 | 967 | ||
963 | struct sway_seat *seat; | 968 | if (con->workspace) { |
964 | struct sway_workspace *focus_ws; | 969 | con->workspace->fullscreen = con; |
965 | wl_list_for_each(seat, &server.input->seats, link) { | 970 | struct sway_seat *seat; |
966 | focus_ws = seat_get_focused_workspace(seat); | 971 | struct sway_workspace *focus_ws; |
967 | if (focus_ws == con->workspace) { | 972 | wl_list_for_each(seat, &server.input->seats, link) { |
968 | seat_set_focus_container(seat, con); | 973 | focus_ws = seat_get_focused_workspace(seat); |
974 | if (focus_ws == con->workspace) { | ||
975 | seat_set_focus_container(seat, con); | ||
976 | } | ||
969 | } | 977 | } |
970 | } | 978 | } |
971 | 979 | ||
@@ -1019,11 +1027,14 @@ void container_fullscreen_disable(struct sway_container *con) { | |||
1019 | con->height = con->saved_height; | 1027 | con->height = con->saved_height; |
1020 | 1028 | ||
1021 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { | 1029 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { |
1022 | con->workspace->fullscreen = NULL; | 1030 | if (con->workspace) { |
1023 | if (container_is_floating(con)) { | 1031 | con->workspace->fullscreen = NULL; |
1024 | struct sway_output *output = container_floating_find_output(con); | 1032 | if (container_is_floating(con)) { |
1025 | if (con->workspace->output != output) { | 1033 | struct sway_output *output = |
1026 | container_floating_move_to_center(con); | 1034 | container_floating_find_output(con); |
1035 | if (con->workspace->output != output) { | ||
1036 | container_floating_move_to_center(con); | ||
1037 | } | ||
1027 | } | 1038 | } |
1028 | } | 1039 | } |
1029 | } else { | 1040 | } else { |
@@ -1040,6 +1051,17 @@ void container_fullscreen_disable(struct sway_container *con) { | |||
1040 | con->fullscreen_mode = FULLSCREEN_NONE; | 1051 | con->fullscreen_mode = FULLSCREEN_NONE; |
1041 | container_end_mouse_operation(con); | 1052 | container_end_mouse_operation(con); |
1042 | ipc_event_window(con, "fullscreen_mode"); | 1053 | ipc_event_window(con, "fullscreen_mode"); |
1054 | |||
1055 | if (con->scratchpad) { | ||
1056 | struct sway_seat *seat; | ||
1057 | wl_list_for_each(seat, &server.input->seats, link) { | ||
1058 | struct sway_container *focus = seat_get_focused_container(seat); | ||
1059 | if (focus == con || container_has_ancestor(focus, con)) { | ||
1060 | seat_set_focus(seat, | ||
1061 | seat_get_focus_inactive(seat, &root->node)); | ||
1062 | } | ||
1063 | } | ||
1064 | } | ||
1043 | } | 1065 | } |
1044 | 1066 | ||
1045 | void container_set_fullscreen(struct sway_container *con, | 1067 | void container_set_fullscreen(struct sway_container *con, |
@@ -1056,7 +1078,7 @@ void container_set_fullscreen(struct sway_container *con, | |||
1056 | if (root->fullscreen_global) { | 1078 | if (root->fullscreen_global) { |
1057 | container_fullscreen_disable(root->fullscreen_global); | 1079 | container_fullscreen_disable(root->fullscreen_global); |
1058 | } | 1080 | } |
1059 | if (con->workspace->fullscreen) { | 1081 | if (con->workspace && con->workspace->fullscreen) { |
1060 | container_fullscreen_disable(con->workspace->fullscreen); | 1082 | container_fullscreen_disable(con->workspace->fullscreen); |
1061 | } | 1083 | } |
1062 | container_fullscreen_workspace(con); | 1084 | container_fullscreen_workspace(con); |
@@ -1171,6 +1193,11 @@ void container_add_gaps(struct sway_container *c) { | |||
1171 | c->current_gaps.bottom > 0 || c->current_gaps.left > 0) { | 1193 | c->current_gaps.bottom > 0 || c->current_gaps.left > 0) { |
1172 | return; | 1194 | return; |
1173 | } | 1195 | } |
1196 | // Fullscreen global scratchpad containers cannot have gaps | ||
1197 | struct sway_workspace *ws = c->workspace; | ||
1198 | if (!ws) { | ||
1199 | return; | ||
1200 | } | ||
1174 | // Linear containers don't have gaps because it'd create double gaps | 1201 | // Linear containers don't have gaps because it'd create double gaps |
1175 | if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) { | 1202 | if (!c->view && c->layout != L_TABBED && c->layout != L_STACKED) { |
1176 | return; | 1203 | return; |
@@ -1199,8 +1226,6 @@ void container_add_gaps(struct sway_container *c) { | |||
1199 | } | 1226 | } |
1200 | } | 1227 | } |
1201 | 1228 | ||
1202 | struct sway_workspace *ws = c->workspace; | ||
1203 | |||
1204 | c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; | 1229 | c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0; |
1205 | c->current_gaps.right = ws->gaps_inner; | 1230 | c->current_gaps.right = ws->gaps_inner; |
1206 | c->current_gaps.bottom = ws->gaps_inner; | 1231 | c->current_gaps.bottom = ws->gaps_inner; |
@@ -1308,6 +1333,10 @@ void container_add_child(struct sway_container *parent, | |||
1308 | child->parent = parent; | 1333 | child->parent = parent; |
1309 | child->workspace = parent->workspace; | 1334 | child->workspace = parent->workspace; |
1310 | container_for_each_child(child, set_workspace, NULL); | 1335 | container_for_each_child(child, set_workspace, NULL); |
1336 | bool fullscreen = child->fullscreen_mode != FULLSCREEN_NONE || | ||
1337 | parent->fullscreen_mode != FULLSCREEN_NONE; | ||
1338 | set_fullscreen_iterator(child, &fullscreen); | ||
1339 | container_for_each_child(child, set_fullscreen_iterator, &fullscreen); | ||
1311 | container_handle_fullscreen_reparent(child); | 1340 | container_handle_fullscreen_reparent(child); |
1312 | container_update_representation(parent); | 1341 | container_update_representation(parent); |
1313 | node_set_dirty(&child->node); | 1342 | node_set_dirty(&child->node); |
@@ -1347,8 +1376,31 @@ void container_detach(struct sway_container *child) { | |||
1347 | 1376 | ||
1348 | void container_replace(struct sway_container *container, | 1377 | void container_replace(struct sway_container *container, |
1349 | struct sway_container *replacement) { | 1378 | struct sway_container *replacement) { |
1379 | enum sway_fullscreen_mode fullscreen = container->fullscreen_mode; | ||
1380 | bool scratchpad = container->scratchpad; | ||
1381 | if (fullscreen != FULLSCREEN_NONE) { | ||
1382 | container_fullscreen_disable(container); | ||
1383 | } | ||
1384 | if (scratchpad) { | ||
1385 | root_scratchpad_show(container); | ||
1386 | root_scratchpad_remove_container(container); | ||
1387 | } | ||
1350 | container_add_sibling(container, replacement, 1); | 1388 | container_add_sibling(container, replacement, 1); |
1351 | container_detach(container); | 1389 | container_detach(container); |
1390 | if (scratchpad) { | ||
1391 | root_scratchpad_add_container(replacement); | ||
1392 | } | ||
1393 | switch (fullscreen) { | ||
1394 | case FULLSCREEN_WORKSPACE: | ||
1395 | container_fullscreen_workspace(replacement); | ||
1396 | break; | ||
1397 | case FULLSCREEN_GLOBAL: | ||
1398 | container_fullscreen_global(replacement); | ||
1399 | break; | ||
1400 | case FULLSCREEN_NONE: | ||
1401 | // noop | ||
1402 | break; | ||
1403 | } | ||
1352 | } | 1404 | } |
1353 | 1405 | ||
1354 | struct sway_container *container_split(struct sway_container *child, | 1406 | struct sway_container *container_split(struct sway_container *child, |
@@ -1369,7 +1421,11 @@ struct sway_container *container_split(struct sway_container *child, | |||
1369 | 1421 | ||
1370 | if (set_focus) { | 1422 | if (set_focus) { |
1371 | seat_set_raw_focus(seat, &cont->node); | 1423 | seat_set_raw_focus(seat, &cont->node); |
1372 | seat_set_raw_focus(seat, &child->node); | 1424 | if (cont->fullscreen_mode == FULLSCREEN_GLOBAL) { |
1425 | seat_set_focus(seat, &child->node); | ||
1426 | } else { | ||
1427 | seat_set_raw_focus(seat, &child->node); | ||
1428 | } | ||
1373 | } | 1429 | } |
1374 | 1430 | ||
1375 | return cont; | 1431 | return cont; |
@@ -1529,7 +1585,7 @@ void container_raise_floating(struct sway_container *con) { | |||
1529 | while (floater->parent) { | 1585 | while (floater->parent) { |
1530 | floater = floater->parent; | 1586 | floater = floater->parent; |
1531 | } | 1587 | } |
1532 | if (container_is_floating(floater)) { | 1588 | if (container_is_floating(floater) && floater->workspace) { |
1533 | list_move_to_end(floater->workspace->floating, floater); | 1589 | list_move_to_end(floater->workspace->floating, floater); |
1534 | node_set_dirty(&floater->workspace->node); | 1590 | node_set_dirty(&floater->workspace->node); |
1535 | } | 1591 | } |
diff --git a/sway/tree/node.c b/sway/tree/node.c index dcab1c9b..ffa7f2cc 100644 --- a/sway/tree/node.c +++ b/sway/tree/node.c | |||
@@ -142,11 +142,19 @@ list_t *node_get_children(struct sway_node *node) { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) { | 144 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) { |
145 | if (ancestor->type == N_ROOT && node->type == N_CONTAINER && | ||
146 | node->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
147 | return true; | ||
148 | } | ||
145 | struct sway_node *parent = node_get_parent(node); | 149 | struct sway_node *parent = node_get_parent(node); |
146 | while (parent) { | 150 | while (parent) { |
147 | if (parent == ancestor) { | 151 | if (parent == ancestor) { |
148 | return true; | 152 | return true; |
149 | } | 153 | } |
154 | if (ancestor->type == N_ROOT && parent->type == N_CONTAINER && | ||
155 | parent->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
156 | return true; | ||
157 | } | ||
150 | parent = node_get_parent(parent); | 158 | parent = node_get_parent(parent); |
151 | } | 159 | } |
152 | return false; | 160 | return false; |
diff --git a/sway/tree/root.c b/sway/tree/root.c index a9d306a4..1dabc287 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -62,6 +62,11 @@ void root_scratchpad_add_container(struct sway_container *con) { | |||
62 | struct sway_container *parent = con->parent; | 62 | struct sway_container *parent = con->parent; |
63 | struct sway_workspace *workspace = con->workspace; | 63 | struct sway_workspace *workspace = con->workspace; |
64 | 64 | ||
65 | // Clear the fullscreen mode when sending to the scratchpad | ||
66 | if (con->fullscreen_mode != FULLSCREEN_NONE) { | ||
67 | container_fullscreen_disable(con); | ||
68 | } | ||
69 | |||
65 | // When a tiled window is sent to scratchpad, center and resize it. | 70 | // When a tiled window is sent to scratchpad, center and resize it. |
66 | if (!container_is_floating(con)) { | 71 | if (!container_is_floating(con)) { |
67 | container_set_floating(con, true); | 72 | container_set_floating(con, true); |
@@ -143,6 +148,15 @@ void root_scratchpad_hide(struct sway_container *con) { | |||
143 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); | 148 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); |
144 | struct sway_workspace *ws = con->workspace; | 149 | struct sway_workspace *ws = con->workspace; |
145 | 150 | ||
151 | if (con->fullscreen_mode == FULLSCREEN_GLOBAL && !con->workspace) { | ||
152 | // If the container was made fullscreen global while in the scratchpad, | ||
153 | // it should be shown until fullscreen has been disabled | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | if (con->fullscreen_mode != FULLSCREEN_NONE) { | ||
158 | container_fullscreen_disable(con); | ||
159 | } | ||
146 | container_detach(con); | 160 | container_detach(con); |
147 | arrange_workspace(ws); | 161 | arrange_workspace(ws); |
148 | if (&con->node == focus || node_has_ancestor(focus, &con->node)) { | 162 | if (&con->node == focus || node_has_ancestor(focus, &con->node)) { |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 2c8839f5..c241b2b3 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -197,10 +197,11 @@ static bool gaps_to_edge(struct sway_view *view) { | |||
197 | 197 | ||
198 | void view_autoconfigure(struct sway_view *view) { | 198 | void view_autoconfigure(struct sway_view *view) { |
199 | struct sway_container *con = view->container; | 199 | struct sway_container *con = view->container; |
200 | if (container_is_scratchpad_hidden(con)) { | 200 | if (container_is_scratchpad_hidden(con) && |
201 | con->fullscreen_mode != FULLSCREEN_GLOBAL) { | ||
201 | return; | 202 | return; |
202 | } | 203 | } |
203 | struct sway_output *output = con->workspace->output; | 204 | struct sway_output *output = con->workspace ? con->workspace->output : NULL; |
204 | 205 | ||
205 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { | 206 | if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { |
206 | con->content_x = output->lx; | 207 | con->content_x = output->lx; |
@@ -226,19 +227,21 @@ void view_autoconfigure(struct sway_view *view) { | |||
226 | 227 | ||
227 | con->border_top = con->border_bottom = true; | 228 | con->border_top = con->border_bottom = true; |
228 | con->border_left = con->border_right = true; | 229 | con->border_left = con->border_right = true; |
229 | if (config->hide_edge_borders == E_BOTH | 230 | if (ws) { |
230 | || config->hide_edge_borders == E_VERTICAL | 231 | if (config->hide_edge_borders == E_BOTH |
231 | || (smart && !other_views && no_gaps)) { | 232 | || config->hide_edge_borders == E_VERTICAL |
232 | con->border_left = con->x - con->current_gaps.left != ws->x; | 233 | || (smart && !other_views && no_gaps)) { |
233 | int right_x = con->x + con->width + con->current_gaps.right; | 234 | con->border_left = con->x - con->current_gaps.left != ws->x; |
234 | con->border_right = right_x != ws->x + ws->width; | 235 | int right_x = con->x + con->width + con->current_gaps.right; |
235 | } | 236 | con->border_right = right_x != ws->x + ws->width; |
236 | if (config->hide_edge_borders == E_BOTH | 237 | } |
237 | || config->hide_edge_borders == E_HORIZONTAL | 238 | if (config->hide_edge_borders == E_BOTH |
238 | || (smart && !other_views && no_gaps)) { | 239 | || config->hide_edge_borders == E_HORIZONTAL |
239 | con->border_top = con->y - con->current_gaps.top != ws->y; | 240 | || (smart && !other_views && no_gaps)) { |
240 | int bottom_y = con->y + con->height + con->current_gaps.bottom; | 241 | con->border_top = con->y - con->current_gaps.top != ws->y; |
241 | con->border_bottom = bottom_y != ws->y + ws->height; | 242 | int bottom_y = con->y + con->height + con->current_gaps.bottom; |
243 | con->border_bottom = bottom_y != ws->y + ws->height; | ||
244 | } | ||
242 | } | 245 | } |
243 | 246 | ||
244 | double y_offset = 0; | 247 | double y_offset = 0; |
@@ -247,7 +250,8 @@ void view_autoconfigure(struct sway_view *view) { | |||
247 | // title area. We have to offset the surface y by the height of the title, | 250 | // title area. We have to offset the surface y by the height of the title, |
248 | // bar, and disable any top border because we'll always have the title bar. | 251 | // bar, and disable any top border because we'll always have the title bar. |
249 | list_t *siblings = container_get_siblings(con); | 252 | list_t *siblings = container_get_siblings(con); |
250 | bool show_titlebar = siblings->length > 1 || !config->hide_lone_tab; | 253 | bool show_titlebar = (siblings && siblings->length > 1) |
254 | || !config->hide_lone_tab; | ||
251 | if (show_titlebar && !container_is_floating(con)) { | 255 | if (show_titlebar && !container_is_floating(con)) { |
252 | enum sway_container_layout layout = container_parent_layout(con); | 256 | enum sway_container_layout layout = container_parent_layout(con); |
253 | if (layout == L_TABBED) { | 257 | if (layout == L_TABBED) { |
@@ -538,6 +542,10 @@ static bool should_focus(struct sway_view *view) { | |||
538 | struct sway_workspace *prev_ws = seat_get_focused_workspace(seat); | 542 | struct sway_workspace *prev_ws = seat_get_focused_workspace(seat); |
539 | struct sway_workspace *map_ws = view->container->workspace; | 543 | struct sway_workspace *map_ws = view->container->workspace; |
540 | 544 | ||
545 | if (view->container->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
546 | return true; | ||
547 | } | ||
548 | |||
541 | // Views can only take focus if they are mapped into the active workspace | 549 | // Views can only take focus if they are mapped into the active workspace |
542 | if (prev_ws != map_ws) { | 550 | if (prev_ws != map_ws) { |
543 | return false; | 551 | return false; |
@@ -581,7 +589,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
581 | } | 589 | } |
582 | 590 | ||
583 | struct sway_seat *seat = input_manager_current_seat(); | 591 | struct sway_seat *seat = input_manager_current_seat(); |
584 | struct sway_node *node = seat_get_focus_inactive(seat, &ws->node); | 592 | struct sway_node *node = ws ? seat_get_focus_inactive(seat, &ws->node) |
593 | : seat_get_focus_inactive(seat, &root->node); | ||
585 | struct sway_container *target_sibling = node->type == N_CONTAINER ? | 594 | struct sway_container *target_sibling = node->type == N_CONTAINER ? |
586 | node->sway_container : NULL; | 595 | node->sway_container : NULL; |
587 | 596 | ||
@@ -589,12 +598,13 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
589 | // launch it as a tiled view in the root of the workspace instead. | 598 | // launch it as a tiled view in the root of the workspace instead. |
590 | if (target_sibling && container_is_floating(target_sibling)) { | 599 | if (target_sibling && container_is_floating(target_sibling)) { |
591 | target_sibling = NULL; | 600 | target_sibling = NULL; |
601 | ws = seat_get_last_known_workspace(seat); | ||
592 | } | 602 | } |
593 | 603 | ||
594 | view->container = container_create(view); | 604 | view->container = container_create(view); |
595 | if (target_sibling) { | 605 | if (target_sibling) { |
596 | container_add_sibling(target_sibling, view->container, 1); | 606 | container_add_sibling(target_sibling, view->container, 1); |
597 | } else { | 607 | } else if (ws) { |
598 | workspace_add_tiling(ws, view->container); | 608 | workspace_add_tiling(ws, view->container); |
599 | } | 609 | } |
600 | ipc_event_window(view->container, "new"); | 610 | ipc_event_window(view->container, "new"); |
@@ -1032,8 +1042,18 @@ bool view_is_visible(struct sway_view *view) { | |||
1032 | return false; | 1042 | return false; |
1033 | } | 1043 | } |
1034 | struct sway_workspace *workspace = view->container->workspace; | 1044 | struct sway_workspace *workspace = view->container->workspace; |
1035 | if (!workspace) { | 1045 | if (!workspace && view->container->fullscreen_mode != FULLSCREEN_GLOBAL) { |
1036 | return false; | 1046 | bool fs_global_descendant = false; |
1047 | struct sway_container *parent = view->container->parent; | ||
1048 | while (parent) { | ||
1049 | if (parent->fullscreen_mode == FULLSCREEN_GLOBAL) { | ||
1050 | fs_global_descendant = true; | ||
1051 | } | ||
1052 | parent = parent->parent; | ||
1053 | } | ||
1054 | if (!fs_global_descendant) { | ||
1055 | return false; | ||
1056 | } | ||
1037 | } | 1057 | } |
1038 | // Determine if view is nested inside a floating container which is sticky | 1058 | // Determine if view is nested inside a floating container which is sticky |
1039 | struct sway_container *floater = view->container; | 1059 | struct sway_container *floater = view->container; |
@@ -1041,7 +1061,7 @@ bool view_is_visible(struct sway_view *view) { | |||
1041 | floater = floater->parent; | 1061 | floater = floater->parent; |
1042 | } | 1062 | } |
1043 | bool is_sticky = container_is_floating(floater) && floater->is_sticky; | 1063 | bool is_sticky = container_is_floating(floater) && floater->is_sticky; |
1044 | if (!is_sticky && !workspace_is_visible(workspace)) { | 1064 | if (!is_sticky && workspace && !workspace_is_visible(workspace)) { |
1045 | return false; | 1065 | return false; |
1046 | } | 1066 | } |
1047 | // Check view isn't in a tabbed or stacked container on an inactive tab | 1067 | // Check view isn't in a tabbed or stacked container on an inactive tab |