Move func "constraints_border_width" to Rust

This commit is contained in:
Alex Kotov 2022-09-07 17:59:07 +04:00
parent 2664eca633
commit bd4b49c5e1
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 9 additions and 11 deletions

View file

@ -1,7 +1,5 @@
#include "constraints.h"
#define MIN_BORDER_WIDTH 0
#define MAX_BORDER_WIDTH 10000
#define MIN_DEFAULT_CLIENTS_IN_MASTER 1
#define MAX_DEFAULT_CLIENTS_IN_MASTER 10000
#define MIN_DEFAULT_MASTER_AREA_FACTOR 0.05
@ -15,13 +13,6 @@
#define MIN_SNAP_DISTANCE 1
#define MAX_SNAP_DISTANCE 10000
int constraints_border_width(const int border_width)
{
if (border_width < MIN_BORDER_WIDTH) return MIN_BORDER_WIDTH;
if (border_width > MAX_BORDER_WIDTH) return MAX_BORDER_WIDTH;
return border_width;
}
int constraints_default_clients_in_master(const int default_clients_in_master)
{
if (default_clients_in_master < MIN_DEFAULT_CLIENTS_IN_MASTER) return MIN_DEFAULT_CLIENTS_IN_MASTER;

View file

@ -1,4 +1,11 @@
use std::os::raw::*;
const MIN_BORDER_WIDTH: c_int = 0;
const MAX_BORDER_WIDTH: c_int = 10000;
#[no_mangle]
pub extern "C" fn foo() -> u32 {
123
pub extern "C" fn constraints_border_width(border_width: c_int) -> c_int {
if border_width < MIN_BORDER_WIDTH { return MIN_BORDER_WIDTH }
if border_width > MAX_BORDER_WIDTH { return MAX_BORDER_WIDTH }
border_width
}