diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-13 10:27:16 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-13 10:27:16 -0500 |
commit | f7c0d2badb3f06a5f90f7a25aeca6242d2aba093 (patch) | |
tree | 43aa391baccfa2d6e26c40823234bcc6694afcb5 /wayland | |
parent | Merge branch 'master' of github.com:SirCmpwn/sway (diff) | |
download | sway-f7c0d2badb3f06a5f90f7a25aeca6242d2aba093.tar.gz sway-f7c0d2badb3f06a5f90f7a25aeca6242d2aba093.tar.zst sway-f7c0d2badb3f06a5f90f7a25aeca6242d2aba093.zip |
Clean up some things better in wayland clients
Diffstat (limited to 'wayland')
-rw-r--r-- | wayland/client.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/wayland/client.c b/wayland/client.c index 5c5c0751..fcbba885 100644 --- a/wayland/client.c +++ b/wayland/client.c | |||
@@ -93,7 +93,7 @@ static int create_pool_file(size_t size) { | |||
93 | 93 | ||
94 | if (fd < 0) { | 94 | if (fd < 0) { |
95 | return -1; | 95 | return -1; |
96 | } | 96 | } |
97 | 97 | ||
98 | if (ftruncate(fd, size) < 0) { | 98 | if (ftruncate(fd, size) < 0) { |
99 | close(fd); | 99 | close(fd); |
@@ -125,6 +125,9 @@ struct buffer *create_buffer(struct client_state *state, | |||
125 | void *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | 125 | void *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
126 | buf->pool = wl_shm_create_pool(state->shm, fd, size); | 126 | buf->pool = wl_shm_create_pool(state->shm, fd, size); |
127 | buf->buffer = wl_shm_pool_create_buffer(buf->pool, 0, width, height, stride, format); | 127 | buf->buffer = wl_shm_pool_create_buffer(buf->pool, 0, width, height, stride, format); |
128 | wl_shm_pool_destroy(buf->pool); | ||
129 | close(fd); | ||
130 | fd = -1; | ||
128 | 131 | ||
129 | state->cairo_surface = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride); | 132 | state->cairo_surface = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride); |
130 | state->cairo = cairo_create(state->cairo_surface); | 133 | state->cairo = cairo_create(state->cairo_surface); |
@@ -175,22 +178,21 @@ struct client_state *client_setup(void) { | |||
175 | return state; | 178 | return state; |
176 | } | 179 | } |
177 | 180 | ||
178 | int client_prerender(struct client_state *state) { | ||
179 | wl_display_dispatch_pending(state->display); | ||
180 | wl_display_flush(state->display); | ||
181 | return 1; | ||
182 | } | ||
183 | |||
184 | int client_render(struct client_state *state) { | 181 | int client_render(struct client_state *state) { |
185 | if (state->frame_cb) { | 182 | if (state->frame_cb || state->busy) { |
186 | return 2; | 183 | return 2; |
187 | } | 184 | } |
185 | sway_log(L_INFO, "Rendering"); | ||
186 | |||
188 | state->frame_cb = wl_surface_frame(state->surface); | 187 | state->frame_cb = wl_surface_frame(state->surface); |
189 | wl_callback_add_listener(state->frame_cb, &listener, state); | 188 | wl_callback_add_listener(state->frame_cb, &listener, state); |
190 | wl_surface_damage(state->surface, 0, 0, 100, 100); | 189 | |
190 | wl_surface_damage(state->surface, 0, 0, state->buffer->width, state->buffer->height); | ||
191 | wl_surface_attach(state->surface, state->buffer->buffer, 0, 0); | 191 | wl_surface_attach(state->surface, state->buffer->buffer, 0, 0); |
192 | wl_surface_commit(state->surface); | 192 | wl_surface_commit(state->surface); |
193 | |||
193 | state->busy = true; | 194 | state->busy = true; |
195 | |||
194 | return wl_display_dispatch(state->display) != -1; | 196 | return wl_display_dispatch(state->display) != -1; |
195 | } | 197 | } |
196 | 198 | ||