mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-14 01:15:59 +01:00
Merge pull request #57 from acrisci/feature/create-region
implement compositor create region
This commit is contained in:
commit
947bb2e436
3 changed files with 21 additions and 4 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
pixman_region32_init(region);
|
||||
wl_resource_set_implementation(res, ®ion_interface, region, destroy_region);
|
||||
if (region == NULL) {
|
||||
wl_resource_post_no_memory(res);
|
||||
return;
|
||||
}
|
||||
|
||||
pixman_region32_init(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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue