diff --git a/meson.build b/meson.build index f03fe0b..43861aa 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project( ) add_project_arguments( - ['-D_POSIX_C_SOURCE=200809L', '-Wno-unused-parameter'], + ['-D_XOPEN_SOURCE=700', '-Wno-unused-parameter'], language: 'c', ) @@ -47,25 +47,25 @@ wp_viewporter = [ ] layer_shell = [ - proto_c.process('wlr-layer-shell-unstable-v1.xml'), - proto_h.process('wlr-layer-shell-unstable-v1.xml'), + proto_c.process('protocols/wlr-layer-shell-unstable-v1.xml'), + proto_h.process('protocols/wlr-layer-shell-unstable-v1.xml'), ] screencopy = [ - proto_c.process('wlr-screencopy-unstable-v1.xml'), - proto_h.process('wlr-screencopy-unstable-v1.xml'), + proto_c.process('protocols/wlr-screencopy-unstable-v1.xml'), + proto_h.process('protocols/wlr-screencopy-unstable-v1.xml'), ] executable( meson.project_name(), install: true, sources: [ - 'array.c', - 'buffer.c', - 'capture.c', - 'image.c', - 'main.c', - 'overlay.c', + 'src/array.c', + 'src/buffer.c', + 'src/capture.c', + 'src/image.c', + 'src/main.c', + 'src/overlay.c', xdg_shell, wp_viewporter, layer_shell, @@ -83,7 +83,7 @@ if unity.found() 'array', executable( 'array.test', - sources: ['array.c', 'array.test.c'], + sources: ['src/array.c', 'src/array.test.c'], dependencies: [unity_dep], ), ) @@ -92,7 +92,7 @@ if unity.found() 'image', executable( 'image.test', - sources: ['image.c', 'image.test.c'], + sources: ['src/image.c', 'src/image.test.c'], dependencies: [math, pixman, unity_dep], ), ) diff --git a/wlr-layer-shell-unstable-v1.xml b/protocols/wlr-layer-shell-unstable-v1.xml similarity index 100% rename from wlr-layer-shell-unstable-v1.xml rename to protocols/wlr-layer-shell-unstable-v1.xml diff --git a/wlr-screencopy-unstable-v1.xml b/protocols/wlr-screencopy-unstable-v1.xml similarity index 100% rename from wlr-screencopy-unstable-v1.xml rename to protocols/wlr-screencopy-unstable-v1.xml diff --git a/array.c b/src/array.c similarity index 100% rename from array.c rename to src/array.c diff --git a/array.h b/src/array.h similarity index 61% rename from array.h rename to src/array.h index d9ee0f4..8a8d2ca 100644 --- a/array.h +++ b/src/array.h @@ -16,16 +16,18 @@ void *array_grow_if_needed(void *array, size_t element_size, size_t new_capacity); #define array_push(array, element) \ - { \ + do { \ (array) = array_grow_if_needed((array), sizeof(*array), \ array_length(array) + 1); \ (array)[((struct array_header *)(array) - 1)->length++] = (element); \ - }; + } while (0) -#define array_free(array) \ - if (array) { \ - free((struct array_header *)(array) - 1); \ - (array) = NULL; \ - } +#define array_free(array) \ + do { \ + if (array) { \ + free((struct array_header *)(array) - 1); \ + (array) = NULL; \ + } \ + } while (0) #endif diff --git a/array.test.c b/src/array.test.c similarity index 100% rename from array.test.c rename to src/array.test.c diff --git a/buffer.c b/src/buffer.c similarity index 100% rename from buffer.c rename to src/buffer.c diff --git a/buffer.h b/src/buffer.h similarity index 100% rename from buffer.h rename to src/buffer.h diff --git a/capture.c b/src/capture.c similarity index 100% rename from capture.c rename to src/capture.c diff --git a/capture.h b/src/capture.h similarity index 100% rename from capture.h rename to src/capture.h diff --git a/image.c b/src/image.c similarity index 94% rename from image.c rename to src/image.c index a0bec7c..2201c85 100644 --- a/image.c +++ b/src/image.c @@ -1,9 +1,8 @@ #include "image.h" +#include #include #include -#define PI 3.14159265358979323846 - pixman_image_t * image_revert_wl_output_transform(pixman_image_t *src, enum wl_output_transform wl_output_transform) { @@ -25,7 +24,7 @@ image_revert_wl_output_transform(pixman_image_t *src, pixman_f_transform_translate(&f_transform, NULL, -(double)src_width / 2, -(double)src_height / 2); - double rotation_radians = PI * (wl_output_transform % 4) / 2.0; + double rotation_radians = M_PI * (wl_output_transform % 4) / 2.0; pixman_f_transform_rotate(&f_transform, NULL, round(cos(rotation_radians)), round(sin(rotation_radians))); diff --git a/image.h b/src/image.h similarity index 100% rename from image.h rename to src/image.h diff --git a/image.test.c b/src/image.test.c similarity index 100% rename from image.test.c rename to src/image.test.c diff --git a/main.c b/src/main.c similarity index 100% rename from main.c rename to src/main.c diff --git a/overlay.c b/src/overlay.c similarity index 100% rename from overlay.c rename to src/overlay.c diff --git a/overlay.h b/src/overlay.h similarity index 100% rename from overlay.h rename to src/overlay.h