diff options
author | Pekka Paalanen <ppaalanen@gmail.com> | 2012-01-03 16:32:40 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-01-03 11:22:58 -0500 |
commit | 2755847fce68d6ad36e180f807d06e8a6e70bce7 (patch) | |
tree | a8d3c5c0a64ee32e39842b485805adc6981cb75c | |
parent | d6465c5b402362c730c703f3f6dd5deddefec113 (diff) |
server: add wl_input_device_release()
Add a clean-up function for destroying all objects created in
wl_input_device_init(). Can be used to fix memory leaks reported by
Valgrind in the demos.
The init function was also missing an explicit initialisation of the
'keys' array. Add the explicit array init, although it is redundant with
the zeroing of the whole struct.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
krh: Edited to rename function to *_release()
-rw-r--r-- | src/wayland-server.c | 15 | ||||
-rw-r--r-- | src/wayland-server.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index 89e8a81..54a684c 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -411,6 +411,7 @@ wl_input_device_init(struct wl_input_device *device) { memset(device, 0, sizeof *device); wl_list_init(&device->resource_list); + wl_array_init(&device->keys); device->pointer_focus_listener.func = lose_pointer_focus; device->keyboard_focus_listener.func = lose_keyboard_focus; @@ -418,6 +419,20 @@ wl_input_device_init(struct wl_input_device *device) device->y = 100; } +WL_EXPORT void +wl_input_device_release(struct wl_input_device *device) +{ + if (device->keyboard_focus_resource) + wl_list_remove(&device->keyboard_focus_listener.link); + + if (device->pointer_focus_resource) + wl_list_remove(&device->pointer_focus_listener.link); + + /* XXX: What about device->resource_list? */ + + wl_array_release(&device->keys); +} + static struct wl_resource * find_resource_for_surface(struct wl_list *list, struct wl_surface *surface) { diff --git a/src/wayland-server.h b/src/wayland-server.h index 5176a09..968c654 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -223,6 +223,9 @@ void wl_input_device_init(struct wl_input_device *device); void +wl_input_device_release(struct wl_input_device *device); + +void wl_input_device_set_pointer_focus(struct wl_input_device *device, struct wl_surface *surface, uint32_t time, |