From 5424c2717d7ccdc6ee32ee8c1b9049a6f2ffcef1 Mon Sep 17 00:00:00 2001 From: Taekyun Kim Date: Wed, 5 Aug 2015 19:18:49 +0900 Subject: [PATCH] pepper: Fix event listener to work correctly Change-Id: Ied618c2ddbdf059c8140da84826b327c4c92a5d6 --- src/lib/desktop-shell/shell-surface.c | 2 ++ src/lib/pepper/object.c | 3 ++- src/lib/pepper/pepper.h | 36 ----------------------------------- src/lib/pepper/surface.c | 1 + src/lib/pepper/view.c | 2 ++ src/lib/render/gl-renderer.c | 2 ++ src/lib/render/pixman-renderer.c | 2 ++ 7 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/lib/desktop-shell/shell-surface.c b/src/lib/desktop-shell/shell-surface.c index bb81846..cac5fa7 100644 --- a/src/lib/desktop-shell/shell-surface.c +++ b/src/lib/desktop-shell/shell-surface.c @@ -196,6 +196,7 @@ shell_surface_create(shell_client_t *shell_client, pepper_surface_t *surface, wl_resource_set_implementation(shsurf->resource, implementation, shsurf, handle_resource_destroy); + pepper_event_listener_init(&shsurf->surface_destroy_listener); shsurf->surface_destroy_listener.callback = handle_surface_destroy; shsurf->surface_destroy_listener.data = shsurf; pepper_object_add_event_listener((pepper_object_t *)surface, @@ -204,6 +205,7 @@ shell_surface_create(shell_client_t *shell_client, pepper_surface_t *surface, shell_surface_set_type(shsurf, SHELL_SURFACE_TYPE_NONE); + pepper_event_listener_init(&shsurf->surface_commit_listener); shsurf->surface_commit_listener.callback = handle_surface_commit; shsurf->surface_commit_listener.data = shsurf; shsurf_start_listen_commit_event(shsurf); diff --git a/src/lib/pepper/object.c b/src/lib/pepper/object.c index 7d3c9a9..3ce04e2 100644 --- a/src/lib/pepper/object.c +++ b/src/lib/pepper/object.c @@ -95,6 +95,7 @@ PEPPER_API void pepper_event_listener_init(pepper_event_listener_t *listener) { memset(listener, 0x00, sizeof(pepper_event_listener_t)); + listener->link.item = listener; } PEPPER_API void @@ -114,7 +115,7 @@ pepper_event_listener_remove(pepper_event_listener_t *listener) { if (!listener->object) return; - + pepper_list_remove(&listener->link, NULL); listener->object = NULL; } diff --git a/src/lib/pepper/pepper.h b/src/lib/pepper/pepper.h index d24509d..e87698a 100644 --- a/src/lib/pepper/pepper.h +++ b/src/lib/pepper/pepper.h @@ -85,10 +85,7 @@ struct pepper_event_listener enum pepper_object_events { PEPPER_EVENT_OBJECT_DESTROY, -}; -enum pepper_compositor_events -{ PEPPER_EVENT_COMPOSITOR_OUTPUT_ADD, PEPPER_EVENT_COMPOSITOR_OUTPUT_REMOVE, PEPPER_EVENT_COMPOSITOR_SEAT_ADD, @@ -103,31 +100,16 @@ enum pepper_compositor_events PEPPER_EVENT_COMPOSITOR_KEYBOARD_DEVICE_REMOVE, PEPPER_EVENT_COMPOSITOR_TOUCH_DEVICE_ADD, PEPPER_EVENT_COMPOSITOR_TOUCH_DEVICE_REMOVE, -}; -enum pepper_output_events -{ PEPPER_EVENT_OUTPUT_MODE_CHANGE, PEPPER_EVENT_OUTPUT_MOVE, -}; -enum pepper_surface_events -{ PEPPER_EVENT_SURFACE_COMMIT, -}; -enum pepper_buffer_events -{ PEPPER_EVENT_BUFFER_RELEASE, -}; -enum pepper_view_events -{ PEPPER_EVENT_VIEW_STACK_CHANGE, -}; -enum pepper_seat_events -{ PEPPER_EVENT_SEAT_POINTER_ADD, PEPPER_EVENT_SEAT_POINTER_REMOVE, PEPPER_EVENT_SEAT_KEYBOARD_ADD, @@ -141,43 +123,25 @@ enum pepper_seat_events PEPPER_EVENT_SEAT_KEYBOARD_DEVICE_REMOVE, PEPPER_EVENT_SEAT_TOUCH_DEVICE_ADD, PEPPER_EVENT_SEAT_TOUCH_DEVICE_REMOVE, -}; -enum pepper_pointer_events -{ PEPPER_EVENT_POINTER_MOTION, PEPPER_EVENT_POINTER_BUTTON, PEPPER_EVENT_POINTER_AXIS, -}; -enum pepper_keyboard_events -{ PEPPER_EVENT_KEYBOARD_KEY, PEPPER_EVENT_KEYBOARD_MODIFIERS, -}; -enum pepper_touch_events -{ PEPPER_EVENT_TOUCH_DOWN, PEPPER_EVENT_TOUCH_UP, PEPPER_EVENT_TOUCH_MOTION, -}; -enum pepper_pointer_device_events -{ PEPPER_EVENT_POINTER_DEVICE_MOTION, PEPPER_EVENT_POINTER_DEVICE_BUTTON, PEPPER_EVENT_POINTER_DEVICE_AXIS, -}; -enum pepper_keyboard_device_events -{ PEPPER_EVENT_KEYBOARD_DEVICE_KEY, PEPPER_EVENT_KEYBOARD_DEVICE_MODIFIERS, -}; -enum pepper_touch_device_events -{ PEPPER_EVENT_TOUCH_DEVICE_DOWN, PEPPER_EVENT_TOUCH_DEVICE_UP, PEPPER_EVENT_TOUCH_DEVICE_MOTION, diff --git a/src/lib/pepper/surface.c b/src/lib/pepper/surface.c index abfd2bf..fec2527 100644 --- a/src/lib/pepper/surface.c +++ b/src/lib/pepper/surface.c @@ -23,6 +23,7 @@ pepper_surface_state_init(pepper_surface_state_t *state) pixman_region32_init(&state->input_region); wl_list_init(&state->frame_callbacks); + pepper_event_listener_init(&state->buffer_destroy_listener); state->buffer_destroy_listener.callback = buffer_destroy_handler; state->buffer_destroy_listener.data = state; } diff --git a/src/lib/pepper/view.c b/src/lib/pepper/view.c index 2bedbe0..1e4f34a 100644 --- a/src/lib/pepper/view.c +++ b/src/lib/pepper/view.c @@ -125,6 +125,7 @@ plane_entry_set_plane(pepper_plane_entry_t *entry, pepper_plane_t *plane) if (entry->plane) { + pepper_event_listener_init(&entry->plane_destroy_listener); entry->plane_destroy_listener.callback = view_handle_plane_destroy; entry->plane_destroy_listener.data = entry; pepper_object_add_event_listener(&plane->base, @@ -304,6 +305,7 @@ pepper_compositor_add_surface_view(pepper_compositor_t *compositor, pepper_surfa view->surface_link.item = view; pepper_list_insert(&surface->view_list, &view->surface_link); + pepper_event_listener_init(&view->surface_destroy_listener); view->surface_destroy_listener.callback = view_handle_surface_destroy; view->surface_destroy_listener.data = view; pepper_object_add_event_listener(&surface->base, &view->surface_destroy_listener, diff --git a/src/lib/render/gl-renderer.c b/src/lib/render/gl-renderer.c index 00e0575..666c4fa 100644 --- a/src/lib/render/gl-renderer.c +++ b/src/lib/render/gl-renderer.c @@ -213,9 +213,11 @@ get_surface_state(pepper_renderer_t *renderer, pepper_surface_t *surface) state->surface = surface; + pepper_event_listener_init(&state->buffer_destroy_listener); state->buffer_destroy_listener.callback = surface_state_handle_buffer_destroy; state->buffer_destroy_listener.data = state; + pepper_event_listener_init(&state->surface_destroy_listener); state->surface_destroy_listener.callback = surface_state_handle_surface_destroy; state->surface_destroy_listener.data = state; diff --git a/src/lib/render/pixman-renderer.c b/src/lib/render/pixman-renderer.c index ab9fa09..156d9d0 100644 --- a/src/lib/render/pixman-renderer.c +++ b/src/lib/render/pixman-renderer.c @@ -96,9 +96,11 @@ get_surface_state(pepper_renderer_t *renderer, pepper_surface_t *surface) state->surface = surface; + pepper_event_listener_init(&state->buffer_destroy_listener); state->buffer_destroy_listener.callback = surface_state_handle_buffer_destroy; state->buffer_destroy_listener.data = state; + pepper_event_listener_init(&state->surface_destroy_listener); state->surface_destroy_listener.callback = surface_state_handle_surface_destroy; state->surface_destroy_listener.data = state; -- 2.7.4