summaryrefslogtreecommitdiff
path: root/desktop-shell
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2023-07-12 11:03:21 +0100
committerMarius Vlad <marius.vlad@collabora.com>2023-08-11 14:10:45 +0300
commit73050c358d55bf56cf5d0efcffb903618a3fd93c (patch)
tree9cd70c5f967fb6f26f156511717b5c5d8bf64150 /desktop-shell
parentf17581fdd2e086cb6213a40802a2193506e7a0c2 (diff)
desktop-shell: Don't open-code animate_focus_change()
It already does what we want, so just use it when we're losing focus. Signed-off-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'desktop-shell')
-rw-r--r--desktop-shell/shell.c78
1 files changed, 36 insertions, 42 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 80369004..8aacdd17 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -679,6 +679,39 @@ focus_animation_done(struct weston_view_animation *animation, void *data)
}
static void
+animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
+ struct weston_view *from, struct weston_view *to)
+{
+ struct weston_view *front = ws->fsurf_front->curtain->view;
+ struct weston_view *back = ws->fsurf_back->curtain->view;
+ if ((from && from == to) || shell->focus_animation_type == ANIMATION_NONE)
+ return;
+
+ if (ws->focus_animation) {
+ weston_view_animation_destroy(ws->focus_animation);
+ ws->focus_animation = NULL;
+ }
+
+ if (to) {
+ 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);
+
+ ws->focus_animation =
+ weston_stable_fade_run(front, 0.0, back, 0.4,
+ focus_animation_done, ws);
+ } else {
+ 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);
+ }
+}
+
+static void
focus_state_destroy(struct focus_state *state)
{
wl_list_remove(&state->seat_destroy_listener.link);
@@ -736,14 +769,9 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data)
activate(state->shell, next, state->seat,
WESTON_ACTIVATE_FLAG_CONFIGURE);
} else {
- if (state->shell->focus_animation_type == ANIMATION_DIM_LAYER) {
- if (state->ws->focus_animation)
- weston_view_animation_destroy(state->ws->focus_animation);
-
- state->ws->focus_animation = weston_fade_run(
- state->ws->fsurf_front->curtain->view,
- state->ws->fsurf_front->curtain->view->alpha, 0.0, 300,
- focus_animation_done, state->ws);
+ if (state->shell->focus_animation_type != ANIMATION_NONE) {
+ animate_focus_change(state->shell, state->ws,
+ get_default_view(main_surface), NULL);
}
wl_list_remove(&state->link);
@@ -864,40 +892,6 @@ drop_focus_state(struct desktop_shell *shell, struct workspace *ws,
}
static void
-animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
- struct weston_view *from, struct weston_view *to)
-{
- struct weston_view *front = ws->fsurf_front->curtain->view;
- struct weston_view *back = ws->fsurf_back->curtain->view;
-
- if ((from && from == to) || shell->focus_animation_type == ANIMATION_NONE)
- return;
-
- if (ws->focus_animation) {
- weston_view_animation_destroy(ws->focus_animation);
- ws->focus_animation = NULL;
- }
-
- if (to) {
- 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);
-
- ws->focus_animation =
- weston_stable_fade_run(front, 0.0, back, 0.4,
- focus_animation_done, ws);
- } else {
- 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);
- }
-}
-
-static void
desktop_shell_destroy_layer(struct weston_layer *layer);
static void