Allocate wlr_touch devices

This commit is contained in:
Drew DeVault 2017-06-14 11:40:03 -04:00
parent 7dfc2c28f1
commit d6905f86cb
11 changed files with 104 additions and 14 deletions

View file

@ -7,6 +7,7 @@ add_library(wlr-types
wlr_output.c
wlr_keyboard.c
wlr_pointer.c
wlr_touch.c
wlr_input_device.c
)

View file

@ -16,6 +16,8 @@ struct wlr_keyboard *wlr_keyboard_create(struct wlr_keyboard_impl *impl,
void wlr_keyboard_destroy(struct wlr_keyboard *kb) {
if (!kb) return;
kb->impl->destroy(kb->state);
if (kb->impl) {
kb->impl->destroy(kb->state);
}
free(kb);
}

View file

@ -17,8 +17,10 @@ struct wlr_pointer *wlr_pointer_create(struct wlr_pointer_impl *impl,
return pointer;
}
void wlr_pointer_destroy(struct wlr_pointer *kb) {
if (!kb) return;
kb->impl->destroy(kb->state);
free(kb);
void wlr_pointer_destroy(struct wlr_pointer *pointer) {
if (!pointer) return;
if (pointer->impl) {
pointer->impl->destroy(pointer->state);
}
free(pointer);
}

27
types/wlr_touch.c Normal file
View file

@ -0,0 +1,27 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server.h>
#include <wlr/types.h>
#include <wlr/common/list.h>
#include "types.h"
struct wlr_touch *wlr_touch_create(struct wlr_touch_impl *impl,
struct wlr_touch_state *state) {
struct wlr_touch *touch = calloc(1, sizeof(struct wlr_touch));
touch->impl = impl;
touch->state = state;
wl_signal_init(&touch->events.down);
wl_signal_init(&touch->events.up);
wl_signal_init(&touch->events.motion);
wl_signal_init(&touch->events.frame);
wl_signal_init(&touch->events.cancel);
return touch;
}
void wlr_touch_destroy(struct wlr_touch *touch) {
if (!touch) return;
if (touch->impl) {
touch->impl->destroy(touch->state);
}
free(touch);
}