diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2013-11-19 11:37:11 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-11-19 11:49:20 -0800 |
commit | b482dbd7eb3033e12115047967cbff07ef6e2a96 (patch) | |
tree | cc7590de7e1259d4a1c1e4b7eb3d02422298b1bd /src/animation.c | |
parent | dd8b88d102fa13c92a26253e52a2d5f6b8e0216c (diff) | |
download | weston-b482dbd7eb3033e12115047967cbff07ef6e2a96.tar.gz |
animation, shell: add kbd focus change animation
When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.
When the keyboard focus changes, the change in dimming is animated.
The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).
There is a new weston.ini option "focus-animation", that defaults to
none, and can be set to "dim-layer" to enable the focus change
animation.
[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
[pochu: rebased, ported to weston_view]
Diffstat (limited to 'src/animation.c')
-rw-r--r-- | src/animation.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/animation.c b/src/animation.c index c71b5069..8739f194 100644 --- a/src/animation.c +++ b/src/animation.c @@ -127,9 +127,10 @@ struct weston_view_animation { weston_view_animation_frame_func_t reset; weston_view_animation_done_func_t done; void *data; + void *private; }; -static void +WL_EXPORT void weston_view_animation_destroy(struct weston_view_animation *animation) { wl_list_remove(&animation->animation.link); @@ -185,7 +186,8 @@ weston_view_animation_run(struct weston_view *view, weston_view_animation_frame_func_t frame, weston_view_animation_frame_func_t reset, weston_view_animation_done_func_t done, - void *data) + void *data, + void *private) { struct weston_view_animation *animation; @@ -200,6 +202,7 @@ weston_view_animation_run(struct weston_view *view, animation->data = data; animation->start = start; animation->stop = stop; + animation->private = private; weston_matrix_init(&animation->transform.matrix); wl_list_insert(&view->geometry.transformation_list, &animation->transform.link); @@ -257,7 +260,7 @@ weston_zoom_run(struct weston_view *view, float start, float stop, zoom = weston_view_animation_run(view, start, stop, zoom_frame, reset_alpha, - done, data); + done, data, NULL); weston_spring_init(&zoom->spring, 300.0, start, stop); zoom->spring.friction = 1400; @@ -286,7 +289,7 @@ weston_fade_run(struct weston_view *view, fade = weston_view_animation_run(view, 0, end, fade_frame, reset_alpha, - done, data); + done, data, NULL); weston_spring_init(&fade->spring, k, start, end); @@ -305,6 +308,46 @@ weston_fade_update(struct weston_view_animation *fade, float target) } static void +stable_fade_frame(struct weston_view_animation *animation) +{ + struct weston_view *back_view; + + if (animation->spring.current > 0.999) + animation->view->alpha = 1; + else if (animation->spring.current < 0.001 ) + animation->view->alpha = 0; + else + animation->view->alpha = animation->spring.current; + + back_view = (struct weston_view *) animation->private; + back_view->alpha = + (animation->spring.target - animation->view->alpha) / + (1.0 - animation->view->alpha); + weston_view_geometry_dirty(back_view); +} + +WL_EXPORT struct weston_view_animation * +weston_stable_fade_run(struct weston_view *front_view, float start, + struct weston_view *back_view, float end, + weston_view_animation_done_func_t done, void *data) +{ + struct weston_view_animation *fade; + + fade = weston_view_animation_run(front_view, 0, 0, + stable_fade_frame, NULL, + done, data, back_view); + + + weston_spring_init(&fade->spring, 400, start, end); + fade->spring.friction = 1150; + + front_view->alpha = start; + back_view->alpha = end; + + return fade; +} + +static void slide_frame(struct weston_view_animation *animation) { float scale; @@ -324,7 +367,7 @@ weston_slide_run(struct weston_view *view, float start, float stop, animation = weston_view_animation_run(view, start, stop, slide_frame, NULL, done, - data); + data, NULL); if (!animation) return NULL; |