Skip to content

Commit a491658

Browse files
authored
Merge pull request #192 from wmww/mock-server-buffer-release
Mock server: send buffer release
2 parents 81ecf5e + 94ed094 commit a491658

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/mock-server/overrides.c

+19-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ struct SurfaceData
2727
SurfaceRole role;
2828
struct wl_resource* surface;
2929
struct wl_resource* pending_frame;
30+
struct wl_resource* pending_buffer; // The attached but not committed buffer
31+
char buffer_cleared; // If the buffer has been explicitly cleared since the last commit
3032
struct wl_resource* xdg_toplevel;
3133
struct wl_resource* xdg_popup;
3234
struct wl_resource* xdg_surface;
3335
struct wl_resource* layer_surface;
34-
char has_pending_buffer; // If the pending buffer is non-null; same as has_committed_buffer if no pending buffer
3536
char has_committed_buffer; // This surface has a non-null committed buffer
3637
char initial_commit_for_role; // Set to 1 when a role is created for a surface, and cleared after the first commit
3738
char layer_send_configure; // If to send a layer surface configure on the next commit
@@ -98,16 +99,30 @@ static void wl_surface_attach(struct wl_resource *resource, const struct wl_mess
9899
{
99100
RESOURCE_ARG(wl_buffer, buffer, 0);
100101
SurfaceData* data = wl_resource_get_user_data(resource);
101-
data->has_pending_buffer = (buffer != NULL);
102+
data->pending_buffer = buffer;
103+
data->buffer_cleared = buffer == NULL;
102104
data->click_on_surface = 1;
103105
}
104106

105107
static void wl_surface_commit(struct wl_resource *resource, const struct wl_message* message, union wl_argument* args)
106108
{
107109
SurfaceData* data = wl_resource_get_user_data(resource);
108-
data->has_committed_buffer = data->has_pending_buffer;
110+
if (data->buffer_cleared)
111+
{
112+
data->has_committed_buffer = 0;
113+
data->buffer_cleared = 0;
114+
}
115+
else if (data->pending_buffer)
116+
{
117+
data->has_committed_buffer = 1;
118+
}
119+
120+
if (data->pending_buffer)
121+
{
122+
wl_buffer_send_release(data->pending_buffer);
123+
data->pending_buffer = NULL;
124+
}
109125

110-
// leave the contents of has_pending_buffer alone
111126
if (data->pending_frame)
112127
{
113128
wl_callback_send_done(data->pending_frame, 0);

0 commit comments

Comments
 (0)