diff --git a/Makefile b/Makefile index 67edcfc..83a7b9c 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,8 @@ DWM_SRC = \ TEST_SRC = \ tests/geom_basic_geom.c \ tests/geom_position.c \ - tests/geom_sizes.c + tests/geom_sizes.c \ + tests/geom_win_geom.c MAIN_SRC = $(MODULES_SRC) src/main.c diff --git a/config/3-defvars.mk b/config/3-defvars.mk index 21d8b5b..fdcb96e 100644 --- a/config/3-defvars.mk +++ b/config/3-defvars.mk @@ -5,7 +5,7 @@ PKGCONFIG = pkg-config PKGS += fontconfig freetype2 x11 xft CFLAGS += `$(PKGCONFIG) --cflags $(PKGS)` -LDFLAGS += `$(PKGCONFIG) --libs $(PKGS)` +LDFLAGS += `$(PKGCONFIG) --libs $(PKGS)` -lpthread -ldl CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L CFLAGS += $(CPPFLAGS) -std=c99 -Os -pedantic -Wall -Wno-deprecated-declarations diff --git a/src/geom.c b/src/geom.c index 7b28d17..8177ec9 100644 --- a/src/geom.c +++ b/src/geom.c @@ -88,22 +88,6 @@ void win_geom_convert_to_x_window_changes( x_window_changes->border_width = win_geom->border_width; } -/********************** - * Constant functions * - **********************/ - -int win_geom_total_width( - const struct WinGeom *const win_geom -) { - return win_geom->basic.sizes.w + 2 * win_geom->border_width; -} - -int win_geom_total_height( - const struct WinGeom *const win_geom -) { - return win_geom->basic.sizes.h + 2 * win_geom->border_width; -} - /*********************** * Modifying functions * ***********************/ diff --git a/src/lib.rs b/src/lib.rs index e7c9bb7..6e43b87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,3 +123,17 @@ unsafe extern "C" fn win_geom_init_from_args( border_width, ); } + +#[no_mangle] +unsafe extern "C" fn win_geom_total_width( + win_geom: *const geom::WinGeom, +) -> c_int { + (*win_geom).total_width() +} + +#[no_mangle] +unsafe extern "C" fn win_geom_total_height( + win_geom: *const geom::WinGeom, +) -> c_int { + (*win_geom).total_height() +} diff --git a/tests/geom_win_geom.c b/tests/geom_win_geom.c new file mode 100644 index 0000000..3c1195a --- /dev/null +++ b/tests/geom_win_geom.c @@ -0,0 +1,16 @@ +#include + +#include "../src/geom.h" + +static void test_total_width_height(); + +void test() { + test_total_width_height(); +} + +void test_total_width_height() +{ + const struct WinGeom win_geom = win_geom_create_from_args(0, 0, 34, 56, 12); + assert(win_geom_total_width(&win_geom) == 58); + assert(win_geom_total_height(&win_geom) == 80); +}