Skip to content
Commits on Source (21)
......@@ -212,10 +212,6 @@ struct tablet_tool_listener {
struct wl_listener removed_listener;
};
static struct weston_view *
shell_fade_create_fade_out_view(struct shell_surface *shsurf,
struct weston_surface *surface);
static struct desktop_shell *
shell_surface_get_shell(struct shell_surface *shsurf);
......@@ -598,6 +594,7 @@ create_focus_surface(struct weston_compositor *ec,
fsurf->curtain = weston_shell_utils_curtain_create(ec, &curtain_params);
weston_view_set_output(fsurf->curtain->view, output);
/* XXX: can't map view without a layer! */
fsurf->curtain->view->is_mapped = true;
return fsurf;
......@@ -1711,23 +1708,12 @@ shell_surface_update_child_surface_layers (struct shell_surface *shsurf)
static void
shell_surface_update_layer(struct shell_surface *shsurf)
{
struct weston_surface *surface =
weston_desktop_surface_get_surface(shsurf->desktop_surface);
struct weston_layer_entry *new_layer_link;
new_layer_link = shell_surface_calculate_layer_link(shsurf);
assert(new_layer_link);
if (new_layer_link == NULL)
return;
if (new_layer_link == &shsurf->view->layer_link)
return;
weston_view_geometry_dirty(shsurf->view);
weston_layer_entry_remove(&shsurf->view->layer_link);
weston_layer_entry_insert(new_layer_link, &shsurf->view->layer_link);
weston_view_geometry_dirty(shsurf->view);
weston_surface_damage(surface);
weston_view_move_to_layer(shsurf->view, new_layer_link);
shell_surface_update_child_surface_layers(shsurf);
}
......@@ -1941,12 +1927,7 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)
view = shsurf->fullscreen.black_view->view;
weston_view_set_output(view, output);
view->is_mapped = true;
weston_layer_entry_remove(&view->layer_link);
weston_layer_entry_insert(&shsurf->view->layer_link, &view->layer_link);
weston_view_geometry_dirty(view);
weston_surface_damage(surface);
weston_view_move_to_layer(view, &shsurf->view->layer_link);
shsurf->state.lowered = false;
}
......@@ -2148,7 +2129,7 @@ fade_out_done(struct weston_view_animation *animation, void *data)
loop = wl_display_get_event_loop(shsurf->shell->compositor->wl_display);
if (weston_view_is_mapped(shsurf->wview_anim_fade)) {
weston_view_unmap(shsurf->wview_anim_fade);
weston_view_move_to_layer(shsurf->wview_anim_fade, NULL);
wl_event_loop_add_idle(loop, fade_out_done_idle_cb, shsurf);
}
}
......@@ -2274,16 +2255,18 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
* migrated to a different output, so re-compute this
* as the animation requires having the same output as
* the view */
shsurf->wview_anim_fade = weston_view_create(surface);
weston_view_set_output(shsurf->wview_anim_fade,
shsurf->view->output);
pos = weston_view_get_pos_offset_global(shsurf->view);
weston_view_set_position(shsurf->wview_anim_fade, pos);
weston_layer_entry_insert(&shsurf->view->layer_link,
&shsurf->wview_anim_fade->layer_link);
weston_view_move_to_layer(shsurf->wview_anim_fade,
&shsurf->view->layer_link);
/* unmap the "original" view */
weston_view_unmap(shsurf->view);
/* unmap the "original" view, which is owned by
* libweston-desktop */
weston_view_move_to_layer(shsurf->view, NULL);
weston_fade_run(shsurf->wview_anim_fade, 1.0, 0.0, 300.0,
fade_out_done, shsurf);
......@@ -2352,18 +2335,17 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf)
weston_view_set_initial_position(shsurf->view, shell);
}
/* XXX: don't map without a buffer! */
weston_surface_map(surface);
/* Surface stacking order, see also activate(). */
shell_surface_update_layer(shsurf);
weston_view_update_transform(shsurf->view);
shsurf->view->is_mapped = true;
if (shsurf->state.maximized) {
surface->output = shsurf->output;
weston_view_set_output(shsurf->view, shsurf->output);
}
weston_surface_map(surface);
if (!shell->locked) {
wl_list_for_each(seat, &compositor->seat_list, link)
activate(shell, shsurf->view, seat,
......@@ -2426,8 +2408,6 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
shsurf->wsurface_anim_fade =
weston_surface_ref(surface);
shsurf->wview_anim_fade =
shell_fade_create_fade_out_view(shsurf, surface);
}
return;
......@@ -2882,13 +2862,9 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x,
pos.c.y += y;
weston_view_set_position(ev, pos);
weston_surface_map(ev->surface);
ev->is_mapped = true;
if (wl_list_empty(&ev->layer_link.link)) {
weston_layer_entry_insert(&layer->view_list, &ev->layer_link);
weston_view_geometry_dirty(ev);
weston_compositor_schedule_repaint(ev->surface->compositor);
}
if (wl_list_empty(&ev->layer_link.link))
weston_view_move_to_layer(ev, &layer->view_list);
}
......@@ -3106,17 +3082,14 @@ lock_surface_committed(struct weston_surface *surface,
if (surface->width == 0)
return;
if (weston_surface_is_mapped(surface))
return;
weston_surface_map(surface);
weston_view_move_to_layer(view, &shell->lock_layer.view_list);
weston_shell_utils_center_on_output(view,
weston_shell_utils_get_default_output(shell->compositor));
if (!weston_surface_is_mapped(surface)) {
weston_layer_entry_insert(&shell->lock_layer.view_list,
&view->layer_link);
weston_view_update_transform(view);
weston_surface_map(surface);
view->is_mapped = true;
shell_fade(shell, FADE_IN);
}
shell_fade(shell, FADE_IN);
}
static void
......@@ -3526,7 +3499,6 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
r = sqrtf(dx * dx + dy * dy);
wl_list_remove(&shsurf->rotation.transform.link);
weston_view_geometry_dirty(shsurf->view);
if (r > 20.0f) {
struct weston_matrix *matrix =
......@@ -3550,6 +3522,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
weston_matrix_init(&rotate->rotation);
}
weston_view_geometry_dirty(shsurf->view);
/* We need to adjust the position of the surface
* in case it was resized in a rotated state before */
cposx = shsurf->view->geometry.pos_offset.x + cx;
......@@ -3565,10 +3539,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
weston_view_set_position(shsurf->view, pos);
}
/* Repaint implies weston_view_update_transform(), which
* lazily applies the damage due to rotation update.
*/
weston_compositor_schedule_repaint(surface->compositor);
weston_view_update_transform(shsurf->view);
weston_surface_damage(shsurf->view->surface);
}
static void
......@@ -3718,17 +3690,11 @@ lower_fullscreen_layer(struct desktop_shell *shell,
* in the fullscreen layer. */
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface) &&
shsurf->fullscreen.black_view) {
/* Hide the black view */
weston_layer_entry_remove(&shsurf->fullscreen.black_view->view->layer_link);
wl_list_init(&shsurf->fullscreen.black_view->view->layer_link.link);
weston_view_damage_below(shsurf->fullscreen.black_view->view);
weston_view_move_to_layer(shsurf->fullscreen.black_view->view, NULL);
}
/* Lower the view to the workspace layer */
weston_layer_entry_remove(&view->layer_link);
weston_layer_entry_insert(&ws->layer.view_list, &view->layer_link);
weston_view_damage_below(view);
weston_surface_damage(view->surface);
weston_view_move_to_layer(view, &ws->layer.view_list);
shsurf->state.lowered = true;
}
......@@ -4003,39 +3969,11 @@ shell_fade_create_view_for_output(struct desktop_shell *shell,
assert(curtain);
weston_view_set_output(curtain->view, output);
curtain->view->is_mapped = true;
weston_layer_entry_insert(&compositor->fade_layer.view_list,
&curtain->view->layer_link);
weston_view_geometry_dirty(curtain->view);
weston_surface_damage(curtain->view->surface);
weston_view_move_to_layer(curtain->view, &compositor->fade_layer.view_list);
return curtain;
}
static struct weston_view *
shell_fade_create_fade_out_view(struct shell_surface *shsurf,
struct weston_surface *surface)
{
struct weston_view *view;
struct weston_output *woutput;
struct weston_coord_global pos;
view = weston_view_create(surface);
if (!view)
return NULL;
woutput = weston_shell_utils_get_focused_output(surface->compositor);
/* set the initial position and output just in case we happen to not
* move it around and just destroy it */
weston_view_set_output(view, woutput);
pos = weston_view_get_pos_offset_global(shsurf->view);
weston_view_set_position(view, pos);
view->is_mapped = true;
return view;
}
static void
shell_fade(struct desktop_shell *shell, enum fade_type type)
{
......
......@@ -616,15 +616,12 @@ fs_output_apply_pending(struct fs_output *fsout)
weston_log("no memory\n");
return;
}
fsout->view->is_mapped = true;
fsout->surface->is_mapped = true;
wl_signal_add(&fsout->surface->destroy_signal,
&fsout->surface_destroyed);
weston_layer_entry_insert(&fsout->shell->layer.view_list,
&fsout->view->layer_link);
weston_view_geometry_dirty(fsout->view);
weston_view_move_to_layer(fsout->view,
&fsout->shell->layer.view_list);
}
fs_output_clear_pending(fsout);
......
......@@ -1638,6 +1638,7 @@ struct weston_view {
struct weston_surface *surface;
struct wl_list surface_link;
struct wl_signal destroy_signal;
struct wl_signal map_signal;
struct wl_signal unmap_signal;
/* struct weston_paint_node::view_link */
......@@ -1883,6 +1884,13 @@ struct weston_surface {
void *committed_private;
int (*get_label)(struct weston_surface *surface, char *buf, size_t len);
/*
* Sent when the surface has been mapped and unmapped, respectively.
* The data argument is the weston_surface.
*/
struct wl_signal map_signal;
struct wl_signal unmap_signal;
/* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
* Contains also the parent itself as a dummy weston_subsurface,
* if the list is not empty.
......@@ -2011,6 +2019,10 @@ weston_view_activate_input(struct weston_view *view,
void
notify_modifiers(struct weston_seat *seat, uint32_t serial);
void
weston_view_move_to_layer(struct weston_view *view,
struct weston_layer_entry *layer);
void
weston_layer_entry_insert(struct weston_layer_entry *list,
struct weston_layer_entry *entry);
......
......@@ -392,11 +392,8 @@ kiosk_shell_surface_activate(struct kiosk_shell_surface *shsurf,
* (currently focused one) on a different output when activating
* a new one. */
if (!shsurf->parent && (shsurf->output == current_focus->output)) {
weston_layer_entry_remove(&current_focus->view->layer_link);
weston_layer_entry_insert(&shsurf->shell->inactive_layer.view_list,
&current_focus->view->layer_link);
weston_view_geometry_dirty(current_focus->view);
weston_surface_damage(current_focus->view->surface);
weston_view_move_to_layer(current_focus->view,
&shsurf->shell->inactive_layer.view_list);
}
}
......@@ -407,12 +404,8 @@ kiosk_shell_surface_activate(struct kiosk_shell_surface *shsurf,
/* removes it from the inactive_layer, on removal of a surface, and
* move it back to the normal layer */
weston_layer_entry_remove(&shsurf->view->layer_link);
weston_layer_entry_insert(&shsurf->shell->normal_layer.view_list,
&shsurf->view->layer_link);
weston_view_geometry_dirty(shsurf->view);
weston_view_update_transform(shsurf->view);
weston_surface_damage(shsurf->view->surface);
weston_view_move_to_layer(shsurf->view,
&shsurf->shell->normal_layer.view_list);
}
/*
......@@ -518,11 +511,10 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput)
weston_surface_set_role(shoutput->curtain->view->surface,
"kiosk-shell-background", NULL, 0);
weston_layer_entry_insert(&shell->background_layer.view_list,
&shoutput->curtain->view->layer_link);
shoutput->curtain->view->is_mapped = true;
shoutput->curtain->view->surface->output = output;
weston_view_move_to_layer(shoutput->curtain->view,
&shell->background_layer.view_list);
weston_view_set_output(shoutput->curtain->view, output);
}
......@@ -1026,13 +1018,8 @@ kiosk_shell_activate_view(struct kiosk_shell *shell,
* We don't do this for the parent top-level, since that would
* obscure all children.
*/
if (shsurf->parent) {
weston_layer_entry_remove(&view->layer_link);
weston_layer_entry_insert(&shell->normal_layer.view_list,
&view->layer_link);
weston_view_geometry_dirty(view);
weston_surface_damage(view->surface);
}
if (shsurf->parent)
weston_view_move_to_layer(view, &shell->normal_layer.view_list);
if (kiosk_seat)
kiosk_shell_surface_activate(shsurf, kiosk_seat, flags);
......
......@@ -476,6 +476,7 @@ weston_view_create(struct weston_surface *surface)
wl_list_insert(&surface->views, &view->surface_link);
wl_signal_init(&view->destroy_signal);
wl_signal_init(&view->map_signal);
wl_signal_init(&view->unmap_signal);
wl_list_init(&view->link);
wl_list_init(&view->layer_link.link);
......@@ -676,6 +677,8 @@ weston_surface_create(struct weston_compositor *compositor)
wl_signal_init(&surface->destroy_signal);
wl_signal_init(&surface->commit_signal);
wl_signal_init(&surface->map_signal);
wl_signal_init(&surface->unmap_signal);
surface->compositor = compositor;
surface->ref_count = 1;
......@@ -2122,6 +2125,7 @@ WL_EXPORT void
weston_surface_map(struct weston_surface *surface)
{
surface->is_mapped = true;
weston_signal_emit_mutable(&surface->map_signal, surface);
}
WL_EXPORT void
......@@ -2133,6 +2137,7 @@ weston_surface_unmap(struct weston_surface *surface)
wl_list_for_each(view, &surface->views, surface_link)
weston_view_unmap(view);
surface->output = NULL;
weston_signal_emit_mutable(&surface->unmap_signal, surface);
}
static void
......@@ -3512,6 +3517,47 @@ weston_layer_entry_insert(struct weston_layer_entry *list,
entry->layer = list->layer;
}
/** Move a weston_view to a layer
*
* This moves a view to a given point within a layer, identified by a
* weston_layer_entry.
*
* \param view View to move
* \param layer The target layer entry, or NULL to remove from the scene graph
*/
WL_EXPORT void
weston_view_move_to_layer(struct weston_view *view,
struct weston_layer_entry *layer)
{
bool was_mapped = view->is_mapped;
if (layer == &view->layer_link)
return;
/* Damage the view's old region, and remove it from the layer. */
if (weston_view_is_mapped(view)) {
weston_view_damage_below(view);
weston_view_geometry_dirty(view);
}
weston_layer_entry_remove(&view->layer_link);
if (!layer) {
weston_view_unmap(view);
return;
}
/* Add the view to the new layer and damage its new region. */
weston_layer_entry_insert(layer, &view->layer_link);
view->is_mapped = true;
weston_view_geometry_dirty(view);
weston_view_update_transform(view);
weston_surface_damage(view->surface);
if (!was_mapped)
weston_signal_emit_mutable(&view->map_signal, view);
}
WL_EXPORT void
weston_layer_entry_remove(struct weston_layer_entry *entry)
{
......
......@@ -442,24 +442,15 @@ static void
weston_desktop_view_propagate_layer(struct weston_desktop_view *view)
{
struct weston_desktop_view *child;
struct wl_list *link = &view->view->layer_link.link;
struct wl_list *parent_pos = &view->view->layer_link.link;
/* Move each child to the same layer, immediately in front of its
* parent. */
wl_list_for_each_reverse(child, &view->children_list, children_link) {
struct weston_layer_entry *prev =
wl_container_of(link->prev, prev, link);
if (prev == &child->view->layer_link)
continue;
child->view->is_mapped = true;
weston_view_damage_below(child->view);
weston_view_geometry_dirty(child->view);
weston_layer_entry_remove(&child->view->layer_link);
weston_layer_entry_insert(prev, &child->view->layer_link);
weston_view_geometry_dirty(child->view);
weston_surface_damage(child->view->surface);
weston_view_update_transform(child->view);
struct weston_layer_entry *child_pos =
wl_container_of(parent_pos->prev, child_pos, link);
weston_view_move_to_layer(child->view, child_pos);
weston_desktop_view_propagate_layer(child);
}
}
......
......@@ -95,13 +95,12 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
return;
weston_surface_map(surface);
weston_layer_entry_insert(&dts->layer.view_list, &dts->view->layer_link);
pos.c = weston_coord(0, 0);
pos.c.x -= geometry.x;
pos.c.y -= geometry.y;
weston_view_set_position(dts->view, pos);
weston_view_update_transform(dts->view);
dts->view->is_mapped = true;
weston_layer_entry_insert(&dts->layer.view_list, &dts->view->layer_link);
weston_view_move_to_layer(dts->view, &dts->layer.view_list);
}
static void
......@@ -253,10 +252,8 @@ wet_shell_init(struct weston_compositor *ec,
pos.c = weston_coord(0, 0);
weston_view_set_position(dts->background->view, pos);
weston_layer_entry_insert(&dts->background_layer.view_list,
&dts->background->view->layer_link);
weston_view_update_transform(dts->background->view);
dts->background->view->is_mapped = true;
weston_view_move_to_layer(dts->background->view,
&dts->background_layer.view_list);
dts->desktop = weston_desktop_create(ec, &shell_desktop_api, dts);
if (dts->desktop == NULL)
......