Skip to content
Commits on Source (31)
......@@ -123,7 +123,6 @@ struct shell_surface {
} rotation;
struct {
struct weston_transform transform; /* matrix from x, y */
struct weston_curtain *black_view;
} fullscreen;
......@@ -816,14 +815,14 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
ws->fsurf_front = create_focus_surface(shell->compositor, output);
if (ws->fsurf_front == NULL)
return;
ws->fsurf_front->curtain->view->alpha = 0.0;
weston_view_set_alpha(ws->fsurf_front->curtain->view, 0.0);
ws->fsurf_back = create_focus_surface(shell->compositor, output);
if (ws->fsurf_back == NULL) {
focus_surface_destroy(ws->fsurf_front);
return;
}
ws->fsurf_back->curtain->view->alpha = 0.0;
weston_view_set_alpha(ws->fsurf_back->curtain->view, 0.0);
focus_surface_created = true;
} else {
......@@ -1764,10 +1763,6 @@ weston_view_set_initial_position(struct weston_view *view,
static void
unset_fullscreen(struct shell_surface *shsurf)
{
/* Unset the fullscreen output, driver configuration and transforms. */
wl_list_remove(&shsurf->fullscreen.transform.link);
wl_list_init(&shsurf->fullscreen.transform.link);
if (shsurf->fullscreen.black_view)
weston_shell_utils_curtain_destroy(shsurf->fullscreen.black_view);
shsurf->fullscreen.black_view = NULL;
......@@ -1782,8 +1777,9 @@ unset_fullscreen(struct shell_surface *shsurf)
shsurf->orientation);
if (shsurf->saved_rotation_valid) {
wl_list_insert(&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform.link);
weston_view_add_transform(shsurf->view,
&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform);
shsurf->saved_rotation_valid = false;
}
}
......@@ -1808,8 +1804,9 @@ unset_maximized(struct shell_surface *shsurf)
shsurf->orientation);
if (shsurf->saved_rotation_valid) {
wl_list_insert(&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform.link);
weston_view_add_transform(shsurf->view,
&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform);
shsurf->saved_rotation_valid = false;
}
}
......@@ -2184,7 +2181,6 @@ desktop_surface_added(struct weston_desktop_surface *desktop_surface,
shsurf->desktop_surface = desktop_surface;
shsurf->view = view;
shsurf->fullscreen.black_view = NULL;
wl_list_init(&shsurf->fullscreen.transform.link);
shell_surface_set_output(
shsurf, weston_shell_utils_get_default_output(shsurf->shell->compositor));
......@@ -3442,6 +3438,7 @@ surface_opacity_binding(struct weston_pointer *pointer,
struct shell_surface *shsurf;
struct weston_surface *focus = pointer->focus->surface;
struct weston_surface *surface;
float alpha;
/* XXX: broken for windows containing sub-surfaces */
surface = weston_surface_get_main_surface(focus);
......@@ -3452,15 +3449,13 @@ surface_opacity_binding(struct weston_pointer *pointer,
if (!shsurf)
return;
shsurf->view->alpha -= event->value * step;
alpha = shsurf->view->alpha - (event->value * step);
if (shsurf->view->alpha > 1.0)
shsurf->view->alpha = 1.0;
if (shsurf->view->alpha < step)
shsurf->view->alpha = step;
weston_view_geometry_dirty(shsurf->view);
weston_surface_damage(surface);
weston_view_set_alpha(shsurf->view, alpha);
}
static void
......@@ -3498,8 +3493,6 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
dy = pointer->pos.c.y - rotate->center.y;
r = sqrtf(dx * dx + dy * dy);
wl_list_remove(&shsurf->rotation.transform.link);
if (r > 20.0f) {
struct weston_matrix *matrix =
&shsurf->rotation.transform.matrix;
......@@ -3513,17 +3506,16 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
weston_matrix_multiply(matrix, &rotate->rotation);
weston_matrix_translate(matrix, cx, cy, 0.0f);
wl_list_insert(
&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform.link);
weston_view_add_transform(shsurf->view,
&shsurf->view->geometry.transformation_list,
&shsurf->rotation.transform);
} else {
wl_list_init(&shsurf->rotation.transform.link);
weston_view_remove_transform(shsurf->view,
&shsurf->rotation.transform);
weston_matrix_init(&shsurf->rotation.rotation);
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;
......@@ -4002,8 +3994,8 @@ shell_fade(struct desktop_shell *shell, enum fade_type type)
if (!shell_output->fade.curtain)
continue;
shell_output->fade.curtain->view->alpha = 1.0 - tint;
weston_view_update_transform(shell_output->fade.curtain->view);
weston_view_set_alpha(shell_output->fade.curtain->view,
1.0 - tint);
}
if (shell_output->fade.curtain->view->output == NULL) {
......@@ -4392,16 +4384,11 @@ switcher_next(struct switcher *switcher)
if (prev == switcher->current)
next = view;
prev = view;
view->alpha = 0.25;
weston_view_geometry_dirty(view);
weston_surface_damage(view->surface);
weston_view_set_alpha(view, 0.25);
}
if (is_black_surface_view(view, NULL)) {
view->alpha = 0.25;
weston_view_geometry_dirty(view);
weston_surface_damage(view->surface);
}
if (is_black_surface_view(view, NULL))
weston_view_set_alpha(view, 0.25);
}
if (next == NULL)
......@@ -4415,11 +4402,11 @@ switcher_next(struct switcher *switcher)
switcher->current = next;
wl_list_for_each(view, &next->surface->views, surface_link)
view->alpha = 1.0;
weston_view_set_alpha(view, 1.0);
shsurf = get_shell_surface(switcher->current->surface);
if (shsurf && weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
shsurf->fullscreen.black_view->view->alpha = 1.0;
weston_view_set_alpha(shsurf->fullscreen.black_view->view, 1.0);
}
static void
......@@ -4442,8 +4429,7 @@ switcher_destroy(struct switcher *switcher)
if (is_focus_view(view))
continue;
view->alpha = 1.0;
weston_surface_damage(view->surface);
weston_view_set_alpha(view, 1.0);
}
if (switcher->current && get_shell_surface(switcher->current->surface)) {
......
......@@ -378,15 +378,16 @@ fs_output_scale_view(struct fs_output *fsout, float width, float height)
pos.c.x -= surf_x;
pos.c.y -= surf_y;
weston_view_set_position(view, pos);
weston_view_remove_transform(fsout->view, &fsout->transform);
} else {
matrix = &fsout->transform.matrix;
weston_matrix_init(matrix);
weston_matrix_scale(matrix, width / surf_width,
height / surf_height, 1);
wl_list_remove(&fsout->transform.link);
wl_list_insert(&fsout->view->geometry.transformation_list,
&fsout->transform.link);
weston_view_add_transform(fsout->view,
&fsout->view->geometry.transformation_list,
&fsout->transform);
pos.c.x += (output->width - width) / 2 - surf_x;
pos.c.y += (output->height - height) / 2 - surf_y;
......
......@@ -1417,6 +1417,8 @@ struct weston_compositor {
struct wl_list axis_binding_list;
struct wl_list debug_binding_list;
bool view_list_needs_rebuild;
uint32_t state;
struct wl_event_source *idle_source;
uint32_t idle_inhibit;
......@@ -1577,8 +1579,6 @@ struct weston_buffer_viewport {
*/
int32_t width, height;
} surface;
bool changed;
};
struct weston_buffer_release {
......@@ -1730,14 +1730,28 @@ struct weston_view {
};
enum weston_surface_status {
/** nothing has changed */
WESTON_SURFACE_CLEAN = 0,
/** a new buffer has been attached, but is like-for-like with the
* previous */
WESTON_SURFACE_DIRTY_BUFFER = 1 << 0,
/** surface has been resized */
WESTON_SURFACE_DIRTY_SIZE = 1 << 1,
/** x/y position has changed */
WESTON_SURFACE_DIRTY_POS = 1 << 2,
/** buffer parameters have changed in a way which impacts the
* processing pipeline, e.g. format/opacity */
WESTON_SURFACE_DIRTY_BUFFER_PARAMS = 1 << 3,
/** input region has changed */
WESTON_SURFACE_DIRTY_INPUT = 1 << 4,
/** subsurfaces have been added, removed, or restacked */
WESTON_SURFACE_DIRTY_SUBSURFACE_CONFIG = 1 << 5,
};
struct weston_surface_state {
enum weston_surface_status status;
/* wl_surface.attach */
bool newly_attached;
struct weston_buffer *buffer;
struct wl_listener buffer_destroy_listener;
......@@ -1999,6 +2013,15 @@ weston_view_update_transform(struct weston_view *view);
void
weston_view_geometry_dirty(struct weston_view *view);
void
weston_view_add_transform(struct weston_view *view,
struct wl_list *pos,
struct weston_transform *transform);
void
weston_view_remove_transform(struct weston_view *view,
struct weston_transform *transform);
struct weston_coord_global __attribute__ ((warn_unused_result))
weston_coord_surface_to_global(const struct weston_view *view,
struct weston_coord_surface coord);
......@@ -2019,6 +2042,9 @@ weston_view_activate_input(struct weston_view *view,
void
notify_modifiers(struct weston_seat *seat, uint32_t serial);
void
weston_view_set_alpha(struct weston_view *view, float alpha);
void
weston_view_move_to_layer(struct weston_view *view,
struct weston_layer_entry *layer);
......
......@@ -145,10 +145,9 @@ weston_view_animation_destroy(struct weston_view_animation *animation)
{
wl_list_remove(&animation->animation.link);
wl_list_remove(&animation->listener.link);
wl_list_remove(&animation->transform.link);
weston_view_remove_transform(animation->view, &animation->transform);
if (animation->reset)
animation->reset(animation);
weston_view_geometry_dirty(animation->view);
if (animation->done)
animation->done(animation, animation->data);
free(animation);
......@@ -189,8 +188,10 @@ weston_view_animation_frame(struct weston_animation *base,
if (animation->frame)
animation->frame(animation);
weston_view_geometry_dirty(animation->view);
weston_view_schedule_repaint(animation->view);
weston_view_add_transform(animation->view,
&animation->view->geometry.transformation_list,
&animation->transform);
weston_view_update_transform(animation->view);
/* The view's output_mask will be zero if its position is
* offscreen. Animations should always run but as they are also
......@@ -237,8 +238,7 @@ weston_view_animation_create(struct weston_view *view,
animation->private = private;
weston_matrix_init(&animation->transform.matrix);
wl_list_insert(&view->geometry.transformation_list,
&animation->transform.link);
wl_list_init(&animation->transform.link);
animation->animation.frame = weston_view_animation_frame;
......@@ -271,7 +271,8 @@ reset_alpha(struct weston_view_animation *animation)
{
struct weston_view *view = animation->view;
view->alpha = animation->stop;
weston_view_set_alpha(view, animation->stop);
weston_view_update_transform(view);
}
static void
......@@ -292,9 +293,7 @@ zoom_frame(struct weston_view_animation *animation)
0.5f * es->surface->width,
0.5f * es->surface->height, 0);
es->alpha = animation->spring.current;
if (es->alpha > 1.0)
es->alpha = 1.0;
weston_view_set_alpha(es, MIN(animation->spring.current, 1.0));
}
WL_EXPORT struct weston_view_animation *
......@@ -322,12 +321,16 @@ weston_zoom_run(struct weston_view *view, float start, float stop,
static void
fade_frame(struct weston_view_animation *animation)
{
float alpha;
if (animation->spring.current > 0.999)
animation->view->alpha = 1;
else if (animation->spring.current < 0.001 )
animation->view->alpha = 0;
alpha = 1.0;
else if (animation->spring.current < 0.001)
alpha = 0.0;
else
animation->view->alpha = animation->spring.current;
alpha = animation->spring.current;
weston_view_set_alpha(animation->view, alpha);
}
WL_EXPORT struct weston_view_animation *
......@@ -348,7 +351,8 @@ weston_fade_run(struct weston_view *view,
fade->spring.friction = 4000;
fade->spring.previous = start - (end - start) * 0.1;
view->alpha = start;
weston_view_set_alpha(view, start);
weston_view_update_transform(view);
weston_view_animation_run(fade);
......@@ -366,19 +370,21 @@ static void
stable_fade_frame(struct weston_view_animation *animation)
{
struct weston_view *back_view;
float alpha;
if (animation->spring.current > 0.999)
animation->view->alpha = 1;
else if (animation->spring.current < 0.001 )
animation->view->alpha = 0;
alpha = 1.0;
else if (animation->spring.current < 0.001)
alpha = 0.0;
else
animation->view->alpha = animation->spring.current;
alpha = animation->spring.current;
weston_view_set_alpha(animation->view, alpha);
back_view = (struct weston_view *) animation->private;
back_view->alpha =
(animation->spring.target - animation->view->alpha) /
alpha = (animation->spring.target - animation->view->alpha) /
(1.0 - animation->view->alpha);
weston_view_geometry_dirty(back_view);
weston_view_set_alpha(back_view, alpha);
}
WL_EXPORT struct weston_view_animation *
......@@ -398,8 +404,8 @@ weston_stable_fade_run(struct weston_view *front_view, float start,
weston_spring_init(&fade->spring, 400, start, end);
fade->spring.friction = 1150;
front_view->alpha = start;
back_view->alpha = end;
weston_view_set_alpha(front_view, start);
weston_view_set_alpha(back_view, end);
weston_view_animation_run(fade);
......
This diff is collapsed.
......@@ -123,6 +123,96 @@ surface_commit_color(struct client *client, struct wl_surface *surface,
return buf;
}
TEST(subsurface_recursive_unmap)
{
struct client *client;
struct wl_subcompositor *subco;
struct buffer *bufs[5] = { 0 };
struct wl_surface *surf[5] = { 0 };
struct wl_subsurface *sub[5] = { 0 };
struct rectangle clip = { 40, 40, 280, 200 };
int fail = 0;
unsigned i;
pixman_color_t red;
pixman_color_t blue;
pixman_color_t cyan;
pixman_color_t green;
color_rgb888(&red, 255, 0, 0);
color_rgb888(&blue, 0, 0, 255);
color_rgb888(&cyan, 0, 255, 255);
color_rgb888(&green, 0, 255, 0);
client = create_client_and_test_surface(100, 50, 100, 100);
assert(client);
subco = get_subcompositor(client);
/* move the pointer clearly away from our screenshooting area */
weston_test_move_pointer(client->test->weston_test, 0, 1, 0, 2, 30);
/* make the parent surface red */
surf[0] = client->surface->wl_surface;
client->surface->wl_surface = NULL; /* we stole it and destroy it */
bufs[0] = surface_commit_color(client, surf[0], &red, 100, 100);
/* sub[0] is not used */
fail += check_screen(client, "subsurface_z_order", 0, &clip, 0);
/* create a blue sub-surface above red */
surf[1] = wl_compositor_create_surface(client->wl_compositor);
sub[1] = wl_subcompositor_get_subsurface(subco, surf[1], surf[0]);
bufs[1] = surface_commit_color(client, surf[1], &blue, 100, 100);
wl_subsurface_set_position(sub[1], 20, 20);
wl_surface_commit(surf[0]);
fail += check_screen(client, "subsurface_z_order", 1, &clip, 1);
/* create a cyan sub-surface above blue */
surf[2] = wl_compositor_create_surface(client->wl_compositor);
sub[2] = wl_subcompositor_get_subsurface(subco, surf[2], surf[1]);
bufs[2] = surface_commit_color(client, surf[2], &cyan, 100, 100);
wl_subsurface_set_position(sub[2], 20, 20);
wl_surface_commit(surf[1]);
wl_surface_commit(surf[0]);
fail += check_screen(client, "subsurface_z_order", 2, &clip, 2);
/* create a green sub-surface above blue, sibling to cyan */
surf[3] = wl_compositor_create_surface(client->wl_compositor);
sub[3] = wl_subcompositor_get_subsurface(subco, surf[3], surf[1]);
bufs[3] = surface_commit_color(client, surf[3], &green, 100, 100);
wl_subsurface_set_position(sub[3], -40, 10);
wl_surface_commit(surf[1]);
wl_surface_commit(surf[0]);
fail += check_screen(client, "subsurface_z_order", 3, &clip, 3);
/* destroy blue, to immediately unmap blue + red + cyan */
wl_surface_destroy(surf[1]);
surf[1] = NULL;
fail += check_screen(client, "subsurface_z_order", 0, &clip, 0);
assert(fail == 0);
for (i = 0; i < ARRAY_LENGTH(sub); i++)
if (sub[i])
wl_subsurface_destroy(sub[i]);
for (i = 0; i < ARRAY_LENGTH(surf); i++)
if (surf[i])
wl_surface_destroy(surf[i]);
for (i = 0; i < ARRAY_LENGTH(bufs); i++)
if (bufs[i])
buffer_destroy(bufs[i]);
wl_subcompositor_destroy(subco);
client_destroy(client);
}
TEST(subsurface_z_order)
{
struct client *client;
......