Skip to content

Commit

Permalink
Merge pull request #48 from wmww/mock-server-buffer-release
Browse files Browse the repository at this point in the history
Mock server: send buffer release
  • Loading branch information
wmww authored Sep 10, 2024
2 parents 2a8291a + 1af512b commit e77916e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/mock-server/overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ struct SurfaceData
SurfaceRole role;
struct wl_resource* surface;
struct wl_resource* pending_frame;
struct wl_resource* pending_buffer; // The attached but not committed buffer
char buffer_cleared; // If the buffer has been explicitly cleared since the last commit
struct wl_resource* xdg_toplevel;
struct wl_resource* xdg_popup;
struct wl_resource* xdg_surface;
struct wl_resource* layer_surface;
char has_pending_buffer; // If the pending buffer is non-null; same as has_committed_buffer if no pending buffer
char has_committed_buffer; // This surface has a non-null committed buffer
char initial_commit_for_role; // Set to 1 when a role is created for a surface, and cleared after the first commit
char layer_send_configure; // If to send a layer surface configure on the next commit
Expand Down Expand Up @@ -88,15 +89,29 @@ static void wl_surface_attach(struct wl_resource *resource, const struct wl_mess
{
RESOURCE_ARG(wl_buffer, buffer, 0);
SurfaceData* data = wl_resource_get_user_data(resource);
data->has_pending_buffer = (buffer != NULL);
data->pending_buffer = buffer;
data->buffer_cleared = buffer == NULL;
}

static void wl_surface_commit(struct wl_resource *resource, const struct wl_message* message, union wl_argument* args)
{
SurfaceData* data = wl_resource_get_user_data(resource);
data->has_committed_buffer = data->has_pending_buffer;
if (data->buffer_cleared)
{
data->has_committed_buffer = 0;
data->buffer_cleared = 0;
}
else if (data->pending_buffer)
{
data->has_committed_buffer = 1;
}

if (data->pending_buffer)
{
wl_buffer_send_release(data->pending_buffer);
data->pending_buffer = NULL;
}

// leave the contents of has_pending_buffer alone
if (data->pending_frame)
{
wl_callback_send_done(data->pending_frame, 0);
Expand Down

0 comments on commit e77916e

Please sign in to comment.