diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-08-10 05:57:58 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-08-10 05:59:43 -0400 |
commit | 14654ecb77aaac5dcf4fd11c9e06c4bf16af7a53 (patch) | |
tree | cf54dc7841429ee8fe0953ae2327ade52941741e | |
parent | 750d0ad4583732ee24c998f46a62fc684f86bc48 (diff) |
implement compositor create region
Complete the implementation of wlr_region_create and put it in the compositor.
-rw-r--r-- | examples/compositor/wl_compositor.c | 3 | ||||
-rw-r--r-- | include/wlr/types/wlr_region.h | 3 | ||||
-rw-r--r-- | types/wlr_region.c | 19 |
3 files changed, 21 insertions, 4 deletions
diff --git a/examples/compositor/wl_compositor.c b/examples/compositor/wl_compositor.c index 89d23d6a..e5b1120e 100644 --- a/examples/compositor/wl_compositor.c +++ b/examples/compositor/wl_compositor.c @@ -3,6 +3,7 @@ #include <wayland-server.h> #include <wlr/util/log.h> #include <wlr/types/wlr_surface.h> +#include <wlr/types/wlr_region.h> #include "compositor.h" static void destroy_surface_listener(struct wl_listener *listener, void *data) { @@ -31,7 +32,7 @@ static void wl_compositor_create_surface(struct wl_client *client, static void wl_compositor_create_region(struct wl_client *client, struct wl_resource *resource, uint32_t id) { - wlr_log(L_DEBUG, "TODO: implement create_region"); + wlr_region_create(client, resource, id); } struct wl_compositor_interface wl_compositor_impl = { diff --git a/include/wlr/types/wlr_region.h b/include/wlr/types/wlr_region.h index 9fff0150..0aff48a3 100644 --- a/include/wlr/types/wlr_region.h +++ b/include/wlr/types/wlr_region.h @@ -5,6 +5,7 @@ struct wl_resource; // Implements the given resource as region. // Sets the associated pixman_region32_t as userdata. -void wlr_region_create(struct wl_resource *res); +void wlr_region_create(struct wl_client *client, struct wl_resource *res, + uint32_t id); #endif diff --git a/types/wlr_region.c b/types/wlr_region.c index a1c45542..dead3784 100644 --- a/types/wlr_region.c +++ b/types/wlr_region.c @@ -37,8 +37,23 @@ static void destroy_region(struct wl_resource *resource) { free(reg); } -void wlr_region_create(struct wl_resource *res) { +void wlr_region_create(struct wl_client *client, struct wl_resource *res, + uint32_t id) { pixman_region32_t *region = calloc(1, sizeof(pixman_region32_t)); + if (region == NULL) { + wl_resource_post_no_memory(res); + return; + } + pixman_region32_init(region); - wl_resource_set_implementation(res, ®ion_interface, region, destroy_region); + + struct wl_resource *region_resource = wl_resource_create(client, + &wl_region_interface, 1, id); + if (region_resource == NULL) { + free(region); + wl_resource_post_no_memory(res); + return; + } + wl_resource_set_implementation(region_resource, ®ion_interface, region, + destroy_region); } |