-/* TODO: Replace this with some callback or similar, to have
- * adjustable window management policy.
- */
-void
-ivi_reflow_outputs(struct ivi_compositor *ivi)
-{
- struct ivi_surface *surface;
- struct ivi_output *output;
- int i = 0;
-
- if (wl_list_empty(&ivi->outputs))
- return;
-
- output = wl_container_of(ivi->outputs.next, output, link);
-
- wl_list_for_each(surface, &ivi->surfaces, link) {
- struct weston_desktop_surface *dsurface = surface->dsurface;
-
- int32_t w = output->area.width / 4;
- int32_t h = output->area.height / 2;
- int32_t x = output->output->x + output->area.x + w * (i % 4);
- int32_t y = output->output->y + output->area.y + h * (i / 4);
-
- if (surface->old_geom.width == -1) {
- weston_desktop_surface_set_size(dsurface, w, h);
- continue;
- } else {
- ivi_layout_set_mapped(surface);
- ivi_layout_set_position(surface, x, y, w, h);
- }
-
- if (++i == 8) {
- if (output->link.next == &ivi->outputs)
- break;
-
- output = wl_container_of(output->link.next,
- output, link);
- i = 0;
- }
- }
-
- ivi_layout_commit(ivi);
-}
-
-void
-ivi_layout_set_mapped(struct ivi_surface *surface)
-{
- surface->pending.flags |= IVI_SURFACE_PROP_MAP;
-}
-
-void
-ivi_layout_set_position(struct ivi_surface *surface,
- int32_t x, int32_t y,
- int32_t width, int32_t height)
-{
- surface->pending.flags |= IVI_SURFACE_PROP_POSITION;
- surface->pending.x = x;
- surface->pending.y = y;
- surface->pending.width = width;
- surface->pending.height = height;
-}
-
-void
-ivi_layout_commit(struct ivi_compositor *ivi)
-{
- struct ivi_surface *surface;
-
- wl_list_for_each(surface, &ivi->surfaces, link) {
- struct weston_desktop_surface *dsurface = surface->dsurface;
- struct weston_surface *wsurface =
- weston_desktop_surface_get_surface(dsurface);
- struct weston_geometry geom;
- struct weston_view *view;
-
- /*
- * TODO: Hoist view into ivi_struct. It doesn't need ot be part
- * of the tagged union.
- */
- switch (surface->role) {
- case IVI_SURFACE_ROLE_DESKTOP:
- view = surface->desktop.view;
- break;
- case IVI_SURFACE_ROLE_BACKGROUND:
- view = surface->bg.view;
- break;
- case IVI_SURFACE_ROLE_PANEL:
- view = surface->panel.view;
- break;
- default:
- continue;
- }
-
- if (surface->pending.flags & IVI_SURFACE_PROP_MAP) {
- view = weston_desktop_surface_create_view(dsurface);
- wsurface->is_mapped = true;
-
- surface->desktop.view = view;
- weston_layer_entry_insert(&ivi->normal.view_list,
- &view->layer_link);
- weston_view_update_transform(view);
- weston_view_set_mask_infinite(view);
- weston_view_schedule_repaint(view);
- }
-
- geom = weston_desktop_surface_get_geometry(dsurface);
-
- if (surface->pending.flags & IVI_SURFACE_PROP_POSITION) {
- weston_desktop_surface_set_size(dsurface,
- surface->pending.width,
- surface->pending.height);
- weston_view_set_position(view,
- surface->pending.x - geom.x,
- surface->pending.y - geom.y);
- }
-
- surface->pending.flags = 0;
- }
-}
-