Use wl_signal mechanism
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 12 Apr 2012 03:18:23 +0000 (23:18 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 12 Apr 2012 20:15:56 +0000 (16:15 -0400)
Mostly mechanical rewrite to track waylands change to struct wl_signal.

src/compositor-drm.c
src/compositor.c
src/shell.c
src/tablet-shell.c
src/util.c
src/xserver-launcher.c

index d2a6b34..1b0fbd0 100644 (file)
@@ -190,8 +190,8 @@ drm_output_prepare_scanout_surface(struct drm_output *output)
        output->pending_scanout_buffer = es->buffer;
        output->pending_scanout_buffer->busy_count++;
 
-       wl_list_insert(output->pending_scanout_buffer->resource.destroy_listener_list.prev,
-                      &output->pending_scanout_buffer_destroy_listener.link);
+       wl_signal_add(&output->pending_scanout_buffer->resource.destroy_signal,
+                     &output->pending_scanout_buffer_destroy_listener);
 
        pixman_region32_fini(&es->damage);
        pixman_region32_init(&es->damage);
@@ -335,8 +335,8 @@ vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
 
        if (s->pending_surface) {
                wl_list_remove(&s->pending_destroy_listener.link);
-               wl_list_insert(s->pending_surface->buffer->resource.destroy_listener_list.prev,
-                              &s->destroy_listener.link);
+               wl_signal_add(&s->pending_surface->buffer->resource.destroy_signal,
+                             &s->destroy_listener);
                s->surface = s->pending_surface;
                s->pending_surface = NULL;
                s->fb_id = s->pending_fb_id;
@@ -373,8 +373,8 @@ page_flip_handler(int fd, unsigned int frame,
        if (output->pending_scanout_buffer) {
                output->scanout_buffer = output->pending_scanout_buffer;
                wl_list_remove(&output->pending_scanout_buffer_destroy_listener.link);
-               wl_list_insert(output->scanout_buffer->resource.destroy_listener_list.prev,
-                              &output->scanout_buffer_destroy_listener.link);
+               wl_signal_add(&output->scanout_buffer->resource.destroy_signal,
+                             &output->scanout_buffer_destroy_listener);
                output->pending_scanout_buffer = NULL;
        }
        msecs = sec * 1000 + usec / 1000;
@@ -561,8 +561,8 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base,
        s->src_h = (box->y2 - box->y1) << 16;
        pixman_region32_fini(&src_rect);
 
-       wl_list_insert(es->buffer->resource.destroy_listener_list.prev,
-                      &s->pending_destroy_listener.link);
+       wl_signal_add(&es->buffer->resource.destroy_signal,
+                     &s->pending_destroy_listener);
        return 0;
 }
 
@@ -916,8 +916,7 @@ drm_subpixel_to_wayland(int drm_value)
 }
 
 static void
-output_handle_scanout_buffer_destroy(struct wl_listener *listener,
-                                    struct wl_resource *resource)
+output_handle_scanout_buffer_destroy(struct wl_listener *listener, void *data)
 {
        struct drm_output *output =
                container_of(listener, struct drm_output,
@@ -931,7 +930,7 @@ output_handle_scanout_buffer_destroy(struct wl_listener *listener,
 
 static void
 output_handle_pending_scanout_buffer_destroy(struct wl_listener *listener,
-                                            struct wl_resource *resource)
+                                            void *data)
 {
        struct drm_output *output =
                container_of(listener, struct drm_output,
@@ -943,8 +942,7 @@ output_handle_pending_scanout_buffer_destroy(struct wl_listener *listener,
 }
 
 static void
-sprite_handle_buffer_destroy(struct wl_listener *listener,
-                            struct wl_resource *resource)
+sprite_handle_buffer_destroy(struct wl_listener *listener, void *data)
 {
        struct drm_sprite *sprite =
                container_of(listener, struct drm_sprite,
@@ -954,8 +952,7 @@ sprite_handle_buffer_destroy(struct wl_listener *listener,
 }
 
 static void
-sprite_handle_pending_buffer_destroy(struct wl_listener *listener,
-                                    struct wl_resource *resource)
+sprite_handle_pending_buffer_destroy(struct wl_listener *listener, void *data)
 {
        struct drm_sprite *sprite =
                container_of(listener, struct drm_sprite,
@@ -1157,9 +1154,9 @@ create_output_for_connector(struct drm_compositor *ec,
 
        wl_list_insert(ec->base.output_list.prev, &output->base.link);
 
-       output->scanout_buffer_destroy_listener.func =
+       output->scanout_buffer_destroy_listener.notify =
                output_handle_scanout_buffer_destroy;
-       output->pending_scanout_buffer_destroy_listener.func =
+       output->pending_scanout_buffer_destroy_listener.notify =
                output_handle_pending_scanout_buffer_destroy;
 
        output->next_fb_id = 0;
@@ -1226,8 +1223,8 @@ create_sprites(struct drm_compositor *ec)
                sprite->pending_surface = NULL;
                sprite->fb_id = 0;
                sprite->pending_fb_id = 0;
-               sprite->destroy_listener.func = sprite_handle_buffer_destroy;
-               sprite->pending_destroy_listener.func =
+               sprite->destroy_listener.notify = sprite_handle_buffer_destroy;
+               sprite->pending_destroy_listener.notify =
                        sprite_handle_pending_buffer_destroy;
                sprite->compositor = ec;
                sprite->count_formats = plane->count_formats;
index 8341016..bb0cb35 100644 (file)
@@ -165,8 +165,7 @@ weston_client_launch(struct weston_compositor *compositor,
 }
 
 static void
-surface_handle_buffer_destroy(struct wl_listener *listener,
-                             struct wl_resource *resource)
+surface_handle_buffer_destroy(struct wl_listener *listener, void *data)
 {
        struct weston_surface *es =
                container_of(listener, struct weston_surface, 
@@ -208,7 +207,7 @@ weston_surface_create(struct weston_compositor *compositor)
        if (surface == NULL)
                return NULL;
 
-       wl_list_init(&surface->surface.resource.destroy_listener_list);
+       wl_signal_init(&surface->surface.resource.destroy_signal);
 
        wl_list_init(&surface->link);
        wl_list_init(&surface->layer_link);
@@ -230,7 +229,7 @@ weston_surface_create(struct weston_compositor *compositor)
        pixman_region32_init(&surface->transform.opaque);
        wl_list_init(&surface->frame_callback_list);
 
-       surface->buffer_destroy_listener.func = surface_handle_buffer_destroy;
+       surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
 
        wl_list_init(&surface->geometry.transformation_list);
        wl_list_insert(&surface->geometry.transformation_list,
@@ -686,8 +685,8 @@ weston_surface_attach(struct wl_surface *surface, struct wl_buffer *buffer)
        }
 
        buffer->busy_count++;
-       wl_list_insert(es->buffer->resource.destroy_listener_list.prev,
-                      &es->buffer_destroy_listener.link);
+       wl_signal_add(&es->buffer->resource.destroy_signal,
+                     &es->buffer_destroy_listener);
 
        if (es->geometry.width != buffer->width ||
            es->geometry.height != buffer->height) {
@@ -1660,8 +1659,7 @@ notify_pointer_focus(struct wl_input_device *device,
 }
 
 static void
-destroy_device_saved_kbd_focus(struct wl_listener *listener,
-                              struct wl_resource *resource)
+destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
 {
        struct weston_input_device *wd;
 
@@ -1706,10 +1704,10 @@ notify_keyboard_focus(struct wl_input_device *device, struct wl_array *keys)
 
                if (surface) {
                        wd->saved_kbd_focus = surface;
-                       wd->saved_kbd_focus_listener.func =
+                       wd->saved_kbd_focus_listener.notify =
                                destroy_device_saved_kbd_focus;
-                       wl_list_insert(surface->resource.destroy_listener_list.prev,
-                                      &wd->saved_kbd_focus_listener.link);
+                       wl_signal_add(&surface->resource.destroy_signal,
+                                     &wd->saved_kbd_focus_listener);
                }
 
                wl_input_device_set_keyboard_focus(&wd->input_device, NULL);
@@ -1738,8 +1736,7 @@ find_resource_for_surface(struct wl_list *list, struct wl_surface *surface)
 }
 
 static void
-lose_touch_focus_resource(struct wl_listener *listener,
-                         struct wl_resource *resource)
+lose_touch_focus_resource(struct wl_listener *listener, void *data)
 {
        struct weston_input_device *device =
                container_of(listener, struct weston_input_device,
@@ -1749,8 +1746,7 @@ lose_touch_focus_resource(struct wl_listener *listener,
 }
 
 static void
-lose_touch_focus(struct wl_listener *listener,
-                struct wl_resource *resource)
+lose_touch_focus(struct wl_listener *listener, void *data)
 {
        struct weston_input_device *device =
                container_of(listener, struct weston_input_device,
@@ -1778,13 +1774,13 @@ touch_set_focus(struct weston_input_device *device,
                        return;
                }
 
-               device->touch_focus_resource_listener.func =
+               device->touch_focus_resource_listener.notify =
                        lose_touch_focus_resource;
-               wl_list_insert(resource->destroy_listener_list.prev,
-                              &device->touch_focus_resource_listener.link);
-               device->touch_focus_listener.func = lose_touch_focus;
-               wl_list_insert(surface->resource.destroy_listener_list.prev,
-                              &device->touch_focus_listener.link);
+               wl_signal_add(&resource->destroy_signal,
+                             &device->touch_focus_resource_listener);
+               device->touch_focus_listener.notify = lose_touch_focus;
+               wl_signal_add(&surface->resource.destroy_signal,
+                              &device->touch_focus_listener);
 
                device->touch_focus = surface;
                device->touch_focus_resource = resource;
@@ -1909,8 +1905,7 @@ static const struct wl_input_device_interface input_device_interface = {
 };
 
 static void
-handle_drag_surface_destroy(struct wl_listener *listener,
-                           struct wl_resource *resource)
+handle_drag_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct weston_input_device *device;
 
@@ -1940,8 +1935,7 @@ bind_input_device(struct wl_client *client,
 }
 
 static void
-device_handle_new_drag_icon(struct wl_listener *listener,
-                           struct wl_resource *resource)
+device_handle_new_drag_icon(struct wl_listener *listener, void *data)
 {
        struct weston_input_device *device;
 
@@ -1969,13 +1963,14 @@ weston_input_device_init(struct weston_input_device *device,
        device->modifier_state = 0;
        device->num_tp = 0;
 
-       device->drag_surface_destroy_listener.func = handle_drag_surface_destroy;
+       device->drag_surface_destroy_listener.notify =
+               handle_drag_surface_destroy;
 
        wl_list_insert(ec->input_device_list.prev, &device->link);
 
-       device->new_drag_icon_listener.func = device_handle_new_drag_icon;
-       wl_list_insert(device->input_device.drag_icon_listener_list.prev,
-                      &device->new_drag_icon_listener.link);
+       device->new_drag_icon_listener.notify = device_handle_new_drag_icon;
+       wl_signal_add(&device->input_device.drag_icon_signal,
+                     &device->new_drag_icon_listener);
 }
 
 WL_EXPORT void
@@ -2018,8 +2013,8 @@ device_setup_new_drag_surface(struct weston_input_device *device,
 
        surface->configure = drag_surface_configure;
 
-       wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
-                      &device->drag_surface_destroy_listener.link);
+       wl_signal_add(&surface->surface.resource.destroy_signal,
+                      &device->drag_surface_destroy_listener);
 
        return 1;
 }
index 70a8e62..b7bd4be 100644 (file)
@@ -151,8 +151,7 @@ struct rotate_grab {
 };
 
 static void
-destroy_shell_grab_shsurf(struct wl_listener *listener,
-                         struct wl_resource *resource)
+destroy_shell_grab_shsurf(struct wl_listener *listener, void *data)
 {
        struct shell_grab *grab;
 
@@ -169,9 +168,9 @@ shell_grab_init(struct shell_grab *grab,
 {
        grab->grab.interface = interface;
        grab->shsurf = shsurf;
-       grab->shsurf_destroy_listener.func = destroy_shell_grab_shsurf;
-       wl_list_insert(shsurf->resource.destroy_listener_list.prev,
-                      &grab->shsurf_destroy_listener.link);
+       grab->shsurf_destroy_listener.notify = destroy_shell_grab_shsurf;
+       wl_signal_add(&shsurf->resource.destroy_signal,
+                     &grab->shsurf_destroy_listener);
 
 }
 
@@ -852,8 +851,7 @@ destroy_shell_surface(struct wl_resource *resource)
 }
 
 static void
-shell_handle_surface_destroy(struct wl_listener *listener,
-                            struct wl_resource *resource)
+shell_handle_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct shell_surface *shsurf = container_of(listener,
                                                    struct shell_surface,
@@ -866,16 +864,13 @@ shell_handle_surface_destroy(struct wl_listener *listener,
 static struct shell_surface *
 get_shell_surface(struct weston_surface *surface)
 {
-       struct wl_list *lst = &surface->surface.resource.destroy_listener_list;
        struct wl_listener *listener;
 
-       /* search the destroy listener list for our callback */
-       wl_list_for_each(listener, lst, link) {
-               if (listener->func == shell_handle_surface_destroy) {
-                       return container_of(listener, struct shell_surface,
-                                           surface_destroy_listener);
-               }
-       }
+       listener = wl_signal_get(&surface->surface.resource.destroy_signal,
+                                shell_handle_surface_destroy);
+       if (listener)
+               return container_of(listener, struct shell_surface,
+                                   surface_destroy_listener);
 
        return NULL;
 }
@@ -928,9 +923,9 @@ shell_get_shell_surface(struct wl_client *client,
        shsurf->fullscreen.black_surface = NULL;
        wl_list_init(&shsurf->fullscreen.transform.link);
 
-       shsurf->surface_destroy_listener.func = shell_handle_surface_destroy;
-       wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
-                      &shsurf->surface_destroy_listener.link);
+       shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
+       wl_signal_add(&surface->surface.resource.destroy_signal,
+                     &shsurf->surface_destroy_listener);
 
        /* init link so its safe to always remove it in destroy_shell_surface */
        wl_list_init(&shsurf->link);
@@ -1082,8 +1077,7 @@ desktop_shell_set_panel(struct wl_client *client,
 }
 
 static void
-handle_lock_surface_destroy(struct wl_listener *listener,
-                           struct wl_resource *resource)
+handle_lock_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct wl_shell *shell =
                container_of(listener, struct wl_shell, lock_surface_listener);
@@ -1110,9 +1104,9 @@ desktop_shell_set_lock_surface(struct wl_client *client,
 
        shell->lock_surface = surface;
 
-       shell->lock_surface_listener.func = handle_lock_surface_destroy;
-       wl_list_insert(&surface_resource->destroy_listener_list,
-                      &shell->lock_surface_listener.link);
+       shell->lock_surface_listener.notify = handle_lock_surface_destroy;
+       wl_signal_add(&surface_resource->destroy_signal,
+                     &shell->lock_surface_listener);
 
        shell->lock_surface->type = SHELL_SURFACE_LOCK;
 }
@@ -2026,8 +2020,8 @@ switcher_next(struct switcher *switcher)
                return;
 
        wl_list_remove(&switcher->listener.link);
-       wl_list_insert(next->surface.resource.destroy_listener_list.prev,
-                      &switcher->listener.link);
+       wl_signal_add(&next->surface.resource.destroy_signal,
+                     &switcher->listener);
 
        switcher->current = next;
        next->alpha = 255;
@@ -2038,8 +2032,7 @@ switcher_next(struct switcher *switcher)
 }
 
 static void
-switcher_handle_surface_destroy(struct wl_listener *listener,
-                               struct wl_resource *resource)
+switcher_handle_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct switcher *switcher =
                container_of(listener, struct switcher, listener);
@@ -2097,7 +2090,7 @@ switcher_binding(struct wl_input_device *device, uint32_t time,
        switcher = malloc(sizeof *switcher);
        switcher->compositor = compositor;
        switcher->current = NULL;
-       switcher->listener.func = switcher_handle_surface_destroy;
+       switcher->listener.notify = switcher_handle_surface_destroy;
        wl_list_init(&switcher->listener.link);
 
        switcher->grab.interface = &switcher_grab;
index fc908ab..0ec31ea 100644 (file)
@@ -150,8 +150,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
 }
 
 static void
-handle_lockscreen_surface_destroy(struct wl_listener *listener,
-                                 struct wl_resource *resource)
+handle_lockscreen_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct tablet_shell *shell =
                container_of(listener,
@@ -172,14 +171,13 @@ tablet_shell_set_lockscreen(struct wl_client *client,
        weston_surface_set_position(es, 0, 0);
        shell->lockscreen_surface = es;
        shell->lockscreen_surface->configure = tablet_shell_surface_configure;
-       shell->lockscreen_listener.func = handle_lockscreen_surface_destroy;
-       wl_list_insert(es->surface.resource.destroy_listener_list.prev,
-                      &shell->lockscreen_listener.link);
+       shell->lockscreen_listener.notify = handle_lockscreen_surface_destroy;
+       wl_signal_add(&es->surface.resource.destroy_signal,
+                     &shell->lockscreen_listener);
 }
 
 static void
-handle_switcher_surface_destroy(struct wl_listener *listener,
-                               struct wl_resource *resource)
+handle_switcher_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct tablet_shell *shell =
                container_of(listener,
@@ -205,9 +203,9 @@ tablet_shell_set_switcher(struct wl_client *client,
        shell->switcher_surface = es;
        weston_surface_set_position(shell->switcher_surface, 0, 0);
 
-       shell->switcher_listener.func = handle_switcher_surface_destroy;
-       wl_list_insert(es->surface.resource.destroy_listener_list.prev,
-                      &shell->switcher_listener.link);
+       shell->switcher_listener.notify = handle_switcher_surface_destroy;
+       wl_signal_add(&es->surface.resource.destroy_signal,
+                     &shell->switcher_listener);
 }
 
 static void
index d21c275..c7511cf 100644 (file)
@@ -109,8 +109,7 @@ weston_zoom_destroy(struct weston_zoom *zoom)
 }
 
 static void
-handle_zoom_surface_destroy(struct wl_listener *listener,
-                           struct wl_resource *resource)
+handle_zoom_surface_destroy(struct wl_listener *listener, void *data)
 {
        struct weston_zoom *zoom =
                container_of(listener, struct weston_zoom, listener);
@@ -176,9 +175,9 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
        zoom->animation.frame = weston_zoom_frame;
        weston_zoom_frame(&zoom->animation, NULL, zoom->spring.timestamp);
 
-       zoom->listener.func = handle_zoom_surface_destroy;
-       wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
-                      &zoom->listener.link);
+       zoom->listener.notify = handle_zoom_surface_destroy;
+       wl_signal_add(&surface->surface.resource.destroy_signal,
+                     &zoom->listener);
 
        wl_list_insert(&surface->compositor->animation_list,
                       &zoom->animation.link);
index 09b4dc6..36344ed 100644 (file)
@@ -82,7 +82,7 @@ struct weston_wm {
        xcb_timestamp_t selection_timestamp;
        int selection_property_set;
        int flush_property_on_delete;
-       struct wl_selection_listener selection_listener;
+       struct wl_listener selection_listener;
 
        struct {
                xcb_atom_t               wm_protocols;
@@ -319,7 +319,7 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
        if (source == NULL)
                return;
 
-       wl_list_init(&source->resource.destroy_listener_list);
+       wl_signal_init(&source->resource.destroy_signal);
        source->offer_interface = &data_offer_interface;
        source->cancel = data_source_cancel;
        source->resource.data = wm;
@@ -451,9 +451,9 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
 }
 
 static void
-weston_wm_set_selection(struct wl_selection_listener *listener,
-                       struct wl_input_device *device)
+weston_wm_set_selection(struct wl_listener *listener, void *data)
 {
+       struct wl_input_device *device = data;
        struct weston_wm *wm =
                container_of(listener, struct weston_wm, selection_listener);
        struct wl_data_source *source = device->selection_data_source;
@@ -1348,9 +1348,8 @@ weston_wm_create(struct weston_xserver *wxs)
        xcb_flush(wm->conn);
 
        device = wxs->compositor->input_device;
-       wm->selection_listener.func = weston_wm_set_selection;
-       wl_list_insert(&device->selection_listener_list,
-                      &wm->selection_listener.link);
+       wm->selection_listener.notify = weston_wm_set_selection;
+       wl_signal_add(&device->selection_signal, &wm->selection_listener);
 
        fprintf(stderr, "created wm\n");
 
@@ -1480,7 +1479,7 @@ weston_xserver_cleanup(struct weston_process *process, int status)
 }
 
 static void
-surface_destroy(struct wl_listener *listener, struct wl_resource *resource)
+surface_destroy(struct wl_listener *listener, void *data)
 {
        struct weston_wm_window *window =
                container_of(listener,
@@ -1495,12 +1494,10 @@ get_wm_window(struct weston_surface *surface)
        struct wl_resource *resource = &surface->surface.resource;
        struct wl_listener *listener;
 
-       wl_list_for_each(listener, &resource->destroy_listener_list, link) {
-               if (listener->func == surface_destroy)
-                       return container_of(listener,
-                                           struct weston_wm_window,
-                                           surface_destroy_listener);
-       }
+       listener = wl_signal_get(&resource->destroy_signal, surface_destroy);
+       if (listener)
+               return container_of(listener, struct weston_wm_window,
+                                   surface_destroy_listener);
 
        return NULL;
 }
@@ -1526,9 +1523,9 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
        fprintf(stderr, "set_window_id %d for surface %p\n", id, surface);
 
        window->surface = (struct weston_surface *) surface;
-       window->surface_destroy_listener.func = surface_destroy;
-       wl_list_insert(surface->resource.destroy_listener_list.prev,
-                      &window->surface_destroy_listener.link);
+       window->surface_destroy_listener.notify = surface_destroy;
+       wl_signal_add(&surface->resource.destroy_signal,
+                     &window->surface_destroy_listener);
 }
 
 static const struct xserver_interface xserver_implementation = {