Merge Rust creates

This commit is contained in:
Alex Kotov 2022-09-09 18:11:21 +04:00
parent 2fbe9f00d0
commit ff9dabe3cd
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
7 changed files with 15 additions and 26 deletions

1
.gitignore vendored
View file

@ -10,5 +10,4 @@
# Rust # Rust
/Cargo.lock /Cargo.lock
/rust-polytreewm/Cargo.lock /rust-polytreewm/Cargo.lock
/rust-winproto/Cargo.lock
/target/ /target/

View file

@ -1,5 +1,4 @@
[workspace] [workspace]
members = [ members = [
"rust-polytreewm", "rust-polytreewm",
"rust-winproto",
] ]

View file

@ -19,10 +19,6 @@ RUST_SRC = \
rust-polytreewm/src/*.rs \ rust-polytreewm/src/*.rs \
rust-polytreewm/src/**/*.rs rust-polytreewm/src/**/*.rs
RUST_WINPROTO_SRC = \
rust-winproto/Cargo.toml \
rust-winproto/src/*.rs
RUST_APIS = src/constraints.h src/geom.h src/helpers.h src/settings.h RUST_APIS = src/constraints.h src/geom.h src/helpers.h src/settings.h
MODULES_SRC = \ MODULES_SRC = \
@ -67,10 +63,10 @@ ALL_EXE = polytreewm $(TEST_EXE)
# Executables # # Executables #
############### ###############
polytreewm: src/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a target/debug/libwinproto.a polytreewm: src/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a
$(CC) -o $@ $^ $(LDFLAGS) $(CC) -o $@ $^ $(LDFLAGS)
%.test: %.o tests/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a target/debug/libwinproto.a %.test: %.o tests/main.o $(MODULES_OBJ) target/debug/libpolytreewm.a
$(CC) -o $@ $^ $(LDFLAGS) $(CC) -o $@ $^ $(LDFLAGS)
################ ################
@ -85,9 +81,6 @@ dwm.o: $(DWM_SRC) $(DWM_HDR)
target/debug/libpolytreewm.a: $(RUST_SRC) target/debug/libpolytreewm.a: $(RUST_SRC)
$(CARGO) build $(CARGO) build
target/debug/libwinproto.a: $(RUST_WINPROTO_SRC)
$(CARGO) build
######### #########
# Tasks # # Tasks #
######### #########

View file

@ -20,3 +20,4 @@ crate-type = ["staticlib"]
ctor = "0.1.23" ctor = "0.1.23"
env_logger = "0.9.0" env_logger = "0.9.0"
log = "0.4.17" log = "0.4.17"
x11 = "2.20.0"

View file

@ -1,8 +1,10 @@
mod api; mod api;
mod constraints; mod constraints;
mod xbase;
pub mod geom; pub mod geom;
pub mod settings; pub mod settings;
pub mod unit; pub mod unit;
pub use settings::Settings; pub use settings::Settings;
pub use xbase::Xbase;

View file

@ -3,7 +3,7 @@ use std::ptr::null;
use x11::xlib::{self, Display}; use x11::xlib::{self, Display};
struct Xbase { pub struct Xbase {
program_title: String, program_title: String,
x_display: *mut Display, x_display: *mut Display,
x_screen: c_int, x_screen: c_int,
@ -11,7 +11,9 @@ struct Xbase {
} }
impl Xbase { impl Xbase {
fn new(program_title: String) -> Result<Self, Box<dyn std::error::Error>> { pub fn new(
program_title: String,
) -> Result<Self, Box<dyn std::error::Error>> {
unsafe { unsafe {
if xlib::XSupportsLocale() == 0 { if xlib::XSupportsLocale() == 0 {
return Err("no locale support in X".into()); return Err("no locale support in X".into());
@ -25,7 +27,12 @@ impl Xbase {
let x_screen = xlib::XDefaultScreen(x_display); let x_screen = xlib::XDefaultScreen(x_display);
let x_root = xlib::XRootWindow(x_display, x_screen); let x_root = xlib::XRootWindow(x_display, x_screen);
Ok(Self { program_title, x_display, x_screen, x_root }) Ok(Self {
program_title,
x_display,
x_screen,
x_root,
})
} }
} }
} }

View file

@ -1,12 +0,0 @@
[package]
name = "winproto"
version = "0.0.0"
edition = "2021"
publish = false
[lib]
name = "winproto"
crate-type = ["staticlib"]
[dependencies]
x11 = "2.20.0"