1From 8950431969fd75d6c6aa349a0eed489fe999dfc8 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Wed, 1 Jun 2022 11:28:24 +0800
4Subject: [PATCH 68/93] desktop-shell: Delay locking when having pending
5 fade-out animations
6
7Avoid "unexpectedly large timestamp jump" warning when resuming with
8multi-head.
9
10Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
11---
12 desktop-shell/shell.c         | 14 +++++++++++++-
13 include/libweston/libweston.h |  1 +
14 2 files changed, 14 insertions(+), 1 deletion(-)
15
16diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
17index ff85ff7..2e88b99 100644
18--- a/desktop-shell/shell.c
19+++ b/desktop-shell/shell.c
20@@ -3580,18 +3580,24 @@ shell_fade_done_for_output(struct weston_view_animation *animation, void *data)
21 {
22 	struct shell_output *shell_output = data;
23 	struct desktop_shell *shell = shell_output->shell;
24+	struct weston_compositor *compositor = shell->compositor;
25+
26+	if (shell_output->fade.type == FADE_OUT)
27+		shell->compositor->pending_fade_out --;
28
29 	if (!shell_output->fade.curtain)
30 		return;
31
32 	shell_output->fade.animation = NULL;
33+
34 	switch (shell_output->fade.type) {
35 	case FADE_IN:
36 		weston_curtain_destroy(shell_output->fade.curtain);
37 		shell_output->fade.curtain = NULL;
38 		break;
39 	case FADE_OUT:
40-		lock(shell);
41+		if (!compositor->pending_fade_out)
42+			lock(shell);
43 		break;
44 	default:
45 		break;
46@@ -3705,6 +3711,9 @@ shell_fade(struct desktop_shell *shell, enum fade_type type)
47 		} else if (shell_output->fade.animation) {
48 			weston_fade_update(shell_output->fade.animation, tint);
49 		} else {
50+			if (type == FADE_OUT)
51+				shell->compositor->pending_fade_out ++;
52+
53 			shell_output->fade.animation =
54 				weston_fade_run(shell_output->fade.curtain->view,
55 						1.0 - tint, tint, 300.0,
56@@ -4371,6 +4380,9 @@ shell_output_destroy(struct shell_output *shell_output)
57 	if (shell_output->fade.animation) {
58 		weston_view_animation_destroy(shell_output->fade.animation);
59 		shell_output->fade.animation = NULL;
60+
61+		if (shell_output->fade.type == FADE_OUT)
62+			shell->compositor->pending_fade_out --;
63 	}
64
65 	if (shell_output->fade.curtain) {
66diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
67index bf8e20a..9d9c5c6 100644
68--- a/include/libweston/libweston.h
69+++ b/include/libweston/libweston.h
70@@ -1342,6 +1342,7 @@ struct weston_compositor {
71 	struct weston_output *prefer_output;
72
73 	bool warm_up;
74+	uint32_t pending_fade_out;
75 };
76
77 struct weston_solid_buffer_values {
78--
792.20.1
80
81