[PATCH weston 1/2] desktop-shell: Do not use animation code when no outputs are present

Armin Krezović krezovic.armin at gmail.com
Fri Aug 5 13:32:05 UTC 2016


It leads to crash when trying to select an output that drives
the animation.

Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
---
 desktop-shell/exposay.c     | 10 +++++++++
 desktop-shell/input-panel.c |  9 ++++----
 desktop-shell/shell.c       | 55 ++++++++++++++++++++++++++-------------------
 3 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index b11a7f7..1841554 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -113,6 +113,11 @@ exposay_animate_in_done(struct weston_view_animation *animation, void *data)
 static void
 exposay_animate_in(struct exposay_surface *esurface)
 {
+	struct weston_compositor *ec = esurface->shell->compositor;
+
+	if (wl_list_empty(&ec->output_list))
+		return;
+
 	exposay_in_flight_inc(esurface->shell);
 
 	weston_move_scale_run(esurface->view,
@@ -136,6 +141,11 @@ exposay_animate_out_done(struct weston_view_animation *animation, void *data)
 static void
 exposay_animate_out(struct exposay_surface *esurface)
 {
+	struct weston_compositor *ec = esurface->shell->compositor;
+
+	if (wl_list_empty(&ec->output_list))
+		return;
+
 	exposay_in_flight_inc(esurface->shell);
 
 	/* Remove the static transformation set up by
diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
index 2e18e28..a3ab05f 100644
--- a/desktop-shell/input-panel.c
+++ b/desktop-shell/input-panel.c
@@ -93,10 +93,11 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
 	if (ipsurf->anim)
 		weston_view_animation_destroy(ipsurf->anim);
 
-	ipsurf->anim =
-		weston_slide_run(ipsurf->view,
-				 ipsurf->surface->height * 0.9, 0,
-				 input_panel_slide_done, ipsurf);
+	if (!wl_list_empty(&shell->compositor->output_list))
+		ipsurf->anim =
+			weston_slide_run(ipsurf->view,
+					 ipsurf->surface->height * 0.9, 0,
+					 input_panel_slide_done, ipsurf);
 }
 
 static void
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 64979cd..8e975f0 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -850,10 +850,11 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data)
 			if (state->ws->focus_animation)
 				weston_view_animation_destroy(state->ws->focus_animation);
 
-			state->ws->focus_animation = weston_fade_run(
-				state->ws->fsurf_front->view,
-				state->ws->fsurf_front->view->alpha, 0.0, 300,
-				focus_animation_done, state->ws);
+			if (!wl_list_empty(&shell->compositor->output_list))
+				state->ws->focus_animation = weston_fade_run(
+					state->ws->fsurf_front->view,
+					state->ws->fsurf_front->view->alpha, 0.0, 300,
+					focus_animation_done, state->ws);
 		}
 
 		wl_list_remove(&state->link);
@@ -1030,24 +1031,29 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
 					  &ws->fsurf_front->view->layer_link);
 
 	if (focus_surface_created) {
-		ws->focus_animation = weston_fade_run(
-			ws->fsurf_front->view,
-			ws->fsurf_front->view->alpha, 0.4, 300,
-			focus_animation_done, ws);
+		if (!wl_list_empty(&shell->compositor->output_list))
+			ws->focus_animation = weston_fade_run(
+				ws->fsurf_front->view,
+				ws->fsurf_front->view->alpha, 0.4, 300,
+				focus_animation_done, ws);
 	} else if (from) {
 		weston_layer_entry_insert(&from->layer_link,
 					  &ws->fsurf_back->view->layer_link);
-		ws->focus_animation = weston_stable_fade_run(
-			ws->fsurf_front->view, 0.0,
-			ws->fsurf_back->view, 0.4,
-			focus_animation_done, ws);
+
+		if (!wl_list_empty(&shell->compositor->output_list))
+			ws->focus_animation = weston_stable_fade_run(
+				ws->fsurf_front->view, 0.0,
+				ws->fsurf_back->view, 0.4,
+				focus_animation_done, ws);
 	} else if (to) {
 		weston_layer_entry_insert(&ws->layer.view_list,
 					  &ws->fsurf_back->view->layer_link);
-		ws->focus_animation = weston_stable_fade_run(
-			ws->fsurf_front->view, 0.0,
-			ws->fsurf_back->view, 0.4,
-			focus_animation_done, ws);
+
+		if (!wl_list_empty(&shell->compositor->output_list))
+			ws->focus_animation = weston_stable_fade_run(
+				ws->fsurf_front->view, 0.0,
+				ws->fsurf_back->view, 0.4,
+				focus_animation_done, ws);
 	}
 }
 
@@ -3670,8 +3676,9 @@ handle_resource_destroy(struct wl_listener *listener, void *data)
 	pixman_region32_fini(&shsurf->surface->input);
 	pixman_region32_init(&shsurf->surface->input);
 	if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) {
-		weston_fade_run(shsurf->view, 1.0, 0.0, 300.0,
-				fade_out_done, shsurf);
+		if (!wl_list_empty(&shsurf->surface->compositor->output_list))
+			weston_fade_run(shsurf->view, 1.0, 0.0, 300.0,
+					fade_out_done, shsurf);
 	} else {
 		weston_surface_destroy(shsurf->surface);
 	}
@@ -5440,10 +5447,11 @@ shell_fade(struct desktop_shell *shell, enum fade_type type)
 	} else if (shell->fade.animation) {
 		weston_fade_update(shell->fade.animation, tint);
 	} else {
-		shell->fade.animation =
-			weston_fade_run(shell->fade.view,
-					1.0 - tint, tint, 300.0,
-					shell_fade_done, shell);
+		if (!wl_list_empty(&shell->compositor->output_list))
+			shell->fade.animation =
+				weston_fade_run(shell->fade.view,
+						1.0 - tint, tint, 300.0,
+						shell_fade_done, shell);
 	}
 }
 
@@ -5733,7 +5741,8 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
 	}
 
 	if (shsurf->type == SHELL_SURFACE_TOPLEVEL &&
-	    !shsurf->state.maximized && !shsurf->state.fullscreen)
+	    !shsurf->state.maximized && !shsurf->state.fullscreen &&
+	    !wl_list_empty(&shsurf->surface->compositor->output_list))
 	{
 		switch (shell->win_animation_type) {
 		case ANIMATION_FADE:
-- 
2.9.2



More information about the wayland-devel mailing list