#include <libds/keyboard.h>
#include <libds/touch.h>
+#include "util.h"
+
#define UNUSED __attribute__((unused))
struct keyboard_device
#include <assert.h>
+#include "util.h"
#include "addon.h"
void
{
struct ds_addon *iter;
- assert(owner && impl);
+ DS_ASSERT(owner && impl);
wl_list_for_each(iter, &set->addons, link) {
- if (iter->owner == addon->owner && iter->impl == addon->impl)
- assert(0 && "Can't have two addons of the same type with the same owner");
+ DS_ASSERT(iter->owner == addon->owner && iter->impl == addon->impl);
}
wl_list_insert(&set->addons, &addon->link);
static struct ds_shm_allocator *
shm_allocator_from_allocator(struct ds_allocator *ds_allocator)
{
- assert(ds_allocator->iface == &shm_allocator_iface);
+ DS_ASSERT(ds_allocator->iface == &shm_allocator_iface);
return (struct ds_shm_allocator *)ds_allocator;
}
static struct ds_shm_buffer *
shm_buffer_from_buffer(struct ds_buffer *buffer)
{
- assert(buffer->iface == &shm_buffer_interface);
+ DS_ASSERT(buffer->iface == &shm_buffer_interface);
return (struct ds_shm_buffer *)buffer;
}
#include "libds/log.h"
+#include "util.h"
#include "backend.h"
static const struct ds_backend_interface libinput_backend_interface;
WL_EXPORT struct ds_libinput_backend *
libinput_backend_from_backend(struct ds_backend *backend)
{
- assert(backend->iface == &libinput_backend_interface);
+ DS_ASSERT(backend->iface == &libinput_backend_interface);
return (struct ds_libinput_backend *)backend;
}
#include <assert.h>
#include "libds/log.h"
+#include "util.h"
#include "backend.h"
static const struct ds_input_device_interface input_device_iface;
static struct ds_libinput_input_device *
get_libinput_input_device_from_input_device(struct ds_input_device *ds_dev)
{
- assert(ds_input_device_is_libinput(ds_dev));
+ DS_ASSERT(ds_input_device_is_libinput(ds_dev));
return (struct ds_libinput_input_device *)ds_dev;
}
#include "libds/output.h"
#include "xdg-shell-client-protocol.h"
+#include "util.h"
#include "backend.h"
static const struct ds_backend_interface wl_backend_interface;
struct ds_wl_backend *
wl_backend_from_backend(struct ds_backend *backend)
{
- assert(backend->iface == &wl_backend_interface);
+ DS_ASSERT(backend->iface == &wl_backend_interface);
return (struct ds_wl_backend *)backend;
}
#include "libds/output.h"
#include "xdg-shell-client-protocol.h"
+#include "util.h"
#include "output.h"
#include "backend.h"
static struct ds_wl_output *
wl_output_from_output(struct ds_output *ds_output)
{
- assert(ds_output->iface == &wl_output_iface);
+ DS_ASSERT(ds_output->iface == &wl_output_iface);
return (struct ds_wl_output *)ds_output;
}
-#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static struct ds_wl_input_device *
get_wl_input_device_from_input_device(struct ds_input_device *ds_dev)
{
- assert(ds_input_device_is_wl(ds_dev));
+ DS_ASSERT(ds_input_device_is_wl(ds_dev));
return (struct ds_wl_input_device *)ds_dev;
}
static struct ds_wl_pointer *
get_wl_pointer_from_pointer(struct ds_pointer *ds_pointer)
{
- assert(ds_pointer->iface == &pointer_iface);
+ DS_ASSERT(ds_pointer->iface == &pointer_iface);
return (struct ds_wl_pointer *)ds_pointer;
}
static struct ds_wl_keyboard *
get_wl_keyboard_from_keyboard(struct ds_keyboard *ds_keyboard)
{
- assert(ds_keyboard->iface == &keyboard_iface);
+ DS_ASSERT(ds_keyboard->iface == &keyboard_iface);
return (struct ds_wl_keyboard *)ds_keyboard;
}
static struct ds_wl_touch *
get_wl_touch_from_touch(struct ds_touch *ds_touch)
{
- assert(ds_touch->iface == &touch_iface);
+ DS_ASSERT(ds_touch->iface == &touch_iface);
return (struct ds_wl_touch *)ds_touch;
}
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
#include "libds/interfaces/buffer.h"
+#include "util.h"
#include "buffer.h"
#include "client_buffer.h"
struct ds_buffer *buffer;
const struct ds_buffer_resource_interface *iface;
- assert(resource && ds_resource_is_buffer(resource));
+ DS_ASSERT(resource && ds_resource_is_buffer(resource));
if (wl_shm_buffer_get(resource) != NULL) {
struct ds_shm_client_buffer *shm_client_buffer =
WL_EXPORT void
ds_buffer_drop(struct ds_buffer *buffer)
{
- assert(!buffer->dropped);
+ DS_ASSERT(!buffer->dropped);
buffer->dropped = true;
ds_dbg("Buffer(%p) dropped: n_locks(%zu)", buffer, buffer->n_locks);
buffer_consider_destroy(buffer);
WL_EXPORT void
ds_buffer_unlock(struct ds_buffer *buffer)
{
- assert(buffer->n_locks > 0);
+ DS_ASSERT(buffer->n_locks > 0);
buffer->n_locks--;
ds_dbg("Buffer(%p) n_locks(%zu)", buffer, buffer->n_locks);
ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride)
{
- assert(!buffer->accessing_data_ptr);
+ DS_ASSERT(!buffer->accessing_data_ptr);
if (!buffer->iface->begin_data_ptr_access)
return false;
if (!buffer->iface->begin_data_ptr_access(buffer,
WL_EXPORT void
ds_buffer_end_data_ptr_access(struct ds_buffer *buffer)
{
- assert(buffer->accessing_data_ptr);
+ DS_ASSERT(buffer->accessing_data_ptr);
buffer->iface->end_data_ptr_access(buffer);
buffer->accessing_data_ptr = false;
}
{
const struct ds_buffer_resource_interface **iface_ptr;
- assert(iface);
- assert(iface->is_instance);
- assert(iface->from_resource);
+ DS_ASSERT(iface);
+ DS_ASSERT(iface->is_instance);
+ DS_ASSERT(iface->from_resource);
wl_array_for_each(iface_ptr, &buffer_resource_interfaces) {
if (*iface_ptr == iface) {
if (!buffer->dropped || buffer->n_locks > 0)
return;
- assert(!buffer->accessing_data_ptr);
+ DS_ASSERT(!buffer->accessing_data_ptr);
wl_signal_emit(&buffer->events.destroy, NULL);
buffer->iface->destroy(buffer);
-#include <assert.h>
#include <stdlib.h>
#include <drm_fourcc.h>
#include "libds/log.h"
+#include "util.h"
#include "pixel_format.h"
#include "buffer.h"
#include "client_buffer.h"
static struct ds_shm_client_buffer *
shm_client_buffer_from_buffer(struct ds_buffer *buffer)
{
- assert(buffer->iface == &shm_client_buffer_iface);
+ DS_ASSERT(buffer->iface == &shm_client_buffer_iface);
return (struct ds_shm_client_buffer *)buffer;
}
int32_t height;
shm_buffer = wl_shm_buffer_get(resource);
- assert(shm_buffer);
+ DS_ASSERT(shm_buffer);
width = wl_shm_buffer_get_width(shm_buffer);
height = wl_shm_buffer_get_height(shm_buffer);
#include <strings.h>
#include "libds/log.h"
+#include "util.h"
#include "data_device_private.h"
static const struct wl_data_offer_interface data_offer_iface;
wl_list_insert(&data_device->drag_offers, &offer->link);
break;
default:
- assert(0 && "cannot reach here");
+ DS_ASSERT_NOT_REACHED();
break;
}
{
uint32_t action;
- assert(offer->type == DS_DATA_OFFER_DRAG);
+ DS_ASSERT(offer->type == DS_DATA_OFFER_DRAG);
action = data_offer_choose_action(offer);
if (offer->source->current_dnd_action == action)
-#include <assert.h>
#include <stdlib.h>
+#include "util.h"
#include "data_device_private.h"
void
ds_data_source_init(struct ds_data_source *source,
const struct ds_data_source_interface *iface)
{
- assert(iface->send);
+ DS_ASSERT(iface->send);
source->iface = iface;
source->actions = -1;
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
+#include "util.h"
#include "data_device_private.h"
static const struct wl_data_source_interface wl_data_source_iface;
static struct ds_data_source_client *
data_source_client_from_data_source(struct ds_data_source *ds_source)
{
- assert(ds_source->iface->accept == data_source_client_iface_accept);
+ DS_ASSERT(ds_source->iface->accept == data_source_client_iface_accept);
return (struct ds_data_source_client *)ds_source;
}
struct ds_data_source_client *source;
source = data_source_client_from_data_source(ds_source);
- assert(wl_resource_get_version(source->resource) >=
+ DS_ASSERT(wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION);
wl_data_source_send_dnd_drop_performed(source->resource);
}
struct ds_data_source_client *source;
source = data_source_client_from_data_source(ds_source);
- assert(wl_resource_get_version(source->resource) >=
+ DS_ASSERT(wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION);
wl_data_source_send_dnd_finished(source->resource);
}
struct ds_data_source_client *source;
source = data_source_client_from_data_source(ds_source);
- assert(wl_resource_get_version(source->resource) >=
+ DS_ASSERT(wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION);
wl_data_source_send_action(source->resource, action);
}
-#include <assert.h>
#include <stdlib.h>
+
+#include "util.h"
#include "data_device_private.h"
static const struct ds_pointer_grab_interface drag_pointer_grab_iface;
static void
drag_start(struct ds_drag *drag, uint32_t serial)
{
- assert(!drag->started);
+ DS_ASSERT(!drag->started);
drag->started = true;
ds_seat_keyboard_start_grab(drag->seat, &drag->keyboard_grab);
struct ds_data_device *data_device;
struct wl_resource *resource;
- assert(drag->focused_client);
+ DS_ASSERT(drag->focused_client);
drag->dropped = true;
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
#include "libds/output.h"
#include "libds/interfaces/output.h"
+#include "util.h"
+
#define OUTPUT_VERSION 3
static void output_handle_display_destroy(struct wl_listener *listener,
ds_output_init(struct ds_output *output, struct ds_backend *backend,
const struct ds_output_interface *iface, struct wl_display *display)
{
- assert(iface->commit);
+ DS_ASSERT(iface->commit);
output->backend = backend;
output->iface = iface;
-#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <pixman.h>
#include "libds/log.h"
+#include "util.h"
#include "region.h"
static const struct wl_region_interface region_impl;
pixman_region32_t *
ds_region_from_resource(struct wl_resource *resource)
{
- assert(wl_resource_instance_of(resource, &wl_region_interface,
+ DS_ASSERT(wl_resource_instance_of(resource, &wl_region_interface,
®ion_impl));
return wl_resource_get_user_data(resource);
}
break;
default:
ds_err("Unknown transform value(%d)", transform);
- assert(0 && "Cannot reach here");
+ DS_ASSERT_NOT_REACHED();
break;
}
}
#include "config.h"
-#include <assert.h>
#define _POSIX_C_SOURCE 200809L
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "libds/log.h"
+#include "util.h"
#include "data_device.h"
#include "seat_private.h"
WL_EXPORT struct ds_seat_client *
ds_seat_client_from_resource(struct wl_resource *resource)
{
- assert(wl_resource_instance_of(resource, &wl_seat_interface, &seat_impl));
+ DS_ASSERT(wl_resource_instance_of(resource, &wl_seat_interface, &seat_impl));
return wl_resource_get_user_data(resource);
}
-#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
+#include "util.h"
#include "seat_private.h"
static const struct ds_pointer_grab_interface default_pointer_grab_iface;
{
struct ds_seat_pointer_grab *grab = seat->pointer.grab;
- assert(surface);
+ DS_ASSERT(surface);
grab->iface->enter(grab, surface, sx, sy);
}
return;
if (pointer->sent_axis_source) {
- assert(pointer->cached_axis_source == source);
+ DS_ASSERT(pointer->cached_axis_source == source);
}
else {
pointer->sent_axis_source = true;
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "libds/log.h"
+#include "util.h"
#include "shell.h"
static const struct wl_shell_surface_interface shell_surface_impl;
// TODO
break;
case DS_SHELL_SURFACE_ROLE_NONE:
- assert(false && "not reached");
+ DS_ASSERT_NOT_REACHED();
}
wl_list_for_each_safe(configure, tmp, &shell_surface->configure_list, link)
static void
create_shell_surface_toplevel(struct ds_shell_surface *shell_surface)
{
- assert(shell_surface->toplevel == NULL);
+ DS_ASSERT(shell_surface->toplevel == NULL);
shell_surface->toplevel = calloc(1, sizeof *shell_surface->toplevel);
if (!shell_surface->toplevel) {
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
#include "libds/surface.h"
+#include "util.h"
#include "surface-private.h"
static const struct wl_subsurface_interface subsurface_impl;
WL_EXPORT struct ds_subsurface *
ds_subsurface_from_resource(struct wl_resource *resource)
{
- assert(wl_resource_instance_of(resource, &wl_subsurface_interface,
+ DS_ASSERT(wl_resource_instance_of(resource, &wl_subsurface_interface,
&subsurface_impl));
return wl_resource_get_user_data(resource);
}
struct ds_subsurface *
ds_subsurface_from_ds_surface(struct ds_surface *surface)
{
- assert(ds_surface_is_subsurface(surface));
+ DS_ASSERT(ds_surface_is_subsurface(surface));
return (struct ds_subsurface *)surface->role_data;
}
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
WL_EXPORT struct ds_surface *
ds_surface_from_resource(struct wl_resource *resource)
{
- assert(wl_resource_instance_of(resource, &wl_surface_interface,
+ DS_ASSERT(wl_resource_instance_of(resource, &wl_surface_interface,
&surface_impl));
return wl_resource_get_user_data(resource);
}
const struct ds_surface_role *role, void *role_data,
struct wl_resource *error_resource, uint32_t error_code)
{
- assert(role != NULL);
+ DS_ASSERT(role != NULL);
if (surface->role != NULL && surface->role != role) {
ds_err("Cannot assign role %s to ds_surface(%p) "
WL_EXPORT void
ds_surface_viewport_release(struct ds_surface_viewport *vp_handle)
{
- assert(vp_handle->taken == true);
+ DS_ASSERT(vp_handle->taken == true);
vp_handle->taken = false;
}
{
struct ds_surface *surface;
- assert(vp_handle->taken == true);
- assert(x >= 0 && y >= 0 && width > 0 && height > 0);
+ DS_ASSERT(vp_handle->taken == true);
+ DS_ASSERT(x >= 0 && y >= 0 && width > 0 && height > 0);
surface = wl_container_of(vp_handle, surface, viewport_handle);
surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
{
struct ds_surface *surface;
- assert(vp_handle->taken == true);
+ DS_ASSERT(vp_handle->taken == true);
surface = wl_container_of(vp_handle, surface, viewport_handle);
surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
{
struct ds_surface *surface;
- assert(vp_handle->taken == true);
- assert(width > 0 && height > 0);
+ DS_ASSERT(vp_handle->taken == true);
+ DS_ASSERT(width > 0 && height > 0);
surface = wl_container_of(vp_handle, surface, viewport_handle);
surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
{
struct ds_surface *surface;
- assert(vp_handle->taken == true);
+ DS_ASSERT(vp_handle->taken == true);
surface = wl_container_of(vp_handle, surface, viewport_handle);
surface->pending.committed |= DS_SURFACE_STATE_VIEWPORT;
-#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include "libds/log.h"
#include "libds/allocator.h"
+#include "util.h"
+
#define DS_SWAPCHAIN_CAP 4
struct ds_swapchain_slot
struct ds_swapchain_slot *slot;
size_t i;
- assert(buffer);
+ DS_ASSERT(buffer);
if (!swapchain_has_buffer(swapchain, buffer))
return;
swapchain_slot_acquire(struct ds_swapchain *swapchain, struct ds_swapchain_slot *slot,
int *age)
{
- assert(!slot->acquired);
- assert(slot->buffer);
+ DS_ASSERT(!slot->acquired);
+ DS_ASSERT(slot->buffer);
slot->acquired = true;
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
+#include "util.h"
#include "xdg_shell.h"
static const struct xdg_surface_interface xdg_surface_impl;
// TODO
break;
case DS_XDG_SURFACE_ROLE_NONE:
- assert(false && "not reached");
+ DS_ASSERT_NOT_REACHED();
}
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link)
case DS_XDG_SURFACE_ROLE_POPUP:
break;
default:
- assert(0 && "not reached");
+ DS_ASSERT_NOT_REACHED();
break;
}
switch (surface->role) {
case DS_XDG_SURFACE_ROLE_NONE:
- assert(0 && "not reached");
+ DS_ASSERT_NOT_REACHED();
break;
case DS_XDG_SURFACE_ROLE_TOPLEVEL:
send_xdg_toplevel_configure(surface, configure);
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include "util.h"
#include "xdg_shell.h"
static const struct ds_surface_role xdg_toplevel_surface_role =
WL_EXPORT uint32_t
ds_xdg_toplevel_set_activated(struct ds_xdg_surface *surface, bool activated)
{
- assert(surface->role == DS_XDG_SURFACE_ROLE_TOPLEVEL);
+ DS_ASSERT(surface->role == DS_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.activated = activated;
return ds_xdg_surface_schedule_configure(surface);
return;
}
- assert(surface->toplevel == NULL);
+ DS_ASSERT(surface->toplevel == NULL);
surface->toplevel = calloc(1, sizeof *surface->toplevel);
if (!surface->toplevel) {
-#include <assert.h>
#include <stdlib.h>
#include "libds/log.h"
+#include "util.h"
#include "xdg_shell_v6.h"
static const struct zxdg_surface_v6_interface xdg_surface_v6_impl;
// TODO
break;
case DS_XDG_SURFACE_V6_ROLE_NONE:
- assert(false && "not reached");
+ DS_ASSERT_NOT_REACHED();
}
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link)
case DS_XDG_SURFACE_V6_ROLE_POPUP:
break;
default:
- assert(0 && "not reached");
+ DS_ASSERT_NOT_REACHED();
break;
}
switch (surface->role) {
case DS_XDG_SURFACE_V6_ROLE_NONE:
- assert(0 && "not reached");
+ DS_ASSERT_NOT_REACHED();
break;
case DS_XDG_SURFACE_V6_ROLE_TOPLEVEL:
send_xdg_toplevel_v6_configure(surface, configure);
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include "util.h"
#include "xdg_shell_v6.h"
static const struct ds_surface_role xdg_toplevel_v6_surface_role =
return;
}
- assert(surface->toplevel == NULL);
+ DS_ASSERT(surface->toplevel == NULL);
surface->toplevel = calloc(1, sizeof *surface->toplevel);
if (!surface->toplevel) {