diff options
-rw-r--r-- | backend/libinput/events.c | 2 | ||||
-rw-r--r-- | backend/wayland/output.c | 2 | ||||
-rw-r--r-- | backend/wayland/wl_seat.c | 2 | ||||
-rw-r--r-- | examples/compositor/main.c | 7 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 4 | ||||
-rw-r--r-- | include/wlr/types/wlr_region.h | 6 | ||||
-rw-r--r-- | include/wlr/types/wlr_surface.h | 16 | ||||
-rw-r--r-- | include/wlr/util/list.h | 2 | ||||
-rw-r--r-- | render/gles2/renderer.c | 5 | ||||
-rw-r--r-- | render/gles2/texture.c | 25 | ||||
-rw-r--r-- | render/wlr_texture.c | 5 | ||||
-rw-r--r-- | types/wlr_input_device.c | 5 | ||||
-rw-r--r-- | types/wlr_keyboard.c | 3 | ||||
-rw-r--r-- | types/wlr_pointer.c | 3 | ||||
-rw-r--r-- | types/wlr_surface.c | 191 | ||||
-rw-r--r-- | types/wlr_tablet_pad.c | 3 | ||||
-rw-r--r-- | types/wlr_touch.c | 3 | ||||
-rw-r--r-- | util/list.c | 2 | ||||
-rw-r--r-- | xcursor/wlr_cursor.c | 2 |
19 files changed, 249 insertions, 39 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 37ec6f4c..dc5e4cb1 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -166,7 +166,7 @@ static void handle_device_removed(struct wlr_libinput_backend *backend, if (!wlr_devices) { return; } - for (size_t i = 0; i < wlr_devices->length; i++) { + for (size_t i = 0; i < wlr_devices->length; i++) { struct wlr_input_device *wlr_dev = wlr_devices->items[i]; wl_signal_emit(&backend->backend.events.input_remove, wlr_dev); wlr_input_device_destroy(wlr_dev); diff --git a/backend/wayland/output.c b/backend/wayland/output.c index a95505dc..cb286316 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -162,7 +162,7 @@ static struct wlr_output_impl output_impl = { .move_cursor = wlr_wl_output_move_cursor }; -void handle_ping(void* data, struct wl_shell_surface* ssurface, uint32_t serial) { +void handle_ping(void *data, struct wl_shell_surface *ssurface, uint32_t serial) { struct wlr_wl_backend_output *output = data; assert(output && output->shell_surface == ssurface); wl_shell_surface_pong(ssurface, serial); diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 3742d4fb..4668a72b 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -19,7 +19,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, struct wlr_wl_input_device *wlr_wl_dev = (struct wlr_wl_input_device *)dev; assert(dev && dev->pointer); struct wlr_wl_pointer *wlr_wl_pointer = (struct wlr_wl_pointer *)dev->pointer; - struct wlr_wl_backend_output* output = + struct wlr_wl_backend_output *output = wlr_wl_output_for_surface(wlr_wl_dev->backend, surface); assert(output); wlr_wl_pointer->current_output = output; diff --git a/examples/compositor/main.c b/examples/compositor/main.c index 9b8a041c..e2a3a481 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -8,6 +8,7 @@ #include <wlr/backend.h> #include <wlr/backend/session.h> #include <wlr/render.h> +#include <wlr/render/matrix.h> #include <wlr/render/gles2.h> #include <wlr/types/wlr_output.h> #include <wlr/types/wlr_surface.h> @@ -41,12 +42,14 @@ void handle_output_frame(struct output_state *output, struct timespec *ts) { struct wl_resource *_res; float matrix[16]; + float transform[16]; wl_list_for_each(_res, &sample->compositor.surfaces, link) { struct wlr_surface *surface = wl_resource_get_user_data(_res); wlr_surface_flush_damage(surface); if (surface->texture->valid) { - wlr_texture_get_matrix(surface->texture, &matrix, - &wlr_output->transform_matrix, 200, 200); + wlr_matrix_translate(&transform, 200, 200, 0); + wlr_surface_get_matrix(surface, &matrix, + &wlr_output->transform_matrix, &transform); wlr_render_with_matrix(sample->renderer, surface->texture, &matrix); struct wlr_frame_callback *cb, *cnext; diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 59ece8b1..f98c3bc2 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -46,6 +46,8 @@ struct wlr_texture_impl { struct wl_resource *drm_buf); void (*get_matrix)(struct wlr_texture *state, float (*matrix)[16], const float (*projection)[16], int x, int y); + void (*get_buffer_size)(struct wlr_texture *texture, + struct wl_resource *resource, int *width, int *height); void (*bind)(struct wlr_texture *texture); void (*destroy)(struct wlr_texture *texture); }; @@ -53,5 +55,7 @@ struct wlr_texture_impl { void wlr_texture_init(struct wlr_texture *texture, struct wlr_texture_impl *impl); void wlr_texture_bind(struct wlr_texture *texture); +void wlr_texture_get_buffer_size(struct wlr_texture *texture, + struct wl_resource *resource, int *width, int *height); #endif diff --git a/include/wlr/types/wlr_region.h b/include/wlr/types/wlr_region.h index 0aff48a3..9a64ac13 100644 --- a/include/wlr/types/wlr_region.h +++ b/include/wlr/types/wlr_region.h @@ -3,8 +3,10 @@ struct wl_resource; -// Implements the given resource as region. -// Sets the associated pixman_region32_t as userdata. +/* + * Implements the given resource as region. + * Sets the associated pixman_region32_t as userdata. + */ void wlr_region_create(struct wl_client *client, struct wl_resource *res, uint32_t id); diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 60d8b2f6..9b13d9cc 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -23,8 +23,10 @@ struct wlr_surface_state { int32_t sx, sy; pixman_region32_t surface_damage, buffer_damage; pixman_region32_t opaque, input; - uint32_t transform; + enum wl_output_transform transform; int32_t scale; + int width, height; + int buffer_width, buffer_height; }; struct wlr_surface { @@ -53,5 +55,17 @@ struct wlr_renderer; struct wlr_surface *wlr_surface_create(struct wl_resource *res, struct wlr_renderer *renderer); void wlr_surface_flush_damage(struct wlr_surface *surface); +/** + * Gets a matrix you can pass into wlr_render_with_matrix to display this + * surface. `matrix` is the output matrix, `projection` is the wlr_output + * projection matrix, and `transform` is any additional transformations you want + * to perform on the surface (or NULL/the identity matrix if you don't). + * `transform` is used before the surface is scaled, so its geometry extends + * from 0 to 1 in both dimensions. + */ +void wlr_surface_get_matrix(struct wlr_surface *surface, + float (*matrix)[16], + const float (*projection)[16], + const float (*transform)[16]); #endif diff --git a/include/wlr/util/list.h b/include/wlr/util/list.h index c82fbf7a..0c175132 100644 --- a/include/wlr/util/list.h +++ b/include/wlr/util/list.h @@ -11,7 +11,7 @@ typedef struct { list_t *list_create(void); void list_free(list_t *list); -void list_foreach(list_t *list, void (*callback)(void* item)); +void list_foreach(list_t *list, void (*callback)(void *item)); void list_add(list_t *list, void *item); void list_push(list_t *list, void *item); void list_insert(list_t *list, size_t index, void *item); diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 27f3d33e..1f3c3eeb 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -101,8 +101,9 @@ error: } static void init_image_ext() { - if (glEGLImageTargetTexture2DOES) + if (glEGLImageTargetTexture2DOES) { return; + } const char *exts = (const char*) glGetString(GL_EXTENSIONS); if (strstr(exts, "GL_OES_EGL_image_external")) { @@ -177,7 +178,7 @@ static void draw_quad() { static bool wlr_gles2_render_texture(struct wlr_renderer *_renderer, struct wlr_texture *texture, const float (*matrix)[16]) { - if(!texture || !texture->valid) { + if (!texture || !texture->valid) { wlr_log(L_ERROR, "attempt to render invalid texture"); return false; } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 041625fd..6bb93e4f 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -218,6 +218,30 @@ static void gles2_texture_get_matrix(struct wlr_texture *_texture, wlr_matrix_mul(projection, matrix, matrix); } +static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct + wl_resource *resource, int *width, int *height) { + struct wl_shm_buffer *buffer = wl_shm_buffer_get(resource); + if (!buffer) { + struct wlr_gles2_texture *tex = (struct wlr_gles2_texture *)texture; + if (!glEGLImageTargetTexture2DOES) { + return; + } + if (!wlr_egl_query_buffer(tex->egl, resource, EGL_WIDTH, + (EGLint*)&width)) { + wlr_log(L_ERROR, "could not get size of the buffer " + "(no buffer found)"); + return; + }; + wlr_egl_query_buffer(tex->egl, resource, EGL_HEIGHT, + (EGLint*)&height); + + return; + } + + *width = wl_shm_buffer_get_width(buffer); + *height = wl_shm_buffer_get_height(buffer); +} + static void gles2_texture_bind(struct wlr_texture *_texture) { struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture; GL_CALL(glBindTexture(GL_TEXTURE_2D, texture->tex_id)); @@ -247,6 +271,7 @@ static struct wlr_texture_impl wlr_texture_impl = { .update_shm = gles2_texture_update_shm, .upload_drm = gles2_texture_upload_drm, .get_matrix = gles2_texture_get_matrix, + .get_buffer_size = gles2_texture_get_buffer_size, .bind = gles2_texture_bind, .destroy = gles2_texture_destroy, }; diff --git a/render/wlr_texture.c b/render/wlr_texture.c index f98284a1..9faea820 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -52,3 +52,8 @@ void wlr_texture_get_matrix(struct wlr_texture *texture, float (*matrix)[16], const float (*projection)[16], int x, int y) { texture->impl->get_matrix(texture, matrix, projection, x, y); } + +void wlr_texture_get_buffer_size(struct wlr_texture *texture, struct wl_resource + *resource, int *width, int *height) { + texture->impl->get_buffer_size(texture, resource, width, height); +} diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index a8b264ac..409e8bd1 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -23,7 +23,10 @@ void wlr_input_device_init(struct wlr_input_device *dev, } void wlr_input_device_destroy(struct wlr_input_device *dev) { - if (!dev) return; + if (!dev) { + return; + } + if (dev->_device) { switch (dev->type) { case WLR_INPUT_DEVICE_KEYBOARD: diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 14930f6f..02b3842d 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -11,8 +11,7 @@ void wlr_keyboard_init(struct wlr_keyboard *kb, } void wlr_keyboard_destroy(struct wlr_keyboard *kb) { - if (!kb) return; - if (kb->impl && kb->impl->destroy) { + if (kb && kb->impl && kb->impl->destroy) { kb->impl->destroy(kb); } else { free(kb); diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index 02c2ce61..74856762 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -14,8 +14,7 @@ void wlr_pointer_init(struct wlr_pointer *pointer, } void wlr_pointer_destroy(struct wlr_pointer *pointer) { - if (!pointer) return; - if (pointer->impl && pointer->impl->destroy) { + if (pointer && pointer->impl && pointer->impl->destroy) { pointer->impl->destroy(pointer); } else { free(pointer); diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 1110ef06..50de2e4b 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -5,6 +5,7 @@ #include <wlr/egl.h> #include <wlr/render/interface.h> #include <wlr/types/wlr_surface.h> +#include <wlr/render/matrix.h> static void surface_destroy(struct wl_client *client, struct wl_resource *resource) { wl_resource_destroy(resource); @@ -27,8 +28,8 @@ static void surface_damage(struct wl_client *client, } surface->pending.invalid |= WLR_SURFACE_INVALID_SURFACE_DAMAGE; pixman_region32_union_rect(&surface->pending.surface_damage, - &surface->pending.surface_damage, - x, y, width, height); + &surface->pending.surface_damage, + x, y, width, height); } static void destroy_frame_callback(struct wl_resource *resource) { @@ -57,7 +58,7 @@ static void surface_frame(struct wl_client *client, } wl_resource_set_implementation(cb->resource, - NULL, cb, destroy_frame_callback); + NULL, cb, destroy_frame_callback); wl_list_insert(surface->frame_callback_list.prev, &cb->link); } @@ -86,27 +87,151 @@ static void surface_set_input_region(struct wl_client *client, } else { pixman_region32_fini(&surface->pending.input); pixman_region32_init_rect(&surface->pending.input, - INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); + INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); } } +static void wlr_surface_update_size(struct wlr_surface *surface) { + int scale = surface->current.scale; + enum wl_output_transform transform = surface->current.transform; + + wlr_texture_get_buffer_size(surface->texture, surface->current.buffer, + &surface->current.buffer_width, &surface->current.buffer_height); + + int _width = surface->current.buffer_width / scale; + int _height = surface->current.buffer_height / scale; + + if (transform == WL_OUTPUT_TRANSFORM_90 || + transform == WL_OUTPUT_TRANSFORM_270 || + transform == WL_OUTPUT_TRANSFORM_FLIPPED_90 || + transform == WL_OUTPUT_TRANSFORM_FLIPPED_270) { + int tmp = _width; + _width = _height; + _height = tmp; + } + + surface->current.width = _width; + surface->current.height = _height; +} + +static void wlr_surface_to_buffer_region(struct wlr_surface *surface, + pixman_region32_t *surface_region, pixman_region32_t *buffer_region, + int width, int height) { + pixman_box32_t *src_rects, *dest_rects; + int nrects, i; + int scale = surface->current.scale; + enum wl_output_transform transform = surface->current.transform; + + src_rects = pixman_region32_rectangles(surface_region, &nrects); + dest_rects = malloc(nrects * sizeof(*dest_rects)); + if (!dest_rects) { + return; + } + + for (i = 0; i < nrects; i++) { + switch (transform) { + default: + case WL_OUTPUT_TRANSFORM_NORMAL: + dest_rects[i].x1 = src_rects[i].x1; + dest_rects[i].y1 = src_rects[i].y1; + dest_rects[i].x2 = src_rects[i].x2; + dest_rects[i].y2 = src_rects[i].y2; + break; + case WL_OUTPUT_TRANSFORM_90: + dest_rects[i].x1 = height - src_rects[i].y2; + dest_rects[i].y1 = src_rects[i].x1; + dest_rects[i].x2 = height - src_rects[i].y1; + dest_rects[i].y2 = src_rects[i].x2; + break; + case WL_OUTPUT_TRANSFORM_180: + dest_rects[i].x1 = width - src_rects[i].x2; + dest_rects[i].y1 = height - src_rects[i].y2; + dest_rects[i].x2 = width - src_rects[i].x1; + dest_rects[i].y2 = height - src_rects[i].y1; + break; + case WL_OUTPUT_TRANSFORM_270: + dest_rects[i].x1 = src_rects[i].y1; + dest_rects[i].y1 = width - src_rects[i].x2; + dest_rects[i].x2 = src_rects[i].y2; + dest_rects[i].y2 = width - src_rects[i].x1; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED: + dest_rects[i].x1 = width - src_rects[i].x2; + dest_rects[i].y1 = src_rects[i].y1; + dest_rects[i].x2 = width - src_rects[i].x1; + dest_rects[i].y2 = src_rects[i].y2; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + dest_rects[i].x1 = height - src_rects[i].y2; + dest_rects[i].y1 = width - src_rects[i].x2; + dest_rects[i].x2 = height - src_rects[i].y1; + dest_rects[i].y2 = width - src_rects[i].x1; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_180: + dest_rects[i].x1 = src_rects[i].x1; + dest_rects[i].y1 = height - src_rects[i].y2; + dest_rects[i].x2 = src_rects[i].x2; + dest_rects[i].y2 = height - src_rects[i].y1; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + dest_rects[i].x1 = src_rects[i].y1; + dest_rects[i].y1 = src_rects[i].x1; + dest_rects[i].x2 = src_rects[i].y2; + dest_rects[i].y2 = src_rects[i].x2; + break; + } + } + + if (scale != 1) { + for (i = 0; i < nrects; i++) { + dest_rects[i].x1 *= scale; + dest_rects[i].x2 *= scale; + dest_rects[i].y1 *= scale; + dest_rects[i].y2 *= scale; + } + } + + pixman_region32_fini(buffer_region); + pixman_region32_init_rects(buffer_region, dest_rects, nrects); + free(dest_rects); +} + static void surface_commit(struct wl_client *client, struct wl_resource *resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); + surface->current.scale = surface->pending.scale; + surface->current.transform = surface->pending.transform; if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) { surface->current.buffer = surface->pending.buffer; } if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) { - // TODO: Sort out buffer damage too + wlr_surface_update_size(surface); + pixman_region32_union(&surface->current.surface_damage, - &surface->current.surface_damage, - &surface->pending.surface_damage); - // TODO: Surface sizing is complicated - //pixman_region32_intersect_rect(&surface->current.surface_damage, - // &surface->current.surface_damage, - // 0, 0, surface->width, surface->height); + &surface->current.surface_damage, + &surface->pending.surface_damage); + pixman_region32_intersect_rect(&surface->current.surface_damage, + &surface->current.surface_damage, 0, 0, surface->current.width, + surface->current.height); + + pixman_region32_union(&surface->current.buffer_damage, + &surface->current.buffer_damage, + &surface->pending.buffer_damage); + + pixman_region32_t buffer_damage; + pixman_region32_init(&buffer_damage); + wlr_surface_to_buffer_region(surface, &surface->current.surface_damage, + &buffer_damage, surface->current.width, surface->current.height); + pixman_region32_union(&surface->current.buffer_damage, + &surface->current.buffer_damage, &buffer_damage); + + pixman_region32_intersect_rect(&surface->current.buffer_damage, + &surface->current.buffer_damage, 0, 0, + surface->current.buffer_width, surface->current.buffer_height); + pixman_region32_clear(&surface->pending.surface_damage); + pixman_region32_clear(&surface->pending.buffer_damage); } // TODO: Commit other changes @@ -132,7 +257,7 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) { return; } } - pixman_region32_t damage = surface->current.surface_damage; + pixman_region32_t damage = surface->current.buffer_damage; if (!pixman_region32_not_empty(&damage)) { goto release; } @@ -142,7 +267,7 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) { for (int i = 0; i < n; ++i) { pixman_box32_t rect = rects[i]; if (!wlr_texture_update_shm(surface->texture, format, - rect.x1, rect.y1, + rect.x1, rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1, buffer)) { @@ -151,26 +276,38 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) { } pixman_region32_fini(&surface->current.surface_damage); pixman_region32_init(&surface->current.surface_damage); + + pixman_region32_fini(&surface->current.buffer_damage); + pixman_region32_init(&surface->current.buffer_damage); release: wl_resource_queue_event(surface->current.buffer, WL_BUFFER_RELEASE); } static void surface_set_buffer_transform(struct wl_client *client, struct wl_resource *resource, int transform) { - wlr_log(L_DEBUG, "TODO: surface surface buffer transform"); + struct wlr_surface *surface = wl_resource_get_user_data(resource); + surface->pending.transform = transform; } static void surface_set_buffer_scale(struct wl_client *client, struct wl_resource *resource, int32_t scale) { - wlr_log(L_DEBUG, "TODO: surface set buffer scale"); + struct wlr_surface *surface = wl_resource_get_user_data(resource); + surface->pending.scale = scale; } static void surface_damage_buffer(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { - wlr_log(L_DEBUG, "TODO: surface damage buffer"); + struct wlr_surface *surface = wl_resource_get_user_data(resource); + if (width < 0 || height < 0) { + return; + } + surface->pending.invalid |= WLR_SURFACE_INVALID_SURFACE_DAMAGE; + pixman_region32_union_rect(&surface->pending.buffer_damage, + &surface->pending.buffer_damage, + x, y, width, height); } const struct wl_surface_interface surface_interface = { @@ -208,9 +345,29 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res, surface->renderer = renderer; surface->texture = wlr_render_texture_init(renderer); surface->resource = res; + surface->current.scale = 1; + surface->pending.scale = 1; + surface->current.transform = WL_OUTPUT_TRANSFORM_NORMAL; + surface->pending.transform = WL_OUTPUT_TRANSFORM_NORMAL; wl_signal_init(&surface->signals.commit); wl_list_init(&surface->frame_callback_list); wl_resource_set_implementation(res, &surface_interface, - surface, destroy_surface); + surface, destroy_surface); return surface; } + +void wlr_surface_get_matrix(struct wlr_surface *surface, + float (*matrix)[16], + const float (*projection)[16], + const float (*transform)[16]) { + int width = surface->texture->width / surface->current.scale; + int height = surface->texture->height / surface->current.scale; + float scale[16]; + wlr_matrix_identity(matrix); + if (transform) { + wlr_matrix_mul(matrix, transform, matrix); + } + wlr_matrix_scale(&scale, width, height, 1); + wlr_matrix_mul(matrix, &scale, matrix); + wlr_matrix_mul(projection, matrix, matrix); +} diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index b7f03493..07f9da10 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -13,8 +13,7 @@ void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, } void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) { - if (!pad) return; - if (pad->impl && pad->impl->destroy) { + if (pad && pad->impl && pad->impl->destroy) { pad->impl->destroy(pad); } else { free(pad); diff --git a/types/wlr_touch.c b/types/wlr_touch.c index 46ae7ce9..5db653e7 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -14,8 +14,7 @@ void wlr_touch_init(struct wlr_touch *touch, } void wlr_touch_destroy(struct wlr_touch *touch) { - if (!touch) return; - if (touch->impl && touch->impl->destroy) { + if (touch && touch->impl && touch->impl->destroy) { touch->impl->destroy(touch); } else { free(touch); diff --git a/util/list.c b/util/list.c index 279d2ab5..44fba4db 100644 --- a/util/list.c +++ b/util/list.c @@ -81,7 +81,7 @@ void list_cat(list_t *list, list_t *source) { } } -void list_qsort(list_t* list, int compare(const void *left, const void *right)) { +void list_qsort(list_t *list, int compare(const void *left, const void *right)) { qsort(list->items, list->length, sizeof(void *), compare); } diff --git a/xcursor/wlr_cursor.c b/xcursor/wlr_cursor.c index 3a7da05b..85e0d3be 100644 --- a/xcursor/wlr_cursor.c +++ b/xcursor/wlr_cursor.c @@ -269,7 +269,7 @@ void wlr_cursor_theme_destroy(struct wlr_cursor_theme *theme) { } struct wlr_cursor *wlr_cursor_theme_get_cursor(struct wlr_cursor_theme *theme, - const char *name) { + const char *name) { unsigned int i; for (i = 0; i < theme->cursor_count; i++) { |