handle_shell_client_destroy(struct wl_listener *listener, void *data)
{
shell_client_t *shell_client = pepper_container_of(listener,
- shell_client_t,
+ shell_client,
client_destroy_listener);
remove_ping_timer(shell_client);
if (!target_seat_name)
target_seat_name = "seat0";
- PEPPER_LIST_FOR_EACH(&shell->shseat_list, l)
+ pepper_list_for_each(l, &shell->shseat_list)
{
shseat = l->item;
-
seat_name = pepper_seat_get_name(shseat->seat);
/* Find seat to adding input device */
}
shseat->shell = shell;
-
shseat->link.item = shseat;
+
pepper_list_insert(&shell->shseat_list, &shseat->link);
/* Add this input_device to seat */
desktop_shell_t *shell = data;
pepper_seat_t *seat = info;
shell_seat_t *shseat;
- pepper_list_t *l;
pepper_pointer_t *pointer;
pepper_keyboard_t *keyboard;
pepper_touch_t *touch;
+ pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&shell->shseat_list, l)
+ pepper_list_for_each(l, &shell->shseat_list)
{
shseat = l->item;
PEPPER_ERROR("Memory allocation failed\n");
return ;
}
+
shseat->seat = seat;
shseat->shell = shell;
+ shseat->link.item = shseat;
pepper_list_insert(&shell->shseat_list, &shseat->link);
-
shell_seat_set_default_grab(shseat);
-
- pepper_object_set_user_data((pepper_object_t *)seat,
- shell, shseat, NULL);
+ pepper_object_set_user_data((pepper_object_t *)seat, shell, shseat, NULL);
pointer = pepper_seat_get_pointer(seat);
+
if (pointer)
{
shseat->pointer_motion_listener =
- pepper_object_add_event_listener((pepper_object_t *)pointer, PEPPER_EVENT_POINTER_MOTION,
+ pepper_object_add_event_listener((pepper_object_t *)pointer,
+ PEPPER_EVENT_POINTER_MOTION,
0, pointer_event_handler, shseat);
shseat->pointer_button_listener =
- pepper_object_add_event_listener((pepper_object_t *)pointer, PEPPER_EVENT_POINTER_BUTTON,
+ pepper_object_add_event_listener((pepper_object_t *)pointer,
+ PEPPER_EVENT_POINTER_BUTTON,
0, pointer_event_handler, shseat);
shseat->pointer_axis_listener =
- pepper_object_add_event_listener((pepper_object_t *)pointer, PEPPER_EVENT_POINTER_AXIS,
+ pepper_object_add_event_listener((pepper_object_t *)pointer,
+ PEPPER_EVENT_POINTER_AXIS,
0, pointer_event_handler, shseat);
}
else
{
shseat->pointer_add_listener =
- pepper_object_add_event_listener((pepper_object_t *)seat, PEPPER_EVENT_SEAT_POINTER_ADD,
+ pepper_object_add_event_listener((pepper_object_t *)seat,
+ PEPPER_EVENT_SEAT_POINTER_ADD,
0, seat_logical_device_add_callback, shseat);
shseat->pointer_remove_listener =
- pepper_object_add_event_listener((pepper_object_t *)seat, PEPPER_EVENT_SEAT_POINTER_REMOVE,
+ pepper_object_add_event_listener((pepper_object_t *)seat,
+ PEPPER_EVENT_SEAT_POINTER_REMOVE,
0, seat_logical_device_remove_callback, shseat);
}
{
desktop_shell_t *shell = data;
pepper_seat_t *seat = info;
- shell_seat_t *shseat;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&shell->shseat_list, l)
+ pepper_list_for_each(l, &shell->shseat_list)
{
- shseat = l->item;
+ shell_seat_t *shseat = l->item;
if (shseat->seat == seat)
{
pepper_list_t *l, *p;
p = drm->plane_list.next;
- PEPPER_LIST_FOR_EACH(view_list, l)
+ pepper_list_for_each(l, view_list)
{
pepper_view_t *view = (pepper_view_t *)l->item;
drm_plane_t *plane = (drm_plane_t *)p->item;
set_planes(drm_output_t *output)
{
pepper_list_t *l;
- drm_plane_t *plane;
- drmVBlank vbl;
- PEPPER_LIST_FOR_EACH(&output->drm->plane_list, l)
+ pepper_list_for_each(l, &output->drm->plane_list)
{
- plane = (drm_plane_t *)l->item;
+ drm_plane_t *plane = (drm_plane_t *)l->item;
+ drmVBlank vbl;
if (plane->output != output)
continue;
drm_output_t *output = (drm_output_t *)o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(plane_list, l)
+ pepper_list_for_each(l, plane_list)
{
pepper_plane_t *plane = l->item;
{
pepper_list_t *l, *next;
- PEPPER_LIST_FOR_EACH_SAFE(&drm->plane_list, l, next)
+ pepper_list_for_each_safe(l, next, &drm->plane_list)
{
drm_plane_t *plane = (drm_plane_t *)l->item;
pepper_list_remove(l, NULL);
fbdev_output_t *output = (fbdev_output_t *)o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(view_list, l)
+ pepper_list_for_each(l, view_list)
{
pepper_view_t *view = l->item;
pepper_view_assign_plane(view, output->base, output->primary_plane);
fbdev_output_t *output = (fbdev_output_t *)o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(plane_list, l)
+ pepper_list_for_each(l, plane_list)
{
pepper_plane_t *plane = l->item;
static void
buffer_resource_destroy_handler(struct wl_listener *listener, void *data)
{
- pepper_buffer_t *buffer =
- pepper_container_of(listener, pepper_buffer_t, resource_destroy_listener);
+ pepper_buffer_t *buffer = pepper_container_of(listener, buffer, resource_destroy_listener);
/* Ensure no reference to this buffer. */
PEPPER_ASSERT(buffer->ref_count == 0);
listener = wl_resource_get_destroy_listener(resource, buffer_resource_destroy_handler);
if (listener)
- return pepper_container_of(listener, pepper_buffer_t, resource_destroy_listener);
+ return pepper_container_of(listener, buffer, resource_destroy_listener);
buffer = (pepper_buffer_t *)pepper_object_alloc(PEPPER_OBJECT_BUFFER, sizeof(pepper_buffer_t));
if (!buffer)
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&compositor->output_list, l)
+ pepper_list_for_each(l, &compositor->output_list)
pepper_output_schedule_repaint((pepper_output_t *)l->item);
}
static void
destroy_offer_data_source(struct wl_listener *listener, void *data)
{
- pepper_data_offer_t *offer =
- pepper_container_of(listener, pepper_data_offer_t, source_destroy_listener);
+ pepper_data_offer_t *offer = pepper_container_of(listener, offer, source_destroy_listener);
offer->source = NULL;
}
pepper_list_t *l;
uint32_t caps = 0;
- PEPPER_LIST_FOR_EACH(&seat->input_device_list, l)
+ pepper_list_for_each(l, &seat->input_device_list)
{
pepper_input_device_entry_t *entry = l->item;
caps |= entry->device->caps;
pepper_input_device_entry_t *entry;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&seat->input_device_list, l)
+ pepper_list_for_each(l, &seat->input_device_list)
{
pepper_input_device_entry_t *entry = l->item;
if (entry->device == device)
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&seat->input_device_list, l)
+ pepper_list_for_each(l, &seat->input_device_list)
{
pepper_input_device_entry_t *entry = l->item;
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&object->event_listener_list, l)
+ pepper_list_for_each(l, &object->event_listener_list)
{
pepper_event_listener_t *pos = l->item;
pepper_event_listener_t *listener;
pepper_list_t *l, *tmp;
- PEPPER_LIST_FOR_EACH_SAFE(&object->event_listener_list, l, tmp)
+ pepper_list_for_each_safe(l, tmp, &object->event_listener_list)
{
listener = l->item;
pixman_region32_init(&clip);
- PEPPER_LIST_FOR_EACH_REVERSE(&output->plane_list, l)
+ pepper_list_for_each_reverse(l, &output->plane_list)
{
pepper_plane_t *plane = l->item;
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&output->compositor->view_list, l)
+ pepper_list_for_each(l, &output->compositor->view_list)
pepper_view_update((pepper_view_t *)l->item);
pepper_list_init(&output->view_list);
/* Build a list of views in sorted z-order that are visible on the given output. */
- PEPPER_LIST_FOR_EACH(&output->compositor->view_list, l)
+ pepper_list_for_each(l, &output->compositor->view_list)
{
pepper_view_t *view = l->item;
output->backend->assign_planes(output->data, &output->view_list);
- PEPPER_LIST_FOR_EACH(&output->plane_list, l)
+ pepper_list_for_each(l, &output->plane_list)
pepper_plane_update((pepper_plane_t *)l->item, &output->view_list);
output_accumulate_damage(output);
output->frame.pending = PEPPER_TRUE;
output->frame.scheduled = PEPPER_FALSE;
- PEPPER_LIST_FOR_EACH(&output->view_list, l)
+ pepper_list_for_each(l, &output->view_list)
{
/* TODO: Output time stamp and presentation feedback. */
pepper_view_t *view = l->item;
pepper_output_add_damage_region(pepper_output_t *output, pixman_region32_t *region)
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&output->plane_list, l)
+ pepper_list_for_each(l, &output->plane_list)
pepper_plane_add_damage_region((pepper_plane_t *)l->item, region);
}
return NULL;
}
- PEPPER_LIST_FOR_EACH(&compositor->output_list, l)
+ pepper_list_for_each(l, &compositor->output_list)
{
output = l->item;
pepper_output_t *output;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&compositor->output_list, l)
+ pepper_list_for_each(l, &compositor->output_list)
{
output = l->item;
#define PEPPER_MAX(a, b) ((a) > (b) ? (a) : (b))
#define PEPPER_MIN(a, b) ((a) < (b) ? (a) : (b))
-#define pepper_container_of(ptr, type, member) ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+#define pepper_container_of(ptr, sample, member) \
+ (__typeof__(sample))((char *)(ptr) - offsetof(__typeof__(*sample), member))
#define PEPPER_ARRAY_LENGTH(arr) (sizeof(arr) / sizeof(arr)[0])
typedef struct pepper_list pepper_list_t;
-#define PEPPER_LIST_FOR_EACH(head, pos) \
- for (pos = (head)->next; \
- pos != (head); \
+#define pepper_list_for_each(pos, head) \
+ for (pos = (head)->next; \
+ pos != (head); \
pos = pos->next)
-#define PEPPER_LIST_FOR_EACH_SAFE(head, pos, temp) \
- for (pos = (head)->next, temp = pos->next; \
- pos != (head); \
- pos = temp, temp = pos->next)
+#define pepper_list_for_each_safe(pos, tmp, head) \
+ for (pos = (head)->next, tmp = pos->next; \
+ pos != (head); \
+ pos = tmp, tmp = pos->next)
-#define PEPPER_LIST_FOR_EACH_REVERSE(head, pos) \
- for (pos = (head)->prev; \
- pos != (head); \
+#define pepper_list_for_each_reverse(pos, head) \
+ for (pos = (head)->prev; \
+ pos != (head); \
pos = pos->prev)
-#define PEPPER_LIST_FOR_EACH_REVERSE_SAFE(head, pos, temp) \
- for (pos = (head)->prev, temp = pos->prev; \
- pos != (head); \
- pos = temp, temp = pos->prev)
+#define pepper_list_for_each_reverse_safe(pos, tmp, head) \
+ for (pos = (head)->prev, tmp = pos->prev; \
+ pos != (head); \
+ pos = tmp, tmp = pos->prev)
struct pepper_list
{
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(list, l)
+ pepper_list_for_each(l, list)
{
if (l->item == item)
return l;
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(list, l)
+ pepper_list_for_each(l, list)
{
if (l->item == item)
{
{
pepper_list_t *l, *temp;
- PEPPER_LIST_FOR_EACH_SAFE(list, l, temp)
+ pepper_list_for_each_safe(l, temp, list)
{
if (free_func)
free_func(l->item);
pepper_list_init(&plane->entry_list);
- PEPPER_LIST_FOR_EACH(view_list, l)
+ pepper_list_for_each(l, view_list)
{
pepper_view_t *view = l->item;
pepper_plane_entry_t *entry = &view->plane_entries[plane->output->id];
pixman_region32_init(clip);
- PEPPER_LIST_FOR_EACH_REVERSE(&plane->entry_list, l)
+ pepper_list_for_each_reverse(l, &plane->entry_list)
{
pepper_plane_entry_t *entry = l->item;
pepper_view_t *view = (pepper_view_t *)entry->base.view;
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&plane->entry_list, l)
+ pepper_list_for_each(l, &plane->entry_list)
{
pepper_plane_entry_t *entry = l->item;
pepper_view_assign_plane(entry->base.view, plane->output, NULL);
if (!pixman_region32_not_empty(&surface->damage_region))
return;
- PEPPER_LIST_FOR_EACH(&surface->view_list, l)
+ pepper_list_for_each(l, &surface->view_list)
pepper_view_surface_damage((pepper_view_t *)l->item);
/* TODO: Call backend.urface_flush(). */
if ((flag & PEPPER_VIEW_VISIBILITY_DIRTY) ||
(flag & PEPPER_VIEW_GEOMETRY_DIRTY))
{
- PEPPER_LIST_FOR_EACH(&view->children_list, l)
+ pepper_list_for_each(l, &view->children_list)
view_mark_dirty((pepper_view_t *)l->item, flag);
}
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(&view->children_list, l)
+ pepper_list_for_each(l, &view->children_list)
pos = view_insert((pepper_view_t *)l->item, pos, subtree);
}
view->output_overlap = 0;
- PEPPER_LIST_FOR_EACH(&view->compositor->output_list, l)
+ pepper_list_for_each(l, &view->compositor->output_list)
{
pepper_output_t *output = l->item;
pixman_box32_t box =
for (i = 0; i < PEPPER_MAX_OUTPUT_COUNT; i++)
plane_entry_set_plane(&view->plane_entries[i], NULL);
- PEPPER_LIST_FOR_EACH_SAFE(&view->children_list, l, next)
+ pepper_list_for_each_safe(l, next, &view->children_list)
pepper_view_destroy((pepper_view_t *)(l->item));
if (view->parent)
{
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH_REVERSE(render_list, l)
+ pepper_list_for_each_reverse(l, render_list)
repaint_view(renderer, (pepper_render_item_t *)l->item, damage);
}
}
wayland_output_t *output = (wayland_output_t *)o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(view_list, l)
+ pepper_list_for_each(l, view_list)
{
pepper_view_t *view = l->item;
pepper_view_assign_plane(view, output->base, output->primary_plane);
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(plane_list, l)
+ pepper_list_for_each(l, plane_list)
{
pepper_plane_t *plane = l->item;
}
else
{
- buffer = pepper_container_of(output->shm.free_buffers.next, wayland_shm_buffer_t, link);
+ buffer = pepper_container_of(output->shm.free_buffers.next, buffer, link);
wl_list_remove(&buffer->link);
}
x11_output_t *output = (x11_output_t *)o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(view_list, l)
+ pepper_list_for_each(l, view_list)
{
pepper_view_t *view = l->item;
pepper_view_assign_plane(view, output->base, output->primary_plane);
x11_output_t *output = o;
pepper_list_t *l;
- PEPPER_LIST_FOR_EACH(plane_list, l)
+ pepper_list_for_each(l, plane_list)
{
pepper_plane_t *plane = l->item;