Skip to content
Commits on Source (11)
......@@ -103,8 +103,8 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
&ipsurf->view->layer_link);
weston_view_geometry_dirty(ipsurf->view);
weston_view_update_transform(ipsurf->view);
ipsurf->surface->is_mapped = true;
ipsurf->view->is_mapped = true;
weston_surface_map(ipsurf->surface);
weston_surface_damage(ipsurf->surface);
if (ipsurf->anim)
......
......@@ -2124,7 +2124,7 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
surface_subsurfaces_boundingbox(surface, &surf_x, &surf_y,
&surf_width, &surf_height);
if (surface->buffer_ref.buffer)
if (weston_surface_has_content(surface))
center_on_output(shsurf->view, shsurf->fullscreen_output);
}
......@@ -2454,6 +2454,8 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
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,
......@@ -2501,7 +2503,6 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
if (!weston_surface_is_mapped(surface)) {
map(shell, shsurf, sx, sy);
surface->is_mapped = true;
/* as we need to survive the weston_surface destruction we'll
* need to take another reference */
if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
......@@ -2914,7 +2915,7 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x,
}
weston_view_set_position(ev, ev->output->x + x, ev->output->y + y);
ev->surface->is_mapped = true;
weston_surface_map(ev->surface);
ev->is_mapped = true;
if (wl_list_empty(&ev->layer_link.link)) {
......@@ -3136,7 +3137,7 @@ lock_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
weston_layer_entry_insert(&shell->lock_layer.view_list,
&view->layer_link);
weston_view_update_transform(view);
surface->is_mapped = true;
weston_surface_map(surface);
view->is_mapped = true;
shell_fade(shell, FADE_IN);
}
......
......@@ -327,7 +327,6 @@ fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
fsout->curtain = create_curtain(shell->compositor, fsout,
output->x, output->y,
output->width, output->height);
fsout->curtain->view->surface->is_mapped = true;
fsout->curtain->view->is_mapped = true;
weston_layer_entry_insert(&shell->layer.view_list,
&fsout->curtain->view->layer_link);
......
......@@ -1311,6 +1311,10 @@ struct weston_compositor {
struct weston_log_scope *libseat_debug;
struct content_protection *content_protection;
/* One-time warning about a view appearing in the layer list when it
* or its surface are not mapped. */
bool warned_about_unmapped_surface_or_view;
};
struct weston_buffer {
......@@ -1928,6 +1932,9 @@ weston_surface_attach_solid(struct weston_surface *surface,
void
weston_buffer_destroy_solid(struct weston_buffer_reference *buffer_ref);
bool
weston_surface_has_content(struct weston_surface *surface);
void
weston_view_destroy(struct weston_view *view);
......@@ -1968,6 +1975,9 @@ weston_view_damage_below(struct weston_view *view);
void
weston_view_unmap(struct weston_view *view);
void
weston_surface_map(struct weston_surface *surface);
void
weston_surface_unmap(struct weston_surface *surface);
......
......@@ -835,7 +835,7 @@ build_view_list(struct ivi_layout *layout)
weston_layer_entry_insert(&layout->layout_layer.view_list,
&ivi_view->view->layer_link);
ivi_view->ivisurf->surface->is_mapped = true;
weston_surface_map(ivi_view->ivisurf->surface);
ivi_view->view->is_mapped = true;
}
}
......
......@@ -523,7 +523,6 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput)
&shoutput->curtain->view->layer_link);
shoutput->curtain->view->is_mapped = true;
shoutput->curtain->view->surface->is_mapped = true;
shoutput->curtain->view->surface->output = output;
weston_view_set_output(shoutput->curtain->view, output);
}
......@@ -799,7 +798,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
struct kiosk_shell_seat *kiosk_seat;
shsurf->view->is_mapped = true;
surface->is_mapped = true;
weston_surface_map(surface);
kiosk_seat = get_kiosk_shell_seat(seat);
if (seat && kiosk_seat)
......
......@@ -645,11 +645,11 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(toplevel->base.desktop_surface);
if (!wsurface->buffer_ref.buffer && !toplevel->added) {
if (!weston_surface_has_content(wsurface) && !toplevel->added) {
weston_desktop_xdg_toplevel_ensure_added(toplevel);
return;
}
if (!wsurface->buffer_ref.buffer)
if (!weston_surface_has_content(wsurface))
return;
struct weston_geometry geometry =
......@@ -841,6 +841,14 @@ weston_desktop_xdg_popup_committed(struct weston_desktop_xdg_popup *popup)
popup->committed = true;
weston_desktop_xdg_popup_update_position(popup->base.desktop_surface,
popup);
if (!weston_surface_is_mapped(wsurface) &&
weston_surface_has_content(wsurface)) {
weston_surface_map(wsurface);
} else if (weston_surface_is_mapped(wsurface) &&
!weston_surface_has_content(wsurface)) {
weston_surface_unmap(wsurface);
}
}
static void
......@@ -1209,7 +1217,7 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
struct weston_surface *wsurface =
weston_desktop_surface_get_surface (dsurface);
if (wsurface->buffer_ref.buffer && !surface->configured) {
if (weston_surface_has_content(wsurface) && !surface->configured) {
wl_resource_post_error(surface->resource,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface has never been configured");
......@@ -1397,7 +1405,7 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct wl_client *wl_client,
if (surface->resource == NULL)
return;
if (wsurface->buffer_ref.buffer != NULL) {
if (weston_surface_has_content(wsurface)) {
wl_resource_post_error(surface->resource,
ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface must not have a buffer at creation");
......
......@@ -693,11 +693,11 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(toplevel->base.desktop_surface);
if (!wsurface->buffer_ref.buffer && !toplevel->added) {
if (!weston_surface_has_content(wsurface) && !toplevel->added) {
weston_desktop_xdg_toplevel_ensure_added(toplevel);
return;
}
if (!wsurface->buffer_ref.buffer)
if (!weston_surface_has_content(wsurface))
return;
struct weston_geometry geometry =
......@@ -962,6 +962,14 @@ weston_desktop_xdg_popup_committed(struct weston_desktop_xdg_popup *popup)
popup->committed = true;
weston_desktop_xdg_popup_update_position(popup->base.desktop_surface,
popup);
if (!weston_surface_is_mapped(wsurface) &&
weston_surface_has_content(wsurface)) {
weston_surface_map(wsurface);
} else if (weston_surface_is_mapped(wsurface) &&
!weston_surface_has_content(wsurface)) {
weston_surface_unmap(wsurface);
}
}
static void
......@@ -1351,7 +1359,7 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
struct weston_surface *wsurface =
weston_desktop_surface_get_surface (dsurface);
if (wsurface->buffer_ref.buffer && !surface->configured) {
if (weston_surface_has_content(wsurface) && !surface->configured) {
wl_resource_post_error(surface->resource,
XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface has never been configured");
......@@ -1518,7 +1526,7 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct wl_client *wl_client,
return;
}
if (wsurface->buffer_ref.buffer != NULL) {
if (weston_surface_has_content(wsurface)) {
wl_resource_post_error(resource,
XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER,
"xdg_surface must not have a buffer at creation");
......
......@@ -122,7 +122,7 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
weston_layer_entry_insert(&surface->xwayland->layer.view_list,
&surface->view->layer_link);
surface->view->is_mapped = true;
wsurface->is_mapped = true;
weston_surface_map(wsurface);
}
surface->state = state;
......
......@@ -2121,7 +2121,7 @@ weston_surface_calculate_size_from_buffer(struct weston_surface *surface)
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
if (!surface->buffer_ref.buffer) {
if (!weston_surface_has_content(surface)) {
surface->width_from_buffer = 0;
surface->height_from_buffer = 0;
return;
......@@ -2261,6 +2261,12 @@ weston_view_unmap(struct weston_view *view)
}
}
WL_EXPORT void
weston_surface_map(struct weston_surface *surface)
{
surface->is_mapped = true;
}
WL_EXPORT void
weston_surface_unmap(struct weston_surface *surface)
{
......@@ -2985,6 +2991,26 @@ view_list_add(struct weston_compositor *compositor,
struct weston_subsurface *sub;
weston_view_update_transform(view);
/* It is possible for a view to appear in the layer list even though
* the view or the surface is unmapped. This is erroneous but difficult
* to fix. */
if (!weston_surface_is_mapped(view->surface) ||
!weston_view_is_mapped(view) ||
!weston_surface_has_content(view->surface)) {
if (!compositor->warned_about_unmapped_surface_or_view) {
weston_log("Detected an unmapped surface or view in "
"the layer list, which should not occur.\n");
compositor->warned_about_unmapped_surface_or_view = true;
}
pnode = weston_view_find_paint_node(view, output);
if (pnode)
weston_paint_node_destroy(pnode);
return;
}
pnode = view_ensure_paint_node(view, output);
if (wl_list_empty(&view->surface->subsurface_list)) {
......@@ -3609,6 +3635,16 @@ weston_compositor_schedule_repaint(struct weston_compositor *compositor)
weston_output_schedule_repaint(output);
}
/**
* Returns true if a surface has a buffer attached to it and thus valid
* content available.
*/
WL_EXPORT bool
weston_surface_has_content(struct weston_surface *surface)
{
return !!surface->buffer_ref.buffer;
}
static void
surface_destroy(struct wl_client *client, struct wl_resource *resource)
{
......@@ -4519,22 +4555,21 @@ subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy)
* mapped, parent is not in a visible layer, so this sub-surface
* will not be drawn either.
*/
if (!weston_surface_is_mapped(surface)) {
surface->is_mapped = surface->buffer_ref.buffer != NULL;
/* Cannot call weston_view_update_transform(),
* because that would call it also for the parent surface,
* which might not be mapped yet. That would lead to
* inconsistent state, where the window could never be
* mapped.
*
* Instead just force the is_mapped flag on, to make
* weston_surface_is_mapped() return true, so that when the
* parent surface does get mapped, this one will get
* included, too. See view_list_add().
*/
}
if (!weston_surface_is_mapped(surface) &&
weston_surface_has_content(surface)) {
weston_surface_map(surface);
}
/* Cannot call weston_view_update_transform() here, because that would
* call it also for the parent surface, which might not be mapped yet.
* That would lead to inconsistent state, where the window could never
* be mapped.
*
* Instead just force the child surface to appear mapped, to make
* weston_surface_is_mapped() return true, so that when the parent
* surface does get mapped, this one will get included, too. See
* view_list_add().
*/
}
static struct weston_subsurface *
......
......@@ -420,8 +420,7 @@ drag_surface_configure(struct weston_drag *drag,
assert((pointer != NULL && touch == NULL) ||
(pointer == NULL && touch != NULL));
/* XXX: Why are we checking for a valid buffer here too ... ? */
if (!weston_surface_is_mapped(es) && es->buffer_ref.buffer) {
if (!weston_surface_is_mapped(es) && weston_surface_has_content(es)) {
if (pointer && pointer->sprite &&
weston_view_is_mapped(pointer->sprite))
list = &pointer->sprite->layer_link;
......@@ -432,7 +431,7 @@ drag_surface_configure(struct weston_drag *drag,
weston_layer_entry_insert(list, &drag->icon->layer_link);
weston_view_update_transform(drag->icon);
pixman_region32_clear(&es->pending.input);
es->is_mapped = true;
weston_surface_map(es);
drag->icon->is_mapped = true;
}
......
......@@ -2697,7 +2697,7 @@ pointer_cursor_surface_committed(struct weston_surface *es,
weston_layer_entry_insert(&es->compositor->cursor_layer.view_list,
&pointer->sprite->layer_link);
weston_view_update_transform(pointer->sprite);
es->is_mapped = true;
weston_surface_map(es);
pointer->sprite->is_mapped = true;
}
}
......
......@@ -206,7 +206,7 @@ map_calibrator(struct weston_touch_calibrator *calibrator)
calibrator->view->is_mapped = true;
calibrator->surface->output = calibrator->output;
calibrator->surface->is_mapped = true;
weston_surface_map(calibrator->surface);
weston_output_schedule_repaint(calibrator->output);
......
......@@ -185,6 +185,8 @@ weston_curtain_create(struct weston_compositor *compositor,
pixman_region32_init(&surface->input);
}
weston_surface_map(surface);
weston_view_set_position(view, params->x, params->y);
return curtain;
......
......@@ -92,7 +92,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
if (weston_surface_is_mapped(surface))
return;
surface->is_mapped = true;
weston_surface_map(surface);
weston_layer_entry_insert(&dts->layer.view_list, &dts->view->layer_link);
weston_view_set_position(dts->view, 0 - geometry.x, 0 - geometry.y);
weston_view_update_transform(dts->view);
......@@ -225,6 +225,7 @@ wet_shell_init(struct weston_compositor *ec,
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;
dts->desktop = weston_desktop_create(ec, &shell_desktop_api, dts);
if (dts->desktop == NULL)
......
......@@ -164,7 +164,7 @@ test_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
weston_view_update_transform(test_surface->view);
test_surface->surface->is_mapped = true;
weston_surface_map(test_surface->surface);
test_surface->view->is_mapped = true;
}
......