diff options
author | Daniel Stone <daniels@collabora.com> | 2023-07-12 10:55:21 +0100 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2023-08-11 14:10:45 +0300 |
commit | f04e1ec9ab369047f07020dd9d04ab9222bc81e0 (patch) | |
tree | 00bbe770485b36eab616f4fe48bfa31fb9beb605 /desktop-shell/shell.c | |
parent | 42334db41e0ce96a2d0cf3431846cbc0c62ab574 (diff) |
desktop-shell: Clean up animate_focus_change()
Now that we're not allocating surfaces on demand, animate_focus_change()
becomes a lot more straightforward and common, and using some local
variables sure does cut out a lot of typing.
Knowing that both from and to cannot both be NULL (because we check if
from == to), we can change the juggling to be extremely simple:
calculate where we need the curtains to be in the view list, put them
there, and set up the fade.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'desktop-shell/shell.c')
-rw-r--r-- | desktop-shell/shell.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 177cf0e1..989980bb 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -854,12 +854,11 @@ static void animate_focus_change(struct desktop_shell *shell, struct workspace *ws, struct weston_view *from, struct weston_view *to) { - /* FIXME: Only support dim animation using two layers */ - if (from == to || shell->focus_animation_type != ANIMATION_DIM_LAYER) - return; + struct weston_view *front = ws->fsurf_front->curtain->view; + struct weston_view *back = ws->fsurf_back->curtain->view; - weston_view_move_to_layer(ws->fsurf_front->curtain->view, NULL); - weston_view_move_to_layer(ws->fsurf_back->curtain->view, NULL); + if ((from && from == to) || shell->focus_animation_type == ANIMATION_NONE) + return; if (ws->focus_animation) { weston_view_animation_destroy(ws->focus_animation); @@ -867,32 +866,21 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws, } if (to) { - weston_view_move_to_layer(ws->fsurf_front->curtain->view, - &to->layer_link); - } else { - weston_view_move_to_layer(ws->fsurf_front->curtain->view, - &ws->layer.view_list); - } + weston_view_move_to_layer(front, &to->layer_link); + if (from) + weston_view_move_to_layer(back, &from->layer_link); + else + weston_view_move_to_layer(back, &ws->layer.view_list); - if (from) { - weston_view_move_to_layer(ws->fsurf_back->curtain->view, - &from->layer_link); - ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->curtain->view, 0.0, - ws->fsurf_back->curtain->view, 0.4, - focus_animation_done, ws); - } else if (to) { - weston_view_move_to_layer(ws->fsurf_back->curtain->view, - &ws->layer.view_list); - ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->curtain->view, 0.0, - ws->fsurf_back->curtain->view, 0.4, - focus_animation_done, ws); + ws->focus_animation = + weston_stable_fade_run(front, 0.0, back, 0.4, + focus_animation_done, ws); } else { - ws->focus_animation = weston_fade_run( - ws->fsurf_front->curtain->view, - ws->fsurf_front->curtain->view->alpha, 0.0, 300, - focus_animation_done, ws); + weston_view_move_to_layer(front, &ws->layer.view_list); + weston_view_move_to_layer(back, NULL); + ws->focus_animation = + weston_fade_run(front, front->alpha, 0.0, 300, + focus_animation_done, ws); } } |