viewporter: remove crop and scale state upon destruction

According to the viewport protocol, upon wp_viewport::destroy():

> The associated wl_surface's crop and scale state is removed.
> The change is applied on the next wl_surface.commit.

Therefore, wp_viewport_destroy(viewport) should remove all viewport state.

Currently, wlroots does not remove the crop and scale state. Instead, a
client must do:

    wl_fixed_t clear = wl_fixed_from_int(-1);
    wp_viewport_set_source(viewport, clear, clear, clear, clear);
    wp_viewport_set_destination(viewport, -1, -1);
    wp_viewport_destroy(viewport);

This commit adds the necessary logic into viewport_destroy and makes
wlroots comply with the protocol.
This commit is contained in:
Quantum 2021-08-01 18:10:25 -04:00 committed by Simon Ser
parent f5df956c18
commit 456c6e2279
1 changed files with 6 additions and 0 deletions

View File

@ -95,6 +95,12 @@ static void viewport_destroy(struct wlr_viewport *viewport) {
if (viewport == NULL) {
return;
}
struct wlr_surface_state *pending = &viewport->surface->pending;
pending->viewport.has_src = false;
pending->viewport.has_dst = false;
pending->committed |= WLR_SURFACE_STATE_VIEWPORT;
wl_resource_set_user_data(viewport->resource, NULL);
wl_list_remove(&viewport->surface_destroy.link);
wl_list_remove(&viewport->surface_commit.link);