mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 07:38:22 +02:00
view: Add weston_view_set_alpha()
Does what it says on the box: sets the view's alpha, also inflicting damage where required. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
f39b1e9fbd
commit
7d2c5e0c33
4 changed files with 51 additions and 38 deletions
|
|
@ -815,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 {
|
||||
|
|
@ -3436,6 +3436,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);
|
||||
|
|
@ -3446,15 +3447,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
|
||||
|
|
@ -3996,8 +3995,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) {
|
||||
|
|
@ -4386,16 +4385,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)
|
||||
|
|
@ -4409,11 +4403,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
|
||||
|
|
@ -4436,8 +4430,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)) {
|
||||
|
|
|
|||
|
|
@ -2033,6 +2033,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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -3596,6 +3596,17 @@ idle_repaint(void *data)
|
|||
weston_output_schedule_repaint_reset(output);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_view_set_alpha(struct weston_view *view, float alpha)
|
||||
{
|
||||
view->alpha = alpha;
|
||||
weston_surface_damage(view->surface);
|
||||
if (alpha != 1.0 || !view->surface->is_opaque)
|
||||
weston_view_damage_below(view);
|
||||
weston_view_geometry_dirty_internal(view);
|
||||
weston_view_update_transform(view);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_layer_entry_insert(struct weston_layer_entry *list,
|
||||
struct weston_layer_entry *entry)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue