From 3dcceb506b427b42927c33fc44f23f5ce7bdd106 Mon Sep 17 00:00:00 2001 From: hujianwei Date: Sun, 6 Nov 2022 05:09:57 +0000 Subject: [PATCH] Fix subsurface commit behavior * subsurface.c (EarlyCommit): Clear pending_commit after merging cached state. * tests/subsurface_test.c (test_single_step): Add test that found this problem. --- subsurface.c | 13 +++++++++---- tests/subsurface_test.c | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/subsurface.c b/subsurface.c index 734410b..7e779be 100644 --- a/subsurface.c +++ b/subsurface.c @@ -592,10 +592,15 @@ EarlyCommit (Surface *surface, Role *role) return False; } else if (subsurface->pending_commit) - /* There is still pending state. Merge the state into the surface - first, before SubcompositorUpdate is called by - InternalCommit. */ - XLSurfaceMergeCachedState (surface); + { + /* There is still cached state. Merge the state into the + surface first, before SubcompositorUpdate is called by + InternalCommit. */ + XLSurfaceMergeCachedState (surface); + + /* As the state is merged, there is no more cached state. */ + subsurface->pending_commit = False; + } return True; } diff --git a/tests/subsurface_test.c b/tests/subsurface_test.c index 0e68d27..6d8c0dc 100644 --- a/tests/subsurface_test.c +++ b/tests/subsurface_test.c @@ -685,6 +685,24 @@ test_single_step (enum test_kind kind) WL_OUTPUT_TRANSFORM_90); wait_frame_callback (subsurfaces[8]->surface); sleep_or_verify (); + + /* Now, attach subsurface_1.png in subsurfaces[7]. Nothing + should be displayed. */ + wl_surface_attach (subsurfaces[7]->surface, subsurface_1_png, + 0, 0); + wl_surface_damage (subsurfaces[7]->surface, 0, 0, 256, 256); + wl_surface_commit (subsurfaces[7]->surface); + + /* Also move the subsurface a little. */ + wl_subsurface_set_position (subsurfaces[7]->subsurface, 100, 100); + + wait_frame_callback (wayland_surface); + sleep_or_verify (); + + /* Commit subsurfaces[6]. As it is now desynchronous, + subsurface_1.png should be displayed. */ + wait_frame_callback (subsurfaces[6]->surface); + sleep_or_verify (); break; }