diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 92 |
1 files changed, 74 insertions, 18 deletions
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 | } |