/* FIXME: Need a destructor for void *data? */
- global = container_of(display->global_list.next,
- struct wl_global, link);
- while (&global->link != &display->global_list) {
+ wl_list_for_each(global, &display->global_list, link)
if (global->proxy != NULL)
(*handler)(display, &global->proxy->base, data);
- global = container_of(global->link.next,
- struct wl_global, link);
- }
-
return listener;
}
wl_list_init(&proxy->listener_list);
wl_hash_insert(display->objects, &proxy->base);
- listener = container_of(display->global_listener_list.next,
- struct wl_global_listener, link);
- while (&listener->link != &display->global_listener_list) {
+ wl_list_for_each(listener, &display->global_listener_list, link)
(*listener->handler)(display, &proxy->base, listener->data);
- listener = container_of(listener->link.next,
- struct wl_global_listener, link);
- }
return proxy;
}
{
struct wl_global *global;
- global = container_of(display->global_list.next,
- struct wl_global, link);
- while (&global->link != &display->global_list) {
+ wl_list_for_each(global, &display->global_list, link)
if (strcmp(global->interface, interface) == 0 &&
global->version >= version)
return global->id;
- global = container_of(global->link.next,
- struct wl_global, link);
- }
-
return 0;
}
id, opcode);
}
- listener = container_of(proxy->listener_list.next,
- struct wl_listener, link);
- while (&listener->link != &proxy->listener_list) {
-
+ wl_list_for_each(listener, &proxy->listener_list, link)
wl_connection_demarshal(display->connection,
size,
display->objects,
&proxy->base,
&proxy->base.interface->events[opcode]);
- listener = container_of(listener->link.next,
- struct wl_listener, link);
- }
}
wl_connection_consume(display->connection, size);
struct wl_event_source *drm_source;
uint32_t modifier_state;
- struct wl_list animate_list;
};
#define MODIFIER_CTRL (1 << 8)
GLdouble x, y, z;
};
-struct wlsc_animate {
- struct wl_list link;
- void (*animate)(struct wlsc_animate *animate,
- struct wlsc_compositor *compositor,
- uint32_t frame, uint32_t msecs);
-};
-
struct wlsc_surface {
struct wl_surface base;
struct wlsc_compositor *compositor;
int i, j;
i = 0;
- output = container_of(ec->output_list.next, struct wlsc_output, link);
- while (&output->link != &ec->output_list) {
+ wl_list_for_each(output, &ec->output_list, link) {
snprintf(buffer, sizeof buffer, "wayland-screenshot-%d.png", i++);
data = malloc(output->width * output->height * 4);
if (data == NULL) {
gdk_pixbuf_unref(normal);
gdk_pixbuf_unref(pixbuf);
free(data);
-
- output = container_of(output->link.next,
- struct wlsc_output, link);
}
}
wlsc_surface_destroy(struct wlsc_surface *surface,
struct wlsc_compositor *compositor)
{
- struct wlsc_listener *l, *next;
+ struct wlsc_listener *l;
wl_list_remove(&surface->link);
glDeleteTextures(1, &surface->texture);
wl_client_remove_surface(surface->base.client, &surface->base);
- l = container_of(compositor->surface_destroy_listener_list.next,
- struct wlsc_listener, link);
- while (&l->link != &compositor->surface_destroy_listener_list) {
- next = container_of(l->link.next, struct wlsc_listener, link);
+ wl_list_for_each(l, &compositor->surface_destroy_listener_list, link)
l->func(l, surface);
- l = next;
- }
free(surface);
}
unsigned int sec, unsigned int usec, void *data)
{
struct wlsc_output *output = data;
- struct wlsc_animate *animate, *next;
struct wlsc_compositor *compositor = output->compositor;
uint32_t msecs;
wl_event_source_timer_update(compositor->timer_source, 5);
compositor->repaint_on_timeout = 1;
- animate = container_of(compositor->animate_list.next, struct wlsc_animate, link);
- while (&animate->link != &compositor->animate_list) {
- next = container_of(animate->link.next,
- struct wlsc_animate, link);
- animate->animate(animate, compositor, compositor->current_frame, msecs);
- animate = next;
- }
-
compositor->current_frame++;
}
else
glClear(GL_COLOR_BUFFER_BIT);
- es = container_of(ec->surface_list.next,
- struct wlsc_surface, link);
- while (&es->link != &ec->surface_list) {
+ wl_list_for_each(es, &ec->surface_list, link)
wlsc_surface_draw(es);
- es = container_of(es->link.next,
- struct wlsc_surface, link);
- }
- eid = container_of(ec->input_device_list.next,
- struct wlsc_input_device, link);
- while (&eid->link != &ec->input_device_list) {
+ wl_list_for_each(eid, &ec->input_device_list, link)
wlsc_surface_draw(eid->sprite);
- eid = container_of(eid->link.next,
- struct wlsc_input_device, link);
- }
-
fd = eglGetDisplayFD(ec->display);
output->current ^= 1;
return;
}
- output = container_of(ec->output_list.next, struct wlsc_output, link);
- while (&output->link != &ec->output_list) {
+ wl_list_for_each(output, &ec->output_list, link)
repaint_output(output);
- output = container_of(output->link.next,
- struct wlsc_output, link);
- }
ec->repaint_needed = 0;
}
return;
fd = eglGetDisplayFD(compositor->display);
- output = container_of(compositor->output_list.next,
- struct wlsc_output, link);
- while (&output->link != &compositor->output_list) {
+ wl_list_for_each(output, &compositor->output_list, link)
drmModePageFlip(fd, output->crtc_id,
output->fb_id[output->current ^ 1],
DRM_MODE_PAGE_FLIP_EVENT, output);
- output = container_of(output->link.next,
- struct wlsc_output, link);
- }
}
static void
return device->grab_surface;
}
- es = container_of(ec->surface_list.prev,
- struct wlsc_surface, link);
- while (&es->link != &ec->surface_list) {
+ wl_list_for_each(es, &ec->surface_list, link)
if (es->map.x <= device->x &&
device->x < es->map.x + es->map.width &&
es->map.y <= device->y &&
return es;
}
- es = container_of(es->link.prev,
- struct wlsc_surface, link);
-
- }
-
return NULL;
}
ioctl(ec->tty_fd, VT_RELDISP, VT_ACKACQ);
ec->vt_active = TRUE;
- output = container_of(ec->output_list.next, struct wlsc_output, link);
- while (&output->link != &ec->output_list) {
+ wl_list_for_each(output, &ec->output_list, link) {
ret = drmModeSetCrtc(fd, output->crtc_id,
output->fb_id[output->current ^ 1], 0, 0,
&output->connector_id, 1, &output->mode);
if (ret)
fprintf(stderr, "failed to set mode for connector %d: %m\n",
output->connector_id);
-
- output = container_of(output->link.next,
- struct wlsc_output, link);
}
}
ec->timer_source = wl_event_loop_add_timer(loop, repaint, ec);
wlsc_compositor_schedule_repaint(ec);
- wl_list_init(&ec->animate_list);
-
return ec;
}
wl_display_post_range(display, client);
- global = container_of(display->global_list.next,
- struct wl_global, link);
- while (&global->link != &display->global_list) {
+ wl_list_for_each(global, &display->global_list, link)
wl_client_post_event(client, &client->display->base,
WL_DISPLAY_GLOBAL,
global->object,
global->object->interface->name,
global->object->interface->version);
- global = container_of(global->link.next,
- struct wl_global, link);
- }
- global = container_of(display->global_list.next,
- struct wl_global, link);
- while (&global->link != &display->global_list) {
+ wl_list_for_each(global, &display->global_list, link)
if (global->func)
global->func(client, global->object);
- global = container_of(global->link.next,
- struct wl_global, link);
- }
return client;
}
{
struct wl_client *client;
- client = container_of(display->pending_frame_list.next,
- struct wl_client, link);
-
- while (&client->link != &display->pending_frame_list) {
+ wl_list_for_each(client, &display->pending_frame_list, link)
wl_client_post_event(client, &compositor->base,
WL_COMPOSITOR_FRAME, frame, msecs);
- client = container_of(client->link.next,
- struct wl_client, link);
- }
wl_list_remove(&display->pending_frame_list);
wl_list_init(&display->pending_frame_list);