From 58efb8f90a8959a6f34bec233eeda2c1cbe138e8 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 18 Aug 2017 18:27:36 +0200 Subject: wayland backend: remove explicit scale = 1 This is now set correctly in the wlr_output init --- backend/wayland/output.c | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 16f9f017..e5079001 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -224,7 +224,6 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) { wlr_output->width = 640; wlr_output->height = 480; - wlr_output->scale = 1; strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make)); strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model)); snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%zd", -- cgit v1.2.3 From 12782eabfe2bf688b15d612a0357e75f13c9ade7 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 08:11:07 +0200 Subject: libinput: wl_event_source_remove on destroy --- backend/libinput/backend.c | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 28947a5e..5dd93f47 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -109,6 +109,7 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *_backend) { list_free(wlr_devices); } list_free(backend->wlr_device_lists); + wl_event_source_remove(backend->input_event); libinput_unref(backend->libinput_context); free(backend); } -- cgit v1.2.3 From f24b3df980979d761bd59773f39d6d5f90d17913 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 08:10:39 +0200 Subject: wlr renderer/texture: rename init to create when it does alloc --- backend/drm/drm.c | 4 ++-- examples/compositor/main.c | 2 +- examples/output-layout.c | 4 ++-- examples/rotation.c | 4 ++-- examples/tablet.c | 2 +- examples/touch.c | 4 ++-- include/render/gles2.h | 2 +- include/wlr/render.h | 2 +- include/wlr/render/gles2.h | 2 +- include/wlr/render/interface.h | 2 +- render/gles2/renderer.c | 8 ++++---- render/gles2/texture.c | 2 +- render/wlr_renderer.c | 4 ++-- types/wlr_output.c | 4 ++-- types/wlr_surface.c | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 65ea7f45..332926b9 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -598,12 +598,12 @@ static bool wlr_drm_output_set_cursor(struct wlr_output *_output, wlr_matrix_texture(plane->matrix, plane->width, plane->height, output->output.transform ^ WL_OUTPUT_TRANSFORM_FLIPPED_180); - plane->wlr_rend = wlr_gles2_renderer_init(&backend->backend); + plane->wlr_rend = wlr_gles2_renderer_create(&backend->backend); if (!plane->wlr_rend) { return false; } - plane->wlr_tex = wlr_render_texture_init(plane->wlr_rend); + plane->wlr_tex = wlr_render_texture_create(plane->wlr_rend); if (!plane->wlr_tex) { return false; } diff --git a/examples/compositor/main.c b/examples/compositor/main.c index 751a3f23..fdc4ed67 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -147,7 +147,7 @@ int main() { }; compositor_init(&compositor); - state.renderer = wlr_gles2_renderer_init(compositor.backend); + state.renderer = wlr_gles2_renderer_create(compositor.backend); if (!state.renderer) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); diff --git a/examples/output-layout.c b/examples/output-layout.c index dd43d2f4..565b21a6 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -193,8 +193,8 @@ int main(int argc, char *argv[]) { compositor.keyboard_key_cb = handle_keyboard_key; compositor_init(&compositor); - state.renderer = wlr_gles2_renderer_init(compositor.backend); - state.cat_texture = wlr_render_texture_init(state.renderer); + state.renderer = wlr_gles2_renderer_create(compositor.backend); + state.cat_texture = wlr_render_texture_create(state.renderer); wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); diff --git a/examples/rotation.c b/examples/rotation.c index b663f428..28f82382 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -132,12 +132,12 @@ int main(int argc, char *argv[]) { compositor.keyboard_key_cb = handle_keyboard_key; compositor_init(&compositor); - state.renderer = wlr_gles2_renderer_init(compositor.backend); + state.renderer = wlr_gles2_renderer_create(compositor.backend); if (!state.renderer) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); } - state.cat_texture = wlr_render_texture_init(state.renderer); + state.cat_texture = wlr_render_texture_create(state.renderer); if (!state.cat_texture) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); diff --git a/examples/tablet.c b/examples/tablet.c index 17653885..f43fbc52 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) { }; compositor_init(&compositor); - state.renderer = wlr_gles2_renderer_init(compositor.backend); + state.renderer = wlr_gles2_renderer_create(compositor.backend); if (!state.renderer) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); diff --git a/examples/touch.c b/examples/touch.c index 7e01a6c2..8df95e5b 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -107,12 +107,12 @@ int main(int argc, char *argv[]) { }; compositor_init(&compositor); - state.renderer = wlr_gles2_renderer_init(compositor.backend); + state.renderer = wlr_gles2_renderer_create(compositor.backend); if (!state.renderer) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); } - state.cat_texture = wlr_render_texture_init(state.renderer); + state.cat_texture = wlr_render_texture_create(state.renderer); if (!state.cat_texture) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); diff --git a/include/render/gles2.h b/include/render/gles2.h index 0e71d764..79f13ed9 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -49,7 +49,7 @@ extern struct shaders shaders; const struct pixel_format *gl_format_for_wl_format(enum wl_shm_format fmt); -struct wlr_texture *gles2_texture_init(); +struct wlr_texture *gles2_texture_create(); extern const GLchar quad_vertex_src[]; extern const GLchar quad_fragment_src[]; diff --git a/include/wlr/render.h b/include/wlr/render.h index 96b61ddf..b7924928 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -12,7 +12,7 @@ void wlr_renderer_end(struct wlr_renderer *r); /** * Requests a texture handle from this renderer. */ -struct wlr_texture *wlr_render_texture_init(struct wlr_renderer *r); +struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r); /** * Renders the requested texture using the provided matrix. A typical texture * rendering goes like so: diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index b368d6e1..4a944eb7 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -4,6 +4,6 @@ #include struct wlr_egl; -struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend); +struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend); #endif diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index f98c3bc2..c00e0701 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -14,7 +14,7 @@ struct wlr_renderer { struct wlr_renderer_impl { void (*begin)(struct wlr_renderer *renderer, struct wlr_output *output); void (*end)(struct wlr_renderer *renderer); - struct wlr_texture *(*texture_init)(struct wlr_renderer *renderer); + struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer); bool (*render_with_matrix)(struct wlr_renderer *renderer, struct wlr_texture *texture, const float (*matrix)[16]); void (*render_quad)(struct wlr_renderer *renderer, diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 1f3c3eeb..f0c724e4 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -143,11 +143,11 @@ static void wlr_gles2_end(struct wlr_renderer *renderer) { // no-op } -static struct wlr_texture *wlr_gles2_texture_init( +static struct wlr_texture *wlr_gles2_texture_create( struct wlr_renderer *_renderer) { struct wlr_gles2_renderer *renderer = (struct wlr_gles2_renderer *)_renderer; - return gles2_texture_init(renderer->egl); + return gles2_texture_create(renderer->egl); } static void draw_quad() { @@ -231,7 +231,7 @@ static bool wlr_gles2_buffer_is_drm(struct wlr_renderer *_renderer, static struct wlr_renderer_impl wlr_renderer_impl = { .begin = wlr_gles2_begin, .end = wlr_gles2_end, - .texture_init = wlr_gles2_texture_init, + .texture_create = wlr_gles2_texture_create, .render_with_matrix = wlr_gles2_render_texture, .render_quad = wlr_gles2_render_quad, .render_ellipse = wlr_gles2_render_ellipse, @@ -239,7 +239,7 @@ static struct wlr_renderer_impl wlr_renderer_impl = { .buffer_is_drm = wlr_gles2_buffer_is_drm, }; -struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend) { +struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) { init_globals(); struct wlr_gles2_renderer *renderer; if (!(renderer = calloc(1, sizeof(struct wlr_gles2_renderer)))) { diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 6bb93e4f..f6a9d7eb 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -276,7 +276,7 @@ static struct wlr_texture_impl wlr_texture_impl = { .destroy = gles2_texture_destroy, }; -struct wlr_texture *gles2_texture_init(struct wlr_egl *egl) { +struct wlr_texture *gles2_texture_create(struct wlr_egl *egl) { struct wlr_gles2_texture *texture; if (!(texture = calloc(1, sizeof(struct wlr_gles2_texture)))) { return NULL; diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 2f6c7fad..fec5e38a 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -23,8 +23,8 @@ void wlr_renderer_end(struct wlr_renderer *r) { r->impl->end(r); } -struct wlr_texture *wlr_render_texture_init(struct wlr_renderer *r) { - return r->impl->texture_init(r); +struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) { + return r->impl->texture_create(r); } bool wlr_render_with_matrix(struct wlr_renderer *r, diff --git a/types/wlr_output.c b/types/wlr_output.c index e3762733..0a38d591 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -139,14 +139,14 @@ bool wlr_output_set_cursor(struct wlr_output *output, if (!output->cursor.renderer) { /* NULL egl is okay given that we are only using pixel buffers */ - output->cursor.renderer = wlr_gles2_renderer_init(NULL); + output->cursor.renderer = wlr_gles2_renderer_create(NULL); if (!output->cursor.renderer) { return false; } } if (!output->cursor.texture) { - output->cursor.texture = wlr_render_texture_init(output->cursor.renderer); + output->cursor.texture = wlr_render_texture_create(output->cursor.renderer); if (!output->cursor.texture) { return false; } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 240360a1..894ef899 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -356,7 +356,7 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res, return NULL; } surface->renderer = renderer; - surface->texture = wlr_render_texture_init(renderer); + surface->texture = wlr_render_texture_create(renderer); surface->resource = res; surface->current.scale = 1; surface->pending.scale = 1; -- cgit v1.2.3 From fc1a8514154a338e1bf049069dfa6c2c9bf70c99 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 08:37:25 +0200 Subject: wlr_surface: clear/fini buffers when appropriate --- types/wlr_surface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 894ef899..3eae1131 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -230,6 +230,7 @@ static void surface_commit(struct wl_client *client, &buffer_damage, surface->current.width, surface->current.height); pixman_region32_union(&surface->current.buffer_damage, &surface->current.buffer_damage, &buffer_damage); + pixman_region32_fini(&buffer_damage); pixman_region32_intersect_rect(&surface->current.buffer_damage, &surface->current.buffer_damage, 0, 0, @@ -237,6 +238,7 @@ static void surface_commit(struct wl_client *client, pixman_region32_clear(&surface->pending.surface_damage); pixman_region32_clear(&surface->pending.buffer_damage); + pixman_region32_clear(&surface->pending.opaque); } // TODO: Commit other changes -- cgit v1.2.3 From 03b29eb32cb50ccc3b10f95a5c00d14ba1878d85 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 09:20:28 +0200 Subject: wlr region/surface: explicitely select interface fields --- types/wlr_region.c | 6 +++--- types/wlr_surface.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/types/wlr_region.c b/types/wlr_region.c index dead3784..fdf23ad2 100644 --- a/types/wlr_region.c +++ b/types/wlr_region.c @@ -26,9 +26,9 @@ static void region_destroy(struct wl_client *client, struct wl_resource *resourc } static const struct wl_region_interface region_interface = { - region_destroy, - region_add, - region_subtract, + .destroy = region_destroy, + .add = region_add, + .subtract = region_subtract, }; static void destroy_region(struct wl_resource *resource) { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 3eae1131..be6afcf1 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -326,16 +326,16 @@ static void surface_damage_buffer(struct wl_client *client, } const struct wl_surface_interface surface_interface = { - surface_destroy, - surface_attach, - surface_damage, - surface_frame, - surface_set_opaque_region, - surface_set_input_region, - surface_commit, - surface_set_buffer_transform, - surface_set_buffer_scale, - surface_damage_buffer + .destroy = surface_destroy, + .attach = surface_attach, + .damage = surface_damage, + .frame = surface_frame, + .set_opaque_region = surface_set_opaque_region, + .set_input_region = surface_set_input_region, + .commit = surface_commit, + .set_buffer_transform = surface_set_buffer_transform, + .set_buffer_scale = surface_set_buffer_scale, + .damage_buffer = surface_damage_buffer }; static void destroy_surface(struct wl_resource *resource) { -- cgit v1.2.3 From 4da976bfad9fb97a83fd67c52ce547fba880c9b1 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 09:23:53 +0200 Subject: wlr_surface: small refactoring - split surface damage and buffer damage - the pending buffers are always valid, so can be 'fini'shed - consider opaque buffer and input buffer in commit, just to free - only update size if scale/transform/buffer changed --- types/wlr_surface.c | 63 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index be6afcf1..d8baab20 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -67,6 +67,9 @@ static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); + if ((surface->pending.invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) { + pixman_region32_clear(&surface->pending.opaque); + } surface->pending.invalid |= WLR_SURFACE_INVALID_OPAQUE_REGION; if (region_resource) { pixman_region32_t *region = wl_resource_get_user_data(region_resource); @@ -80,12 +83,14 @@ static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); + if ((surface->pending.invalid & WLR_SURFACE_INVALID_INPUT_REGION)) { + pixman_region32_clear(&surface->pending.input); + } surface->pending.invalid |= WLR_SURFACE_INVALID_INPUT_REGION; if (region_resource) { pixman_region32_t *region = wl_resource_get_user_data(region_resource); pixman_region32_copy(&surface->pending.input, region); } else { - pixman_region32_fini(&surface->pending.input); pixman_region32_init_rect(&surface->pending.input, INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); } @@ -199,20 +204,30 @@ static void wlr_surface_to_buffer_region(struct wlr_surface *surface, static void surface_commit(struct wl_client *client, struct wl_resource *resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); - surface->current.scale = surface->pending.scale; - surface->current.transform = surface->pending.transform; + int update_size = 0; + int update_damage = 0; + if ((surface->pending.invalid & WLR_SURFACE_INVALID_SCALE)) { + surface->current.scale = surface->pending.scale; + update_size = 1; + } + if ((surface->pending.invalid & WLR_SURFACE_INVALID_TRANSFORM)) { + surface->current.transform = surface->pending.transform; + update_size = 1; + } if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) { surface->current.buffer = surface->pending.buffer; + update_size = 1; } - if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) { + if (update_size) { int32_t oldw = surface->current.buffer_width; int32_t oldh = surface->current.buffer_height; wlr_surface_update_size(surface); surface->reupload_buffer = oldw != surface->current.buffer_width || oldh != surface->current.buffer_height; - + } + if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) { pixman_region32_union(&surface->current.surface_damage, &surface->current.surface_damage, &surface->pending.surface_damage); @@ -220,10 +235,18 @@ static void surface_commit(struct wl_client *client, &surface->current.surface_damage, 0, 0, surface->current.width, surface->current.height); + pixman_region32_clear(&surface->pending.surface_damage); + update_damage = 1; + } + if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER_DAMAGE)) { pixman_region32_union(&surface->current.buffer_damage, &surface->current.buffer_damage, &surface->pending.buffer_damage); + pixman_region32_clear(&surface->pending.buffer_damage); + update_damage = 1; + } + if (update_damage) { pixman_region32_t buffer_damage; pixman_region32_init(&buffer_damage); wlr_surface_to_buffer_region(surface, &surface->current.surface_damage, @@ -235,12 +258,15 @@ static void surface_commit(struct wl_client *client, pixman_region32_intersect_rect(&surface->current.buffer_damage, &surface->current.buffer_damage, 0, 0, surface->current.buffer_width, surface->current.buffer_height); - - pixman_region32_clear(&surface->pending.surface_damage); - pixman_region32_clear(&surface->pending.buffer_damage); + } + if ((surface->pending.invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) { + // TODO: process buffer pixman_region32_clear(&surface->pending.opaque); } - // TODO: Commit other changes + if ((surface->pending.invalid & WLR_SURFACE_INVALID_INPUT_REGION)) { + // TODO: process buffer + pixman_region32_clear(&surface->pending.input); + } surface->pending.invalid = 0; // TODO: add the invalid bitfield to this callback @@ -288,11 +314,8 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) { } release: - pixman_region32_fini(&surface->current.surface_damage); - pixman_region32_init(&surface->current.surface_damage); - - pixman_region32_fini(&surface->current.buffer_damage); - pixman_region32_init(&surface->current.buffer_damage); + pixman_region32_clear(&surface->current.surface_damage); + pixman_region32_clear(&surface->current.buffer_damage); wl_resource_post_event(surface->current.buffer, WL_BUFFER_RELEASE); surface->current.buffer = NULL; @@ -301,6 +324,7 @@ release: static void surface_set_buffer_transform(struct wl_client *client, struct wl_resource *resource, int transform) { struct wlr_surface *surface = wl_resource_get_user_data(resource); + surface->pending.invalid |= WLR_SURFACE_INVALID_TRANSFORM; surface->pending.transform = transform; } @@ -308,6 +332,7 @@ static void surface_set_buffer_scale(struct wl_client *client, struct wl_resource *resource, int32_t scale) { struct wlr_surface *surface = wl_resource_get_user_data(resource); + surface->pending.invalid |= WLR_SURFACE_INVALID_SCALE; surface->pending.scale = scale; } @@ -319,7 +344,7 @@ static void surface_damage_buffer(struct wl_client *client, if (width < 0 || height < 0) { return; } - surface->pending.invalid |= WLR_SURFACE_INVALID_SURFACE_DAMAGE; + surface->pending.invalid |= WLR_SURFACE_INVALID_BUFFER_DAMAGE; pixman_region32_union_rect(&surface->pending.buffer_damage, &surface->pending.buffer_damage, x, y, width, height); @@ -346,6 +371,10 @@ static void destroy_surface(struct wl_resource *resource) { wl_list_for_each_safe(cb, next, &surface->frame_callback_list, link) { wl_resource_destroy(cb->resource); } + pixman_region32_fini(&surface->pending.surface_damage); + pixman_region32_fini(&surface->pending.buffer_damage); + pixman_region32_fini(&surface->pending.opaque); + pixman_region32_fini(&surface->pending.input); free(surface); } @@ -364,6 +393,10 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res, surface->pending.scale = 1; surface->current.transform = WL_OUTPUT_TRANSFORM_NORMAL; surface->pending.transform = WL_OUTPUT_TRANSFORM_NORMAL; + pixman_region32_init(&surface->pending.surface_damage); + pixman_region32_init(&surface->pending.buffer_damage); + pixman_region32_init(&surface->pending.opaque); + pixman_region32_init(&surface->pending.input); wl_signal_init(&surface->signals.commit); wl_list_init(&surface->frame_callback_list); wl_resource_set_implementation(res, &surface_interface, -- cgit v1.2.3 From 5885679e33b4082e727fb55e1700b67159ec9d06 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 09:26:25 +0200 Subject: examples: separate compositor_fini from run compositor_fini destroys the display, but it is an error to destroy it before e.g. wlr_seat that references it. This lets us order destroy calls properly, following first-in-last-out logic. --- examples/compositor/main.c | 10 +++++++--- examples/output-layout.c | 3 ++- examples/pointer.c | 3 ++- examples/rotation.c | 3 ++- examples/shared.c | 3 +-- examples/shared.h | 2 +- examples/simple.c | 3 ++- examples/tablet.c | 3 ++- examples/touch.c | 3 ++- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/compositor/main.c b/examples/compositor/main.c index fdc4ed67..4c6e213d 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -178,9 +178,13 @@ int main() { break; } - compositor_run(&compositor); + wl_display_run(compositor.display); - wlr_wl_shell_destroy(state.wl_shell); - wlr_xdg_shell_v6_destroy(state.xdg_shell); close(state.keymap_fd); + wlr_seat_destroy(state.wl_seat); + wlr_data_device_manager_destroy(state.data_device_manager); + wlr_xdg_shell_v6_destroy(state.xdg_shell); + wlr_wl_shell_destroy(state.wl_shell); + wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } diff --git a/examples/output-layout.c b/examples/output-layout.c index 565b21a6..0dcbc1f8 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -198,10 +198,11 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); wlr_output_layout_destroy(state.layout); diff --git a/examples/pointer.c b/examples/pointer.c index 1325a579..12253b62 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -146,7 +146,8 @@ int main(int argc, char *argv[]) { } compositor_init(&compositor); - compositor_run(&compositor); + wl_display_run(compositor.display); + compositor_fini(&compositor); wlr_xcursor_theme_destroy(theme); } diff --git a/examples/rotation.c b/examples/rotation.c index 28f82382..1dcbc80f 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -145,10 +145,11 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); example_config_destroy(state.config); } diff --git a/examples/shared.c b/examples/shared.c index 255652c7..f37140cf 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -674,8 +674,7 @@ void compositor_init(struct compositor_state *state) { } } -void compositor_run(struct compositor_state *state) { - wl_display_run(state->display); +void compositor_fini(struct compositor_state *state) { wlr_backend_destroy(state->backend); wl_display_destroy(state->display); } diff --git a/examples/shared.h b/examples/shared.h index 23b2d83d..d8007753 100644 --- a/examples/shared.h +++ b/examples/shared.h @@ -151,6 +151,6 @@ struct compositor_state { }; void compositor_init(struct compositor_state *state); -void compositor_run(struct compositor_state *state); +void compositor_fini(struct compositor_state *state); #endif diff --git a/examples/simple.c b/examples/simple.c index 8e098e18..7c3cc496 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -52,5 +52,6 @@ int main() { .output_frame_cb = handle_output_frame, }; compositor_init(&compositor); - compositor_run(&compositor); + wl_display_run(compositor.display); + compositor_fini(&compositor); } diff --git a/examples/tablet.c b/examples/tablet.c index f43fbc52..4aec5a72 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -158,7 +158,8 @@ int main(int argc, char *argv[]) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); } - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } diff --git a/examples/touch.c b/examples/touch.c index 8df95e5b..7e8d9827 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -120,8 +120,9 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ARGB8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } -- cgit v1.2.3 From 062d923b0a872a0417542ab069cb71da787bc2d0 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 09:30:47 +0200 Subject: wayland backend: wl_event_source_remove on destroy --- backend/wayland/backend.c | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 7bb0d0e9..d917c7e9 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -88,6 +88,7 @@ static void wlr_wl_backend_destroy(struct wlr_backend *_backend) { list_free(backend->outputs); free(backend->seat_name); + wl_event_source_remove(backend->remote_display_src); wlr_egl_free(&backend->egl); if (backend->seat) wl_seat_destroy(backend->seat); if (backend->shm) wl_shm_destroy(backend->shm); -- cgit v1.2.3 From 84c0c87a5ddca24cb039f33eea38252681bb4636 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 19 Aug 2017 14:37:50 +0200 Subject: wlr_surface: change update_size/damage to bool --- types/wlr_surface.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index d8baab20..2f68b134 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -204,20 +204,20 @@ static void wlr_surface_to_buffer_region(struct wlr_surface *surface, static void surface_commit(struct wl_client *client, struct wl_resource *resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); - int update_size = 0; - int update_damage = 0; + bool update_size = false; + bool update_damage = false; if ((surface->pending.invalid & WLR_SURFACE_INVALID_SCALE)) { surface->current.scale = surface->pending.scale; - update_size = 1; + update_size = true; } if ((surface->pending.invalid & WLR_SURFACE_INVALID_TRANSFORM)) { surface->current.transform = surface->pending.transform; - update_size = 1; + update_size = true; } if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) { surface->current.buffer = surface->pending.buffer; - update_size = 1; + update_size = true; } if (update_size) { int32_t oldw = surface->current.buffer_width; @@ -236,7 +236,7 @@ static void surface_commit(struct wl_client *client, surface->current.height); pixman_region32_clear(&surface->pending.surface_damage); - update_damage = 1; + update_damage = true; } if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER_DAMAGE)) { pixman_region32_union(&surface->current.buffer_damage, @@ -244,7 +244,7 @@ static void surface_commit(struct wl_client *client, &surface->pending.buffer_damage); pixman_region32_clear(&surface->pending.buffer_damage); - update_damage = 1; + update_damage = true; } if (update_damage) { pixman_region32_t buffer_damage; -- cgit v1.2.3