summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-04-11 23:18:23 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-04-11 23:18:23 -0400
commit86842ea8cf906da01d10bd0dee53c99cc67f18b7 (patch)
tree72ccdab218db98e97b7f3c49c7f762304d143c2f
parenteae5de76090e18f7a4c2f654cfd94307fc2dbdd8 (diff)
Use wl_signal
-rw-r--r--src/compositor-drm.c24
-rw-r--r--src/compositor.c39
-rw-r--r--src/shell.c37
-rw-r--r--src/tablet-shell.c12
-rw-r--r--src/util.c6
-rw-r--r--src/xserver-launcher.c27
6 files changed, 70 insertions, 75 deletions
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index d2a6b349..4c0c88c8 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -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;
}
@@ -1157,9 +1157,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 +1226,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;
diff --git a/src/compositor.c b/src/compositor.c
index 8341016d..6b449906 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -208,7 +208,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 +230,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 +686,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) {
@@ -1706,10 +1706,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);
@@ -1778,13 +1778,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;
@@ -1969,13 +1969,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 +2019,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;
}
diff --git a/src/shell.c b/src/shell.c
index 70a8e62f..671c3a7d 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -169,9 +169,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);
}
@@ -866,16 +866,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 +925,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);
@@ -1110,9 +1107,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 +2023,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;
@@ -2097,7 +2094,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;
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index fc908ab0..afe31d62 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -172,9 +172,9 @@ 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
@@ -205,9 +205,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
diff --git a/src/util.c b/src/util.c
index d21c275f..9694f1fd 100644
--- a/src/util.c
+++ b/src/util.c
@@ -176,9 +176,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);
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index 09b4dc62..a042f2ab 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -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,7 +451,7 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
}
static void
-weston_wm_set_selection(struct wl_selection_listener *listener,
+weston_wm_set_selection(struct wl_listener *listener,
struct wl_input_device *device)
{
struct weston_wm *wm =
@@ -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");
@@ -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 = {