From d6c0be1bfe70ede248dbbfe1f752f43776d97560 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Fri, 4 Mar 2022 14:25:20 +0900 Subject: [PATCH] Fix formatting Change-Id: I01c89e5adaa5180a116cc61fedce055bb90290bd --- src/libds/allocator.c | 1 + src/libds/allocator/shm.c | 9 ++++++--- src/libds/allocator/tbm.c | 6 +++--- src/libds/backend.c | 4 +++- src/libds/backend/tdm/backend.c | 14 ++++++------- src/libds/backend/tdm/output.c | 13 ++++++------ src/libds/backend/tdm/tdm.h | 1 + src/libds/backend/wayland/backend.c | 17 ++++++++-------- src/libds/backend/wayland/output.c | 11 ++++++---- src/libds/buffer.c | 12 ++++++----- src/libds/client_buffer.h | 3 ++- src/libds/client_buffer/shm_client_buffer.c | 11 ++++++---- src/libds/compositor.c | 12 +++++++---- src/libds/log.c | 9 +++++++-- src/libds/pixel_format.c | 1 + src/libds/presentation.c | 7 ++++--- src/libds/region.c | 9 +++++---- src/libds/subcompositor.c | 11 ++++++---- src/libds/surface/subsurface.c | 7 +++++-- src/libds/surface/surface-private.h | 1 + src/libds/surface/surface.c | 31 +++++++++++++++++++---------- src/libds/swapchain.c | 2 +- src/libds/util/time.c | 4 +++- src/libds/xdg_shell/xdg_shell.c | 17 ++++++++-------- src/libds/xdg_shell/xdg_shell.h | 2 +- src/libds/xdg_shell/xdg_surface.c | 4 +++- src/libds/xdg_shell/xdg_toplevel.c | 14 +++++++------ 27 files changed, 142 insertions(+), 91 deletions(-) diff --git a/src/libds/allocator.c b/src/libds/allocator.c index 34c0aa7..c9769be 100644 --- a/src/libds/allocator.c +++ b/src/libds/allocator.c @@ -1,5 +1,6 @@ #include #include + #include #include "libds/log.h" diff --git a/src/libds/allocator/shm.c b/src/libds/allocator/shm.c index a0acd0c..3fad474 100644 --- a/src/libds/allocator/shm.c +++ b/src/libds/allocator/shm.c @@ -2,6 +2,7 @@ #include #include #include + #include #include @@ -127,6 +128,7 @@ shm_allocator_create_buffer(struct ds_allocator *ds_allocator, int width, int height, uint32_t format) { struct ds_shm_buffer *buffer; + int bytes_per_pixel, stride; buffer = calloc(1, sizeof *buffer); if (!buffer) @@ -135,8 +137,8 @@ shm_allocator_create_buffer(struct ds_allocator *ds_allocator, ds_buffer_init(&buffer->base, &shm_buffer_interface, width, height); // FIXME - int bytes_per_pixel = 4; - int stride = width * bytes_per_pixel; + bytes_per_pixel = 4; + stride = width * bytes_per_pixel; buffer->size = stride * height; buffer->shm.fd = allocate_shm_file(buffer->size); if (buffer->shm.fd < 0) { @@ -164,7 +166,8 @@ shm_allocator_create_buffer(struct ds_allocator *ds_allocator, return &buffer->base; } -static const struct ds_allocator_interface shm_allocator_iface = { +static const struct ds_allocator_interface shm_allocator_iface = +{ .destroy = shm_allocator_destroy, .create_buffer = shm_allocator_create_buffer, }; diff --git a/src/libds/allocator/tbm.c b/src/libds/allocator/tbm.c index f4d0702..dc3be42 100644 --- a/src/libds/allocator/tbm.c +++ b/src/libds/allocator/tbm.c @@ -1,8 +1,8 @@ #include #include + #include #include - #include #include @@ -136,7 +136,6 @@ static const struct ds_buffer_interface tbm_buffer_iface = .end_data_ptr_access = tbm_buffer_end_data_ptr_access, }; - static void tbm_allocator_destroy(struct ds_allocator *ds_allocator) { @@ -171,7 +170,8 @@ tbm_allocator_create_buffer(struct ds_allocator *ds_allocator, return &buffer->base; } -static const struct ds_allocator_interface tbm_allocator_iface = { +static const struct ds_allocator_interface tbm_allocator_iface = +{ .destroy = tbm_allocator_destroy, .create_buffer = tbm_allocator_create_buffer, }; diff --git a/src/libds/backend.c b/src/libds/backend.c index d52a8d2..ee2a912 100644 --- a/src/libds/backend.c +++ b/src/libds/backend.c @@ -1,4 +1,5 @@ #include + #include #include "libds/interfaces/backend.h" @@ -41,7 +42,8 @@ ds_backend_add_new_output_listener(struct ds_backend *backend, } void -ds_backend_init(struct ds_backend *backend, const struct ds_backend_interface *iface) +ds_backend_init(struct ds_backend *backend, + const struct ds_backend_interface *iface) { backend->iface = iface; wl_signal_init(&backend->events.destroy); diff --git a/src/libds/backend/tdm/backend.c b/src/libds/backend/tdm/backend.c index c893702..e756ac1 100644 --- a/src/libds/backend/tdm/backend.c +++ b/src/libds/backend/tdm/backend.c @@ -2,9 +2,11 @@ #include #include "libds/log.h" + #include "tdm.h" static const struct ds_backend_interface tdm_backend_iface; + static void tdm_backend_handle_display_destroy(struct wl_listener *listener, void *data); static void tdm_backend_destroy(struct ds_tdm_backend *tdm); @@ -79,13 +81,11 @@ tdm_backend_destroy(struct ds_tdm_backend *tdm) struct ds_tdm_output *output, *tmp_output; struct ds_tdm_buffer *buffer, *tmp_buffer; - wl_list_for_each_safe(output, tmp_output, &tdm->outputs, link) { + wl_list_for_each_safe(output, tmp_output, &tdm->outputs, link) ds_output_destroy(&output->base); - } - wl_list_for_each_safe(buffer, tmp_buffer, &tdm->buffers, link) { + wl_list_for_each_safe(buffer, tmp_buffer, &tdm->buffers, link) destroy_tdm_buffer(buffer); - } wl_list_remove(&tdm->display_destroy.link); wl_event_source_remove(tdm->tdm_event); @@ -149,7 +149,8 @@ tdm_backend_iface_destroy(struct ds_backend *backend) tdm_backend_destroy(tdm); } -static const struct ds_backend_interface tdm_backend_iface = { +static const struct ds_backend_interface tdm_backend_iface = +{ .start = tdm_backend_iface_start, .destroy = tdm_backend_iface_destroy, .get_drm_fd = NULL, @@ -167,9 +168,8 @@ tdm_backend_handle_display_destroy(struct wl_listener *listener, void *data) static int tdm_backend_handle_tdm_event(int fd, uint32_t mask, void *data) { - struct ds_tdm_backend *tdm; + struct ds_tdm_backend *tdm = data; - tdm = data; tdm_display_handle_events(tdm->tdm_display); return 0; diff --git a/src/libds/backend/tdm/output.c b/src/libds/backend/tdm/output.c index a05d2c9..958b8ce 100644 --- a/src/libds/backend/tdm/output.c +++ b/src/libds/backend/tdm/output.c @@ -1,10 +1,12 @@ #include #include +#include + #include "libds/log.h" #include "libds/allocator/tbm.h" + #include "tdm.h" -#include static const struct ds_output_interface tdm_output_iface; static bool output_init_modes(struct ds_tdm_output *output); @@ -114,9 +116,8 @@ create_tdm_buffer(struct ds_tdm_backend *backend, struct ds_buffer *ds_buffer) } buffer = calloc(1, sizeof *buffer); - if (!buffer) { + if (!buffer) return NULL; - } buffer->surface = surface; buffer->buffer = ds_buffer_lock(ds_buffer); @@ -241,7 +242,7 @@ output_init_modes(struct ds_tdm_output *output) return false; } - ds_inf("Detected modes:"); + ds_dbg("Detected modes:"); for (i = 0; i < num_modes; i++) { tdm_mode = &tdm_modes[i]; @@ -333,9 +334,7 @@ static void output_hwc_commit_handler(tdm_hwc *hwc, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) { - struct ds_tdm_output *output; - - output = user_data; + struct ds_tdm_output *output = user_data; output_update_front_buffer(output); diff --git a/src/libds/backend/tdm/tdm.h b/src/libds/backend/tdm/tdm.h index 2b1c1e4..1c80ef9 100644 --- a/src/libds/backend/tdm/tdm.h +++ b/src/libds/backend/tdm/tdm.h @@ -2,6 +2,7 @@ #define DS_BACKEND_TDM_H #include + #include #include "libds/interfaces/backend.h" diff --git a/src/libds/backend/wayland/backend.c b/src/libds/backend/wayland/backend.c index 9b6cd3a..778ca1c 100644 --- a/src/libds/backend/wayland/backend.c +++ b/src/libds/backend/wayland/backend.c @@ -1,15 +1,16 @@ #include #include #include + #include #include -#include "backend.h" #include "libds/log.h" #include "libds/output.h" - #include "xdg-shell-client-protocol.h" +#include "backend.h" + static const struct ds_backend_interface wl_backend_interface; static void wl_backend_handle_display_destroy(struct wl_listener *listener, void *data); @@ -86,13 +87,11 @@ wl_backend_destroy(struct ds_wl_backend *backend) ds_dbg("Destroy wayland backend(%p)", backend); - wl_list_for_each_safe(output, tmp_output, &backend->outputs, link) { + wl_list_for_each_safe(output, tmp_output, &backend->outputs, link) ds_output_destroy(&output->base); - } - wl_list_for_each_safe(buffer, tmp_buffer, &backend->buffers, link) { + wl_list_for_each_safe(buffer, tmp_buffer, &backend->buffers, link) destroy_wl_buffer(buffer); - } ds_backend_finish(&backend->base); @@ -118,7 +117,8 @@ wl_backend_iface_destroy(struct ds_backend *backend) wl_backend_destroy(wl_backend); } -static const struct ds_backend_interface wl_backend_interface = { +static const struct ds_backend_interface wl_backend_interface = +{ .start = NULL, .destroy = wl_backend_iface_destroy, .get_drm_fd = NULL, @@ -185,7 +185,8 @@ registry_handle_global_remove(void *data, struct wl_registry *registry, // TODO } -static const struct wl_registry_listener registry_listener = { +static const struct wl_registry_listener registry_listener = +{ .global = registry_handle_global, .global_remove = registry_handle_global_remove, }; diff --git a/src/libds/backend/wayland/output.c b/src/libds/backend/wayland/output.c index b411dad..bc18875 100644 --- a/src/libds/backend/wayland/output.c +++ b/src/libds/backend/wayland/output.c @@ -1,13 +1,14 @@ #include #include + #include -#include "backend.h" #include "libds/log.h" #include "libds/output.h" - #include "xdg-shell-client-protocol.h" +#include "backend.h" + const struct ds_output_interface wl_output_iface; static const struct xdg_surface_listener wl_output_xdg_surface_listener; static const struct xdg_toplevel_listener wl_output_xdg_toplevel_listener; @@ -154,7 +155,8 @@ buffer_handle_release(void *data, struct wl_buffer *wl_buffer) ds_buffer_unlock(buffer->buffer); } -static const struct wl_buffer_listener buffer_listener = { +static const struct wl_buffer_listener buffer_listener = +{ .release = buffer_handle_release, }; @@ -223,7 +225,8 @@ surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) wl_signal_emit(&output->base.events.frame, &output->base); } -static const struct wl_callback_listener frame_listener = { +static const struct wl_callback_listener frame_listener = +{ .done = surface_frame_callback }; diff --git a/src/libds/buffer.c b/src/libds/buffer.c index 167d3a7..60b9925 100644 --- a/src/libds/buffer.c +++ b/src/libds/buffer.c @@ -1,11 +1,12 @@ #include #include -#include "buffer.h" -#include "client_buffer.h" #include "libds/log.h" #include "libds/interfaces/buffer.h" +#include "buffer.h" +#include "client_buffer.h" + static struct wl_array buffer_resource_interfaces = {0}; static void buffer_consider_destroy(struct ds_buffer *buffer); @@ -14,8 +15,8 @@ static const struct ds_buffer_resource_interface * get_buffer_resource_iface(struct wl_resource *resource); WL_EXPORT void -ds_buffer_init(struct ds_buffer *buffer, const struct ds_buffer_interface *iface, - int width, int height) +ds_buffer_init(struct ds_buffer *buffer, + const struct ds_buffer_interface *iface, int width, int height) { buffer->iface = iface; buffer->width = width; @@ -99,7 +100,8 @@ ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, uint32_t flags, assert(!buffer->accessing_data_ptr); if (!buffer->iface->begin_data_ptr_access) return false; - if (!buffer->iface->begin_data_ptr_access(buffer, flags, data, format, stride)) + if (!buffer->iface->begin_data_ptr_access(buffer, + flags, data, format, stride)) return false; buffer->accessing_data_ptr = true; return true; diff --git a/src/libds/client_buffer.h b/src/libds/client_buffer.h index cf390aa..a2aef6a 100644 --- a/src/libds/client_buffer.h +++ b/src/libds/client_buffer.h @@ -3,10 +3,11 @@ #include -#include "util.h" #include "libds/buffer.h" #include "libds/interfaces/buffer.h" +#include "util.h" + struct ds_shm_client_buffer { struct ds_buffer base; diff --git a/src/libds/client_buffer/shm_client_buffer.c b/src/libds/client_buffer/shm_client_buffer.c index 14bb745..6d52fb9 100644 --- a/src/libds/client_buffer/shm_client_buffer.c +++ b/src/libds/client_buffer/shm_client_buffer.c @@ -1,10 +1,12 @@ #include #include + #include +#include "libds/log.h" + #include "pixel_format.h" #include "buffer.h" -#include "libds/log.h" #include "client_buffer.h" static void @@ -37,7 +39,6 @@ shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, struct ds_shm_client_buffer *buffer; buffer = wl_container_of(listener, buffer, listener.resource_destroy); - buffer->resource = NULL; buffer->shm_buffer = NULL; wl_list_remove(&buffer->listener.resource_destroy.link); @@ -83,8 +84,9 @@ shm_client_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, *data = wl_shm_buffer_get_data(buffer->shm_buffer); wl_shm_buffer_begin_access(buffer->shm_buffer); } - else + else { return false; + } return true; } @@ -99,7 +101,8 @@ shm_client_buffer_end_data_ptr_access(struct ds_buffer *ds_buffer) wl_shm_buffer_end_access(buffer->shm_buffer); } -static const struct ds_buffer_interface shm_client_buffer_iface = { +static const struct ds_buffer_interface shm_client_buffer_iface = +{ .destroy = shm_client_buffer_destroy, .begin_data_ptr_access = shm_client_buffer_begin_data_ptr_access, .end_data_ptr_access = shm_client_buffer_end_data_ptr_access, diff --git a/src/libds/compositor.c b/src/libds/compositor.c index 64dd363..64b9a99 100644 --- a/src/libds/compositor.c +++ b/src/libds/compositor.c @@ -2,6 +2,7 @@ #include #include "libds/log.h" + #include "subcompositor.h" #include "surface.h" #include "region.h" @@ -85,9 +86,10 @@ static void compositor_handle_create_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id) { - struct ds_compositor *compositor = wl_resource_get_user_data(resource); + struct ds_compositor *compositor; struct ds_surface *surface; + compositor = wl_resource_get_user_data(resource); surface = ds_surface_create(client, wl_resource_get_version(resource), id); if (!surface) { @@ -105,7 +107,8 @@ compositor_handle_create_region(struct wl_client *client, ds_region_add(client, wl_resource_get_version(resource), id); } -static const struct wl_compositor_interface compositor_impl = { +static const struct wl_compositor_interface compositor_impl = +{ .create_surface = compositor_handle_create_surface, .create_region = compositor_handle_create_region, }; @@ -130,8 +133,9 @@ static void compositor_bind(struct wl_client *client, void *data, static void compositor_handle_display_destroy(struct wl_listener *listener, void *data) { - struct ds_compositor *compositor = - wl_container_of(listener, compositor, display_destroy); + struct ds_compositor *compositor; + + compositor = wl_container_of(listener, compositor, display_destroy); ds_dbg("Destroy compositor(%p)", compositor); diff --git a/src/libds/log.c b/src/libds/log.c index 2777f9a..67386af 100644 --- a/src/libds/log.c +++ b/src/libds/log.c @@ -4,6 +4,7 @@ #include #include #include + #include #include "libds/log.h" @@ -51,6 +52,7 @@ WL_EXPORT void _ds_log(enum ds_log_level level, const char *fmt, ...) { va_list args; + va_start(args, fmt); log_callback(level, fmt, args); va_end(args); @@ -66,11 +68,12 @@ static void log_stderr(enum ds_log_level level, const char *fmt, va_list args) { bool colored_tty = false; + unsigned c; if (level > log_level) return; - unsigned c = (level < DS_LOG_LEVEL_LAST) ? level : DS_LOG_LEVEL_LAST - 1; + c = (level < DS_LOG_LEVEL_LAST) ? level : DS_LOG_LEVEL_LAST - 1; colored_tty = colored && isatty(STDERR_FILENO); if (colored_tty) @@ -89,7 +92,9 @@ static void log_wl(const char *fmt, va_list args) { static char ds_fmt[1024]; - int n = snprintf(ds_fmt, sizeof(ds_fmt), "[wayland] %s", fmt); + int n; + + n = snprintf(ds_fmt, sizeof(ds_fmt), "[wayland] %s", fmt); if (n > 0 && ds_fmt[n - 1] == '\n') ds_fmt[n - 1] = '\0'; _ds_vlog(DS_INF, ds_fmt, args); diff --git a/src/libds/pixel_format.c b/src/libds/pixel_format.c index 29da532..8676bec 100644 --- a/src/libds/pixel_format.c +++ b/src/libds/pixel_format.c @@ -1,4 +1,5 @@ #include + #include "pixel_format.h" uint32_t diff --git a/src/libds/presentation.c b/src/libds/presentation.c index d94ad04..54d10d9 100644 --- a/src/libds/presentation.c +++ b/src/libds/presentation.c @@ -1,3 +1,5 @@ +// TODO + #include "libds-private.h" #include "presentation-time-protocol.h" @@ -29,8 +31,6 @@ struct ds_presentation_feedback uint32_t psf_flags; }; - - static void presentation_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id); static void handle_display_destroy(struct wl_listener *listener, void *data); @@ -77,7 +77,8 @@ presentation_handle_feedback(struct wl_client *client, surface = ds_surface_from_resource(surface_resource); } -static const struct wp_presentation_interface presentation_impl = { +static const struct wp_presentation_interface presentation_impl = +{ .destroy = presentation_handle_destroy, .feedback = presentation_handle_feedback, }; diff --git a/src/libds/region.c b/src/libds/region.c index 27d30da..92fe003 100644 --- a/src/libds/region.c +++ b/src/libds/region.c @@ -3,9 +3,10 @@ #include #include -#include "region.h" #include "libds/log.h" +#include "region.h" + static const struct wl_region_interface region_impl; static void region_handle_resource_destroy(struct wl_resource *resource); @@ -127,9 +128,8 @@ ds_region_scale_xy(pixman_region32_t *dst, pixman_region32_t *src, pixman_box32_t *src_rects, *dst_rects; int nrects, i; - if (scale_x == 1.0 && scale_y == 1.0) { + if (scale_x == 1.0 && scale_y == 1.0) pixman_region32_copy(dst, src); - } src_rects = pixman_region32_rectangles(src, &nrects); dst_rects = malloc(nrects * sizeof *dst_rects); @@ -181,7 +181,8 @@ region_subtract(struct wl_client *client, struct wl_resource *resource, pixman_region32_fini(&rect); } -static const struct wl_region_interface region_impl = { +static const struct wl_region_interface region_impl = +{ .destroy = region_destroy, .add = region_add, .subtract = region_subtract, diff --git a/src/libds/subcompositor.c b/src/libds/subcompositor.c index 717fd33..9e821b3 100644 --- a/src/libds/subcompositor.c +++ b/src/libds/subcompositor.c @@ -1,6 +1,7 @@ +#include "libds/log.h" + #include "subcompositor.h" #include "surface.h" -#include "libds/log.h" #define SUBCOMPOSITOR_VERSION 1 @@ -40,9 +41,10 @@ subcompositor_handle_get_subsurface(struct wl_client *client, struct wl_resource *surface_resource, struct wl_resource *parent_resource) { - struct ds_surface *surface = ds_surface_from_resource(surface_resource); - struct ds_surface *parent = ds_surface_from_resource(parent_resource); + struct ds_surface *surface, *parent; + surface = ds_surface_from_resource(surface_resource); + parent = ds_surface_from_resource(parent_resource); if (surface == parent) { ds_inf("ds_surface(%p) cannot be its own parent", surface); wl_resource_post_error(resource, @@ -75,7 +77,8 @@ subcompositor_handle_get_subsurface(struct wl_client *client, wl_resource_get_version(resource), id); } -static const struct wl_subcompositor_interface subcompositor_impl = { +static const struct wl_subcompositor_interface subcompositor_impl = +{ .destroy = subcompositor_handle_destroy, .get_subsurface = subcompositor_handle_get_subsurface, }; diff --git a/src/libds/surface/subsurface.c b/src/libds/surface/subsurface.c index 4cc1ad8..2ec0dae 100644 --- a/src/libds/surface/subsurface.c +++ b/src/libds/surface/subsurface.c @@ -3,6 +3,7 @@ #include "libds/log.h" #include "libds/surface.h" + #include "surface-private.h" static const struct wl_subsurface_interface subsurface_impl; @@ -88,7 +89,8 @@ ds_subsurface_get_parent(struct ds_subsurface *subsurface) return subsurface->parent; } -static const struct ds_surface_role subsurface_role = { +static const struct ds_surface_role subsurface_role = +{ .name = "wl_subsurface", }; @@ -212,7 +214,8 @@ subsurface_handle_set_desync(struct wl_client *client, } } -static const struct wl_subsurface_interface subsurface_impl = { +static const struct wl_subsurface_interface subsurface_impl = +{ .destroy = subsurface_handle_destroy, .set_position = subsurface_handle_set_position, .place_above = subsurface_handle_place_above, diff --git a/src/libds/surface/surface-private.h b/src/libds/surface/surface-private.h index 78b2900..aee9547 100644 --- a/src/libds/surface/surface-private.h +++ b/src/libds/surface/surface-private.h @@ -2,6 +2,7 @@ #define DS_SURFACE_PRIVATE_H #include + #include #include diff --git a/src/libds/surface/surface.c b/src/libds/surface/surface.c index 32ab232..0333561 100644 --- a/src/libds/surface/surface.c +++ b/src/libds/surface/surface.c @@ -1,13 +1,13 @@ #include #include -#include "surface-private.h" -#include "region.h" -#include "util.h" - #include "libds/log.h" #include "libds/surface.h" +#include "region.h" +#include "util.h" +#include "surface-private.h" + #define CALLBACK_VERSION 1 static const struct wl_surface_interface surface_impl; @@ -335,9 +335,11 @@ static void surface_handle_set_input_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource) { - struct ds_surface *surface = wl_resource_get_user_data(resource); + struct ds_surface *surface; pixman_region32_t *region; + surface = wl_resource_get_user_data(resource); + ds_dbg("ds_surface(%p) set input region", surface); surface->pending.committed |= DS_SURFACE_STATE_INPUT_REGION; @@ -379,7 +381,9 @@ static void surface_handle_set_buffer_transform(struct wl_client *client, struct wl_resource *resource, int32_t transform) { - struct ds_surface *surface = wl_resource_get_user_data(resource); + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); ds_dbg("ds_surface(%p) set buffer transform(%d)", surface, transform); @@ -400,7 +404,9 @@ static void surface_handle_set_buffer_scale(struct wl_client *client, struct wl_resource *resource, int32_t scale) { - struct ds_surface *surface = wl_resource_get_user_data(resource); + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); ds_dbg("ds_surface(%p) set buffer scale(%d)", surface, scale); @@ -421,7 +427,9 @@ surface_handle_damage_buffer(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { - struct ds_surface *surface = wl_resource_get_user_data(resource); + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); ds_dbg("ds_surface(%p) damage: x %d y %d width %d height %d", surface, x, y, width, height); @@ -438,7 +446,8 @@ surface_handle_damage_buffer(struct wl_client *client, x, y, width, height); } -static const struct wl_surface_interface surface_impl = { +static const struct wl_surface_interface surface_impl = +{ .destroy = surface_handle_destroy, .attach = surface_handle_attach, .damage = surface_handle_damage, @@ -454,7 +463,9 @@ static const struct wl_surface_interface surface_impl = { static void surface_handle_resource_destroy(struct wl_resource *resource) { - struct ds_surface *surface = wl_resource_get_user_data(resource); + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); ds_inf("Destroy ds_surface %p (res %p)", surface, surface->resource); diff --git a/src/libds/swapchain.c b/src/libds/swapchain.c index 54e64cf..78a2ece 100644 --- a/src/libds/swapchain.c +++ b/src/libds/swapchain.c @@ -41,7 +41,7 @@ struct ds_swapchain * ds_swapchain_create(struct ds_allocator *alloc, int width, int height, uint32_t format) { - struct ds_swapchain *swapchain = NULL; + struct ds_swapchain *swapchain; swapchain = calloc(1, sizeof *swapchain); if (!swapchain) diff --git a/src/libds/util/time.c b/src/libds/util/time.c index 1b17516..afb0e89 100644 --- a/src/libds/util/time.c +++ b/src/libds/util/time.c @@ -3,6 +3,8 @@ #include #include -int64_t timespec_to_msec(const struct timespec *a) { +int64_t +timespec_to_msec(const struct timespec *a) +{ return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; } diff --git a/src/libds/xdg_shell/xdg_shell.c b/src/libds/xdg_shell/xdg_shell.c index b7cc8ff..a53684a 100644 --- a/src/libds/xdg_shell/xdg_shell.c +++ b/src/libds/xdg_shell/xdg_shell.c @@ -2,14 +2,16 @@ #include #include -#include "xdg_shell.h" #include "libds/log.h" #include "libds/xdg_shell.h" +#include "xdg_shell.h" + #define XDG_WM_BASE_VERSION 2 #define XDG_SHELL_PING_TIMEOUT 10000 -static void xdg_shell_handle_display_destroy(struct wl_listener *listener, void *data); +static void xdg_shell_handle_display_destroy(struct wl_listener *listener, + void *data); static void xdg_shell_bind(struct wl_client *wl_client, void *data, uint32_t verison, uint32_t id); @@ -126,7 +128,8 @@ xdg_shell_handle_pong(struct wl_client *wl_client, client->ping_serial = 0; } -static const struct xdg_wm_base_interface xdg_shell_impl = { +static const struct xdg_wm_base_interface xdg_shell_impl = +{ .destroy = xdg_shell_handle_destroy, .create_positioner = xdg_shell_handle_create_positioner, .get_xdg_surface = xdg_shell_handle_get_xdg_surface, @@ -150,11 +153,9 @@ xdg_client_handle_resource_destroy(struct wl_resource *resource) static int xdg_client_handle_ping_timeout(void *user_data) { - struct ds_xdg_client *client; + struct ds_xdg_client *client = user_data; struct ds_xdg_surface *surface; - client = user_data; - wl_list_for_each(surface, &client->surfaces, link) wl_signal_emit(&surface->events.ping_timeout, surface); @@ -181,11 +182,9 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *data, uint32_t version, uint32_t id) { - struct ds_xdg_shell *shell; + struct ds_xdg_shell *shell = data; struct ds_xdg_client *client; - shell = data; - client = calloc(1, sizeof *client); if (client == NULL) { wl_client_post_no_memory(wl_client); diff --git a/src/libds/xdg_shell/xdg_shell.h b/src/libds/xdg_shell/xdg_shell.h index 6596ea2..ea67be7 100644 --- a/src/libds/xdg_shell/xdg_shell.h +++ b/src/libds/xdg_shell/xdg_shell.h @@ -3,10 +3,10 @@ #include +#include "libds/output.h" #include "xdg-shell-server-protocol.h" #include "surface.h" -#include "libds/output.h" enum ds_xdg_surface_role { diff --git a/src/libds/xdg_shell/xdg_surface.c b/src/libds/xdg_shell/xdg_surface.c index 523438d..1e1654e 100644 --- a/src/libds/xdg_shell/xdg_surface.c +++ b/src/libds/xdg_shell/xdg_surface.c @@ -1,10 +1,12 @@ #include #include -#include "xdg_shell.h" #include "libds/log.h" +#include "xdg_shell.h" + static const struct xdg_surface_interface xdg_surface_impl; + static void xdg_surface_handle_surface_destroy(struct wl_listener *listener, void *data); static void xdg_surface_handle_surface_commit(struct wl_listener *listener, diff --git a/src/libds/xdg_shell/xdg_toplevel.c b/src/libds/xdg_shell/xdg_toplevel.c index 8e78fe7..2a1e6d7 100644 --- a/src/libds/xdg_shell/xdg_toplevel.c +++ b/src/libds/xdg_shell/xdg_toplevel.c @@ -4,7 +4,8 @@ #include "xdg_shell.h" -const struct ds_surface_role xdg_toplevel_surface_role = { +static const struct ds_surface_role xdg_toplevel_surface_role = +{ .name = "xdg_toplevel", .commit = handle_xdg_surface_commit, }; @@ -17,9 +18,8 @@ void create_xdg_toplevel(struct ds_xdg_surface *surface, uint32_t id) { if (!ds_surface_set_role(surface->ds_surface, &xdg_toplevel_surface_role, - surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) { + surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) return; - } if (surface->role != DS_XDG_SURFACE_ROLE_NONE) { wl_resource_post_error(surface->resource, @@ -81,6 +81,7 @@ send_xdg_toplevel_configure(struct ds_xdg_surface *surface, struct ds_xdg_surface_configure *configure) { struct wl_array states; + uint32_t width, height; configure->toplevel_configure = malloc(sizeof *configure->toplevel_configure); @@ -125,8 +126,8 @@ send_xdg_toplevel_configure(struct ds_xdg_surface *surface, // TODO } - uint32_t width = surface->toplevel->scheduled.width; - uint32_t height = surface->toplevel->scheduled.height; + width = surface->toplevel->scheduled.width; + height = surface->toplevel->scheduled.height; xdg_toplevel_send_configure(surface->toplevel->resource, width, height, &states); @@ -297,7 +298,8 @@ xdg_toplevel_handle_set_minimized(struct wl_client *client, wl_signal_emit(&surface->toplevel->events.request_maximize, surface); } -static const struct xdg_toplevel_interface xdg_toplevel_impl = { +static const struct xdg_toplevel_interface xdg_toplevel_impl = +{ xdg_toplevel_handle_destroy, xdg_toplevel_handle_set_parent, xdg_toplevel_handle_set_title, -- 2.7.4