From 031c6076f1785a62e9fd0d4e830ed84fa2ea91cc Mon Sep 17 00:00:00 2001 From: Arthur Beck Date: Thu, 6 Mar 2025 08:00:44 -0600 Subject: [PATCH] Add initial work. --- .gitignore | 5 +++++ .vscode/settings.json | 3 +++ Cargo.toml | 8 ++++++++ src/main.rs | 29 +++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore index ab951f8..620f8f6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ Cargo.lock # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +# Added by cargo + +/target diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..660eb93 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.check.command": "clippy" +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e755900 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "nuarth" +version = "0.1.0" +edition = "2024" + +[dependencies] +polling = "3.7.4" +wayland-server = "0.31.7" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3babeaf --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +//! The main code for Nuarth. +#![warn(missing_docs, clippy::missing_docs_in_private_items)] + +use polling::{Event, Poller}; + +/// The state of Nuarth. +struct State {} + +fn main() { + let display = wayland_server::Display::::new(); + if display.is_err() { + println!("[FATAL] Cannot load libwayland-server.so, exiting."); + println!("[HINT] Compile Nuarth with wayland_server's dlopen feature disabled\n[HINT] to not require this library"); + std::process::exit(1); + } + let mut display = display.unwrap(); // Error state is checked above + + let polling_fd = display.backend().poll_fd(); + let poller = Poller::new().unwrap(); // At the moment, this method cannot return an error. + unsafe { poller.add(&polling_fd, Event::readable(0)).unwrap(); } // At the moment, this method cannot return an error. + + let mut events = polling::Events::new(); + + loop { // Event loop + events.clear(); + poller.wait(&mut events, None).unwrap(); // At the moment, this method cannot return an error. + display.dispatch_clients(&mut State { }).unwrap(); // At the moment, this method cannot return an error. + } +}