diff --git a/Cargo.lock b/Cargo.lock index 8ee72e5..099fded 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,28 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + [[package]] name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "ctor" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "errno" version = "0.3.8" @@ -46,11 +62,37 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + [[package]] name = "rswm" version = "0.1.0" dependencies = [ "anyhow", + "as-raw-xcb-connection", + "tiny-xlib", "x11rb", ] @@ -67,6 +109,50 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tiny-xlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4098d49269baa034a8d1eae9bd63e9fa532148d772121dace3bcd6a6c98eb6d" +dependencies = [ + "as-raw-xcb-connection", + "ctor", + "tracing", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + [[package]] name = "windows-sys" version = "0.52.0" @@ -196,7 +282,9 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a" dependencies = [ + "as-raw-xcb-connection", "gethostname", + "libc", "rustix", "x11rb-protocol", ] diff --git a/Cargo.toml b/Cargo.toml index 70ee16e..dc4d6fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -x11rb = { version = "0.13.0", features = ["extra-traits"] } +tiny-xlib = "0.2.2" +as-raw-xcb-connection = "1.0.1" +x11rb = { version = "0.13.0", features = ["extra-traits", "allow-unsafe-code"] } anyhow = "1.0.79" diff --git a/src/main.rs b/src/main.rs index ecbc4da..5ee2d11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,8 @@ -use anyhow::anyhow; +use anyhow::{anyhow, Context}; + +use as_raw_xcb_connection::AsRawXcbConnection; +use tiny_xlib::Display; +use x11rb::xcb_ffi::XCBConnection; fn main() -> anyhow::Result<()> { let mut args = std::env::args().skip(1); @@ -13,7 +17,10 @@ fn main() -> anyhow::Result<()> { // TODO: Investigate LC_CTYPE and Locale stuff from dwm - // TODO: Open Display, dwm uses XOpenDisplay(NULL) or bail + // Here we open a display and get an x11rb connection, we could also just use xcb I think + let display = Display::new(None).context("Failed to open display")?; + let xcb_conn = display.as_raw_xcb_connection(); + let xcb_conn = unsafe { XCBConnection::from_raw_xcb_connection(xcb_conn.cast(), false)? }; // TODO: Check if there are other wms running