Move funcs "win_geom_total_(width|height)" to Rust

This commit is contained in:
Alex Kotov 2022-09-07 20:17:22 +04:00
parent 21554b3f6f
commit 11f0629a19
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
5 changed files with 33 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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 *
***********************/

View File

@ -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()
}

16
tests/geom_win_geom.c Normal file
View File

@ -0,0 +1,16 @@
#include <assert.h>
#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);
}