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.
This commit is contained in:
hujianwei 2022-11-06 05:09:57 +00:00
parent 769827921f
commit 3dcceb506b
2 changed files with 27 additions and 4 deletions

View file

@ -592,11 +592,16 @@ 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
{
/* 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;
}

View file

@ -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;
}