Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock server: send buffer release #48

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading