diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 237e1a35..6ebf2653 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1130,3 +1130,90 @@ void container_end_mouse_operation(struct sway_container *container) { | |||
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | |||
1134 | static void set_fullscreen_iterator(struct sway_container *con, void *data) { | ||
1135 | if (con->type != C_VIEW) { | ||
1136 | return; | ||
1137 | } | ||
1138 | if (con->sway_view->impl->set_fullscreen) { | ||
1139 | bool *enable = data; | ||
1140 | con->sway_view->impl->set_fullscreen(con->sway_view, *enable); | ||
1141 | } | ||
1142 | } | ||
1143 | |||
1144 | void container_set_fullscreen(struct sway_container *container, bool enable) { | ||
1145 | if (container->is_fullscreen == enable) { | ||
1146 | return; | ||
1147 | } | ||
1148 | |||
1149 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); | ||
1150 | if (enable && workspace->sway_workspace->fullscreen) { | ||
1151 | container_set_fullscreen(workspace->sway_workspace->fullscreen, false); | ||
1152 | } | ||
1153 | |||
1154 | container_for_each_descendant_dfs(container, | ||
1155 | set_fullscreen_iterator, &enable); | ||
1156 | |||
1157 | container->is_fullscreen = enable; | ||
1158 | |||
1159 | if (enable) { | ||
1160 | workspace->sway_workspace->fullscreen = container; | ||
1161 | container->saved_x = container->x; | ||
1162 | container->saved_y = container->y; | ||
1163 | container->saved_width = container->width; | ||
1164 | container->saved_height = container->height; | ||
1165 | |||
1166 | struct sway_seat *seat; | ||
1167 | struct sway_container *focus, *focus_ws; | ||
1168 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
1169 | focus = seat_get_focus(seat); | ||
1170 | if (focus) { | ||
1171 | focus_ws = focus; | ||
1172 | if (focus_ws->type != C_WORKSPACE) { | ||
1173 | focus_ws = container_parent(focus_ws, C_WORKSPACE); | ||
1174 | } | ||
1175 | if (focus_ws == workspace) { | ||
1176 | seat_set_focus(seat, container); | ||
1177 | } | ||
1178 | } | ||
1179 | } | ||
1180 | } else { | ||
1181 | workspace->sway_workspace->fullscreen = NULL; | ||
1182 | if (container_is_floating(container)) { | ||
1183 | container->x = container->saved_x; | ||
1184 | container->y = container->saved_y; | ||
1185 | container->width = container->saved_width; | ||
1186 | container->height = container->saved_height; | ||
1187 | } else { | ||
1188 | container->width = container->saved_width; | ||
1189 | container->height = container->saved_height; | ||
1190 | } | ||
1191 | } | ||
1192 | |||
1193 | container_end_mouse_operation(container); | ||
1194 | |||
1195 | ipc_event_window(container, "fullscreen_mode"); | ||
1196 | } | ||
1197 | |||
1198 | bool container_is_fullscreen_or_child(struct sway_container *container) { | ||
1199 | do { | ||
1200 | if (container->is_fullscreen) { | ||
1201 | return true; | ||
1202 | } | ||
1203 | container = container->parent; | ||
1204 | } while (container && container->type != C_WORKSPACE); | ||
1205 | |||
1206 | return false; | ||
1207 | } | ||
1208 | |||
1209 | struct sway_container *container_wrap_children(struct sway_container *parent) { | ||
1210 | struct sway_container *middle = container_create(C_CONTAINER); | ||
1211 | middle->layout = parent->layout; | ||
1212 | while (parent->children->length) { | ||
1213 | struct sway_container *child = parent->children->items[0]; | ||
1214 | container_remove_child(child); | ||
1215 | container_add_child(middle, child); | ||
1216 | } | ||
1217 | container_add_child(parent, middle); | ||
1218 | return middle; | ||
1219 | } | ||