From bb832ae8857bb5daa96aced6870573d87dba8318 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Sat, 13 Apr 2024 17:56:02 +0200 Subject: [PATCH 01/12] Add wlcs stub --- Cargo.lock | 55 +++++++++++++++++++++++- Cargo.toml | 10 ++++- flake.nix | 11 +++++ wlcs_pinnacle/Cargo.toml | 16 +++++++ wlcs_pinnacle/src/lib.rs | 93 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 wlcs_pinnacle/Cargo.toml create mode 100644 wlcs_pinnacle/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 8a84965..b1211c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,6 +562,15 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "container_of" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89f5bbeb86761f66a87f8e327265ea0111f82f1928a84037b9abedab9f79472b" +dependencies = [ + "memoffset 0.6.5", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -1461,6 +1470,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -1532,6 +1550,17 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "libc", +] + [[package]] name = "nix" version = "0.28.0" @@ -1765,7 +1794,7 @@ dependencies = [ "cliclack", "dircpy", "image", - "nix", + "nix 0.28.0", "pinnacle", "pinnacle-api", "pinnacle-api-defs", @@ -3071,7 +3100,7 @@ dependencies = [ "dlib", "libc", "log", - "memoffset", + "memoffset 0.9.1", "once_cell", "pkg-config", ] @@ -3409,6 +3438,28 @@ dependencies = [ "memchr", ] +[[package]] +name = "wlcs" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d99c305ce368db32f0c675a3a17abbfd4123a59f4a1c56c0ee70b372cb7609e" +dependencies = [ + "container_of", + "memoffset 0.9.1", + "nix 0.27.1", + "wayland-sys", +] + +[[package]] +name = "wlcs_pinnacle" +version = "0.0.1" +dependencies = [ + "pinnacle", + "smithay", + "wayland-sys", + "wlcs", +] + [[package]] name = "x11-dl" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 66f596a..cdd64c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,10 @@ [workspace] -members = ["pinnacle-api-defs", "api/rust", "api/rust/pinnacle-api-macros"] +members = [ + "pinnacle-api-defs", + "api/rust", + "api/rust/pinnacle-api-macros", + "wlcs_pinnacle", +] [workspace.package] authors = ["Ottatop "] @@ -76,8 +81,9 @@ dircpy = { workspace = true } chrono = "0.4.37" bytemuck = "1.15.0" pinnacle-api = { path = "./api/rust" } +smithay = { workspace = true } -[dependencies.smithay] +[workspace.dependencies.smithay] git = "https://github.com/Smithay/smithay" rev = "c293ec7" default-features = false diff --git a/flake.nix b/flake.nix index a45ae39..081803d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,17 @@ rust-analyzer cargo-outdated + # wlcs + (writeScriptBin "wlcs" '' + #!/bin/sh + ${wlcs}/libexec/wlcs/wlcs "$@" + '') + + # build time stuff + pkg-config + protobuf + luarocks + wayland # build time stuff diff --git a/wlcs_pinnacle/Cargo.toml b/wlcs_pinnacle/Cargo.toml new file mode 100644 index 0000000..3cf10c2 --- /dev/null +++ b/wlcs_pinnacle/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "wlcs_pinnacle" +version = "0.0.1" +authors.workspace = true +edition.workspace = true +repository.workspace = true +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +smithay = { workspace = true } +pinnacle = { path = ".." } +wayland-sys = { version = "0.31.1", features = ["client", "server"] } +wlcs = "0.1" \ No newline at end of file diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs new file mode 100644 index 0000000..b388686 --- /dev/null +++ b/wlcs_pinnacle/src/lib.rs @@ -0,0 +1,93 @@ +use wayland_sys::{client::{wl_display, wl_proxy}, common::wl_fixed_t}; +use wlcs::{ + ffi_display_server_api::WlcsServerIntegration, ffi_wrappers::wlcs_server, + wlcs_server_integration, Pointer, Touch, Wlcs, +}; + +wlcs_server_integration!(PinnacleHandle); + +struct PinnacleHandle { + // server: Option<(Sender, JoinHandle<()>)>, +} + + +impl Wlcs for PinnacleHandle { + type Pointer = PointerHandle; + type Touch = TouchHandle; + + fn new() -> Self { + todo!() + } + + fn start(&mut self) { + todo!() + } + + fn stop(&mut self) { + todo!() + } + + fn create_client_socket(&self) -> std::io::Result { + todo!() + } + + fn position_window_absolute( + &self, + display: *mut wl_display, + surface: *mut wl_proxy, + x: i32, + y: i32, + ) { + todo!() + } + + fn create_pointer(&mut self) -> Option { + todo!() + } + + fn create_touch(&mut self) -> Option { + todo!() + } + + fn get_descriptor(&self) -> &wlcs::ffi_display_server_api::WlcsIntegrationDescriptor { + todo!() + } + + fn start_on_this_thread(&self, _event_loop: *mut wayland_sys::server::wl_event_loop) {} +} + +struct PointerHandle {} + +impl Pointer for PointerHandle { + fn move_absolute(&mut self, x: wl_fixed_t, y: wl_fixed_t) { + todo!() + } + + fn move_relative(&mut self, dx: wl_fixed_t, dy: wl_fixed_t) { + todo!() + } + + fn button_up(&mut self, button: i32) { + todo!() + } + + fn button_down(&mut self, button: i32) { + todo!() + } +} + +struct TouchHandle {} + +impl Touch for TouchHandle { + fn touch_down(&mut self, x: wayland_sys::common::wl_fixed_t, y: wayland_sys::common::wl_fixed_t) { + todo!() + } + + fn touch_move(&mut self, x: wayland_sys::common::wl_fixed_t, y: wayland_sys::common::wl_fixed_t) { + todo!() + } + + fn touch_up(&mut self) { + todo!() + } +} From 7adcb1d729e940e28d4d798ea4e7d1b8dd5ce7e0 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Mon, 15 Apr 2024 20:15:24 +0200 Subject: [PATCH 02/12] Make wlcs start --- Cargo.lock | 2 + Cargo.toml | 3 +- src/backend.rs | 2 + src/backend/dummy.rs | 17 ++- src/backend/wlcs.rs | 9 ++ wlcs_pinnacle/Cargo.toml | 7 +- wlcs_pinnacle/src/lib.rs | 257 +++++++++++++++++++++++++++++---- wlcs_pinnacle/src/main_loop.rs | 80 ++++++++++ 8 files changed, 344 insertions(+), 33 deletions(-) create mode 100644 src/backend/wlcs.rs create mode 100644 wlcs_pinnacle/src/main_loop.rs diff --git a/Cargo.lock b/Cargo.lock index b1211c1..65f698c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3456,6 +3456,8 @@ version = "0.0.1" dependencies = [ "pinnacle", "smithay", + "tracing", + "tracing-subscriber", "wayland-sys", "wlcs", ] diff --git a/Cargo.toml b/Cargo.toml index cdd64c7..40dae18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,10 +118,11 @@ xdg = { workspace = true } temp-env = "0.3.6" tempfile = "3.10.1" test-log = { version = "0.2.15", default-features = false, features = ["trace"] } -pinnacle = { path = ".", features = ["testing"] } +pinnacle = { path = ".", features = ["wlcs"] } pinnacle-api = { path = "./api/rust" } [features] testing = [ "smithay/renderer_test", ] +wlcs = [ "testing" ] diff --git a/src/backend.rs b/src/backend.rs index a4dc881..0d2d23e 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -43,6 +43,8 @@ use self::{udev::Udev, winit::Winit}; #[cfg(feature = "testing")] pub mod dummy; +#[cfg(feature = "wlcs")] +pub mod wlcs; pub mod udev; pub mod winit; diff --git a/src/backend/dummy.rs b/src/backend/dummy.rs index 3438139..ec602d4 100644 --- a/src/backend/dummy.rs +++ b/src/backend/dummy.rs @@ -16,6 +16,8 @@ use smithay::{ use crate::state::State; +#[cfg(feature = "wlcs")] +use super::wlcs::Wlcs; use super::Backend; use super::BackendData; @@ -24,13 +26,20 @@ pub const DUMMY_OUTPUT_NAME: &str = "Dummy Window"; pub struct Dummy { pub renderer: DummyRenderer, // pub dmabuf_state: (DmabufState, DmabufGlobal, Option), + #[cfg(feature = "wlcs")] + pub wlcs_state: Wlcs, } impl Backend { - fn dummy_mut(&mut self) -> &Dummy { + fn dummy_mut(&mut self) -> &mut Dummy { let Backend::Dummy(dummy) = self else { unreachable!() }; dummy } + + #[cfg(feature = "wlcs")] + pub fn wlcs_mut(&mut self) -> &mut Wlcs { + &mut self.dummy_mut().wlcs_state + } } impl BackendData for Dummy { @@ -91,6 +100,8 @@ pub fn setup_dummy( let backend = Dummy { renderer, // dmabuf_state, + #[cfg(feature = "wlcs")] + wlcs_state: Wlcs::default(), }; let mut state = State::init( @@ -110,7 +121,7 @@ pub fn setup_dummy( state.space.map_output(&output, (0, 0)); - if let Err(err) = state.xwayland.start( + /* if let Err(err) = state.xwayland.start( state.loop_handle.clone(), None, std::iter::empty::<(OsString, OsString)>(), @@ -118,7 +129,7 @@ pub fn setup_dummy( |_| {}, ) { tracing::error!("Failed to start XWayland: {err}"); - } + } */ Ok((state, event_loop)) } diff --git a/src/backend/wlcs.rs b/src/backend/wlcs.rs new file mode 100644 index 0000000..e290b03 --- /dev/null +++ b/src/backend/wlcs.rs @@ -0,0 +1,9 @@ +use std::{collections::HashMap, sync::{atomic::AtomicBool, Arc}}; + +use smithay::reexports::wayland_server::Client; + +#[derive(Default)] +pub struct Wlcs { + pub clients: HashMap, + pub running: Arc, +} diff --git a/wlcs_pinnacle/Cargo.toml b/wlcs_pinnacle/Cargo.toml index 3cf10c2..c82cdac 100644 --- a/wlcs_pinnacle/Cargo.toml +++ b/wlcs_pinnacle/Cargo.toml @@ -11,6 +11,9 @@ crate-type = ["cdylib"] [dependencies] smithay = { workspace = true } -pinnacle = { path = ".." } +pinnacle = { path = "..", features = [ "wlcs" ] } wayland-sys = { version = "0.31.1", features = ["client", "server"] } -wlcs = "0.1" \ No newline at end of file +wlcs = "0.1" + +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } \ No newline at end of file diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index b388686..4ebe3d3 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -1,34 +1,177 @@ -use wayland_sys::{client::{wl_display, wl_proxy}, common::wl_fixed_t}; +mod main_loop; + +use std::{ + io, + os::{ + fd::{AsRawFd, OwnedFd}, + unix::net::UnixStream, + }, + sync::{ + atomic::{AtomicU32, Ordering}, + mpsc::SendError, + Once, + }, + thread::{spawn, JoinHandle}, +}; + +use smithay::{ + reexports::calloop::channel::{channel, Sender}, + utils::{Logical, Point}, +}; +use tracing::{info, warn}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; +use wayland_sys::{ + client::{wayland_client_handle, wl_display, wl_proxy}, + common::{wl_fixed_t, wl_fixed_to_double}, + ffi_dispatch, +}; use wlcs::{ - ffi_display_server_api::WlcsServerIntegration, ffi_wrappers::wlcs_server, + extension_list, + ffi_display_server_api::{ + WlcsExtensionDescriptor, WlcsIntegrationDescriptor, WlcsServerIntegration, + }, + ffi_wrappers::wlcs_server, wlcs_server_integration, Pointer, Touch, Wlcs, }; wlcs_server_integration!(PinnacleHandle); -struct PinnacleHandle { - // server: Option<(Sender, JoinHandle<()>)>, +#[derive(Debug)] +pub enum WlcsEvent { + Stop, + NewClient { + stream: UnixStream, + client_id: i32, + }, + PositionWindow { + client_id: i32, + surface_id: u32, + location: Point, + }, + PointerMoveAbsolute { + device_id: u32, + location: Point, + }, + PointerMoveRelative { + device_id: u32, + location: Point, + }, + PointerButtonUp { + device_id: u32, + button_id: i32, + }, + PointerButtonDown { + device_id: u32, + button_id: i32, + }, + TouchDown { + device_id: u32, + location: Point, + }, + TouchMove { + device_id: u32, + location: Point, + }, + TouchUp { + device_id: u32, + }, } +struct PinnacleConnection { + sender: Sender, + join: JoinHandle<()>, +} + +impl PinnacleConnection { + fn start() -> Self { + let (sender, receiver) = channel(); + let join = spawn(move || main_loop::run(receiver)); + Self { sender, join } + } +} + +struct PinnacleHandle { + server_conn: Option, +} + +static SUPPORTED_EXTENSIONS: &[WlcsExtensionDescriptor] = extension_list!( + // ("wl_compositor", 4), + // ("wl_subcompositor", 1), + // ("wl_data_device_manager", 3), + // ("wl_seat", 7), + // ("wl_output", 4), + // ("xdg_wm_base", 3), +); + +static DESCRIPTOR: WlcsIntegrationDescriptor = WlcsIntegrationDescriptor { + version: 1, + num_extensions: SUPPORTED_EXTENSIONS.len(), + supported_extensions: SUPPORTED_EXTENSIONS.as_ptr(), +}; + +static DEVICE_ID: AtomicU32 = AtomicU32::new(0); + +fn new_device_id() -> u32 { + DEVICE_ID.fetch_add(1, Ordering::Relaxed) +} + +fn init() { + let env_filter = EnvFilter::try_from_default_env(); + + let stdout_env_filter = env_filter.unwrap_or_else(|_| EnvFilter::new("info")); + let stdout_layer = tracing_subscriber::fmt::layer() + .compact() + .with_writer(std::io::stdout) + .with_filter(stdout_env_filter); + + tracing_subscriber::registry().with(stdout_layer).init(); +} + +static INIT_ONCE: Once = Once::new(); impl Wlcs for PinnacleHandle { type Pointer = PointerHandle; type Touch = TouchHandle; fn new() -> Self { - todo!() + INIT_ONCE.call_once(init); + Self { server_conn: None } } fn start(&mut self) { - todo!() + info!("starting"); + self.server_conn = Some(PinnacleConnection::start()); + info!("started"); } fn stop(&mut self) { - todo!() + if let Some(conn) = self.server_conn.take() { + let _ = conn.sender.send(WlcsEvent::Stop); + conn.join.join().expect("failed to join"); + } } - fn create_client_socket(&self) -> std::io::Result { - todo!() + fn create_client_socket(&self) -> io::Result { + info!("new client start"); + let conn = self + .server_conn + .as_ref() + .ok_or(io::Error::from(io::ErrorKind::NotFound))?; + + let (client, server) = UnixStream::pair()?; + + conn.sender + .send(WlcsEvent::NewClient { + stream: server, + client_id: client.as_raw_fd(), + }) + .map_err(|e| { + warn!("failed to send NewClient event"); + io::Error::new(io::ErrorKind::ConnectionReset, e) + })?; + + info!("new client end"); + Ok(client.into()) } fn position_window_absolute( @@ -38,56 +181,116 @@ impl Wlcs for PinnacleHandle { x: i32, y: i32, ) { - todo!() + if let Some(conn) = &self.server_conn { + let client_id = + unsafe { ffi_dispatch!(wayland_client_handle(), wl_display_get_fd, display) }; + let surface_id = + unsafe { ffi_dispatch!(wayland_client_handle(), wl_proxy_get_id, surface) }; + let _ = conn.sender.send(WlcsEvent::PositionWindow { + client_id, + surface_id, + location: (x, y).into(), + }); + } } fn create_pointer(&mut self) -> Option { - todo!() + self.server_conn + .as_ref() + .map(|conn| conn.sender.clone()) + .map(|sender| PointerHandle { + device_id: new_device_id(), + sender, + }) } fn create_touch(&mut self) -> Option { - todo!() + self.server_conn + .as_ref() + .map(|conn| conn.sender.clone()) + .map(|sender| TouchHandle { + device_id: new_device_id(), + sender, + }) } - fn get_descriptor(&self) -> &wlcs::ffi_display_server_api::WlcsIntegrationDescriptor { - todo!() + fn get_descriptor(&self) -> &WlcsIntegrationDescriptor { + &DESCRIPTOR } - - fn start_on_this_thread(&self, _event_loop: *mut wayland_sys::server::wl_event_loop) {} } -struct PointerHandle {} +struct PointerHandle { + device_id: u32, + sender: Sender, +} impl Pointer for PointerHandle { fn move_absolute(&mut self, x: wl_fixed_t, y: wl_fixed_t) { - todo!() + self.sender + .send(WlcsEvent::PointerMoveAbsolute { + device_id: self.device_id, + location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + }) + .expect("failed to send move_absolute"); } fn move_relative(&mut self, dx: wl_fixed_t, dy: wl_fixed_t) { - todo!() + self.sender + .send(WlcsEvent::PointerMoveRelative { + device_id: self.device_id, + location: (wl_fixed_to_double(dx), wl_fixed_to_double(dy)).into(), + }) + .expect("failed to send move_relative"); } fn button_up(&mut self, button: i32) { - todo!() + self.sender + .send(WlcsEvent::PointerButtonUp { + device_id: self.device_id, + button_id: button, + }) + .expect("failed to send button_up"); } fn button_down(&mut self, button: i32) { - todo!() + self.sender + .send(WlcsEvent::PointerButtonDown { + device_id: self.device_id, + button_id: button, + }) + .expect("failed to send button_down"); } } -struct TouchHandle {} +struct TouchHandle { + device_id: u32, + sender: Sender, +} impl Touch for TouchHandle { - fn touch_down(&mut self, x: wayland_sys::common::wl_fixed_t, y: wayland_sys::common::wl_fixed_t) { - todo!() + fn touch_down(&mut self, x: wl_fixed_t, y: wl_fixed_t) { + self.sender + .send(WlcsEvent::TouchDown { + device_id: self.device_id, + location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + }) + .expect("failed to send touch_down"); } - fn touch_move(&mut self, x: wayland_sys::common::wl_fixed_t, y: wayland_sys::common::wl_fixed_t) { - todo!() + fn touch_move(&mut self, x: wl_fixed_t, y: wl_fixed_t) { + self.sender + .send(WlcsEvent::TouchMove { + device_id: self.device_id, + location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + }) + .expect("failed to send touch_move"); } fn touch_up(&mut self) { - todo!() + self.sender + .send(WlcsEvent::TouchUp { + device_id: self.device_id, + }) + .expect("failed to send touch_up"); } } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs new file mode 100644 index 0000000..84e9e97 --- /dev/null +++ b/wlcs_pinnacle/src/main_loop.rs @@ -0,0 +1,80 @@ +use std::sync::{atomic::Ordering, Arc}; + +use pinnacle::{ + backend::dummy::setup_dummy, + state::{ClientState, State}, +}; +use smithay::reexports::calloop::channel::{Channel, Event}; +use tracing::warn; + +use crate::WlcsEvent; + +pub(crate) fn run(channel: Channel) { + let (mut pinnacle_state, mut event_loop) = + setup_dummy(true, None).expect("failed to setup dummy backend"); + + event_loop + .handle() + .insert_source(channel, move |event, &mut (), data| match event { + Event::Msg(msg) => handle_event(msg, data), + Event::Closed => handle_event(WlcsEvent::Stop, data), + }) + .expect("failed to add wlcs event handler"); + + event_loop + .run(None, &mut pinnacle_state, |state| { + state.update_pointer_focus(); + state.fixup_z_layering(); + state.space.refresh(); + state.popup_manager.cleanup(); + + state + .display_handle + .flush_clients() + .expect("failed to flush client buffers"); + }) + .expect("failed to run event_loop"); +} + +fn handle_event(event: WlcsEvent, state: &mut State) { + match event { + WlcsEvent::Stop => state.loop_signal.stop(), + WlcsEvent::NewClient { stream, client_id } => { + let client: smithay::reexports::wayland_server::Client = state + .display_handle + .insert_client(stream, Arc::new(ClientState::default())) + .expect("failed to insert new client"); + state.backend.wlcs_mut().clients.insert(client_id, client); + } + WlcsEvent::PositionWindow { + client_id, + surface_id, + location, + } => warn!("PositionWindow"), + WlcsEvent::PointerMoveAbsolute { + device_id, + location, + } => warn!("PointerMoveAbsolute"), + WlcsEvent::PointerMoveRelative { + device_id, + location, + } => warn!("PointerMoveRelative"), + WlcsEvent::PointerButtonUp { + device_id, + button_id, + } => warn!("PointerButtonUp"), + WlcsEvent::PointerButtonDown { + device_id, + button_id, + } => warn!("PointerButtonDown"), + WlcsEvent::TouchDown { + device_id, + location, + } => warn!("TouchDown"), + WlcsEvent::TouchMove { + device_id, + location, + } => warn!("TouchMove"), + WlcsEvent::TouchUp { device_id } => warn!("TouchUp"), + } +} From e8b8a33bfc02b87705e77b5741bda397ae70e813 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Tue, 16 Apr 2024 20:07:10 +0200 Subject: [PATCH 03/12] Make wlcs run some actual tests --- Cargo.lock | 8 + Cargo.toml | 1 + src/backend/dummy.rs | 2 +- src/config.rs | 13 +- wlcs_pinnacle/Cargo.toml | 4 +- wlcs_pinnacle/src/lib.rs | 35 +- wlcs_pinnacle/src/main_loop.rs | 164 +- wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock | 1315 +++++++++++++++++ wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml | 7 + .../wlcs_pinnacle_config/metaconfig.toml | 46 + .../wlcs_pinnacle_config/pinnacle-config | 1 + .../wlcs_pinnacle_config/src/main.rs | 36 + 12 files changed, 1576 insertions(+), 56 deletions(-) create mode 100644 wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock create mode 100644 wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml create mode 100644 wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml create mode 120000 wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config create mode 100644 wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 65f698c..cabd5b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3456,12 +3456,20 @@ version = "0.0.1" dependencies = [ "pinnacle", "smithay", + "tokio", "tracing", "tracing-subscriber", "wayland-sys", "wlcs", ] +[[package]] +name = "wlcs_pinnacle_config" +version = "0.1.0" +dependencies = [ + "pinnacle-api", +] + [[package]] name = "x11-dl" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 40dae18..cc19785 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "api/rust", "api/rust/pinnacle-api-macros", "wlcs_pinnacle", + "wlcs_pinnacle/wlcs_pinnacle_config", ] [workspace.package] diff --git a/src/backend/dummy.rs b/src/backend/dummy.rs index ec602d4..d46ae37 100644 --- a/src/backend/dummy.rs +++ b/src/backend/dummy.rs @@ -72,7 +72,7 @@ pub fn setup_dummy( size: (0, 0).into(), subpixel: Subpixel::Unknown, make: "Pinnacle".to_string(), - model: "Winit Window".to_string(), + model: "Dummy Window".to_string(), }; let output = Output::new(DUMMY_OUTPUT_NAME.to_string(), physical_properties); diff --git a/src/config.rs b/src/config.rs index 918f15a..db6ebdf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -563,11 +563,18 @@ impl State { error!("gRPC server error: {err}"); } })); - } + }, + None => { + self.grpc_server_join_handle = Some(tokio::spawn(async move { + if let Err(err) = grpc_server.serve_with_incoming(uds_stream).await { + error!("gRPC server error: {err}"); + } + })); + }, // FIXME: Not really high priority but if you somehow reload the config really, REALLY // | fast at startup then I think there's a chance that the gRPC server // | could get started twice. - None => self.schedule( + /* None => self.schedule( |state| state.xdisplay.is_some(), move |state| { state.grpc_server_join_handle = Some(tokio::spawn(async move { @@ -576,7 +583,7 @@ impl State { } })); }, - ), + ), */ } Ok(()) diff --git a/wlcs_pinnacle/Cargo.toml b/wlcs_pinnacle/Cargo.toml index c82cdac..aeddf74 100644 --- a/wlcs_pinnacle/Cargo.toml +++ b/wlcs_pinnacle/Cargo.toml @@ -16,4 +16,6 @@ wayland-sys = { version = "0.31.1", features = ["client", "server"] } wlcs = "0.1" tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } \ No newline at end of file +tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } + +tokio = { workspace = true, features = ["net", "rt"] } \ No newline at end of file diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index 4ebe3d3..2ffbfe8 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -8,7 +8,6 @@ use std::{ }, sync::{ atomic::{AtomicU32, Ordering}, - mpsc::SendError, Once, }, thread::{spawn, JoinHandle}, @@ -48,21 +47,15 @@ pub enum WlcsEvent { surface_id: u32, location: Point, }, - PointerMoveAbsolute { + PointerMove { device_id: u32, - location: Point, + position: Point, + absolute: bool, }, - PointerMoveRelative { - device_id: u32, - location: Point, - }, - PointerButtonUp { - device_id: u32, - button_id: i32, - }, - PointerButtonDown { + PointerButton { device_id: u32, button_id: i32, + pressed: bool, }, TouchDown { device_id: u32, @@ -139,9 +132,7 @@ impl Wlcs for PinnacleHandle { } fn start(&mut self) { - info!("starting"); self.server_conn = Some(PinnacleConnection::start()); - info!("started"); } fn stop(&mut self) { @@ -227,36 +218,40 @@ struct PointerHandle { impl Pointer for PointerHandle { fn move_absolute(&mut self, x: wl_fixed_t, y: wl_fixed_t) { self.sender - .send(WlcsEvent::PointerMoveAbsolute { + .send(WlcsEvent::PointerMove { device_id: self.device_id, - location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + position: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + absolute: true, }) .expect("failed to send move_absolute"); } fn move_relative(&mut self, dx: wl_fixed_t, dy: wl_fixed_t) { self.sender - .send(WlcsEvent::PointerMoveRelative { + .send(WlcsEvent::PointerMove { device_id: self.device_id, - location: (wl_fixed_to_double(dx), wl_fixed_to_double(dy)).into(), + position: (wl_fixed_to_double(dx), wl_fixed_to_double(dy)).into(), + absolute: false, }) .expect("failed to send move_relative"); } fn button_up(&mut self, button: i32) { self.sender - .send(WlcsEvent::PointerButtonUp { + .send(WlcsEvent::PointerButton { device_id: self.device_id, button_id: button, + pressed: false, }) .expect("failed to send button_up"); } fn button_down(&mut self, button: i32) { self.sender - .send(WlcsEvent::PointerButtonDown { + .send(WlcsEvent::PointerButton { device_id: self.device_id, button_id: button, + pressed: true, }) .expect("failed to send button_down"); } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index 84e9e97..eb1f98f 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -1,17 +1,30 @@ -use std::sync::{atomic::Ordering, Arc}; +use std::{sync::Arc, thread, time::Duration}; use pinnacle::{ backend::dummy::setup_dummy, + focus::{keyboard::KeyboardFocusTarget, pointer::PointerFocusTarget}, state::{ClientState, State}, }; -use smithay::reexports::calloop::channel::{Channel, Event}; +use smithay::{ + backend::input::ButtonState, + input::pointer::{ButtonEvent, MotionEvent, RelativeMotionEvent}, + reexports::{ + calloop::channel::{Channel, Event}, + wayland_server::Resource, + }, + utils::SERIAL_COUNTER, + wayland::seat::WaylandFocus, +}; use tracing::warn; use crate::WlcsEvent; pub(crate) fn run(channel: Channel) { - let (mut pinnacle_state, mut event_loop) = - setup_dummy(true, None).expect("failed to setup dummy backend"); + let config_path = + &std::env::var("PINNACLE_WLCS_CONFIG_PATH").expect("PINNACLE_WLCS_CONFIG_PATH not set"); + + let (mut state, mut event_loop) = + setup_dummy(false, Some(config_path.into())).expect("failed to setup dummy backend"); event_loop .handle() @@ -21,8 +34,25 @@ pub(crate) fn run(channel: Channel) { }) .expect("failed to add wlcs event handler"); + // FIXME: a better way to deal with tokio here? + let rt = tokio::runtime::Runtime::new().expect("failed to create tokio runtime"); + let _handle = rt.enter(); + + if let Err(err) = state.start_config(config_path) { + panic!("failed to start config: {err}"); + } + + // FIXME: different sock_dir per instance? + while state.layout_state.layout_request_sender.is_none() { + event_loop + .dispatch(Some(Duration::from_millis(10)), &mut state) + .expect("event_loop error while waiting for config"); + } + + // TODO: handle no-xwayland properly + event_loop - .run(None, &mut pinnacle_state, |state| { + .run(None, &mut state, |state| { state.update_pointer_focus(); state.fixup_z_layering(); state.space.refresh(); @@ -38,7 +68,7 @@ pub(crate) fn run(channel: Channel) { fn handle_event(event: WlcsEvent, state: &mut State) { match event { - WlcsEvent::Stop => state.loop_signal.stop(), + WlcsEvent::Stop => state.shutdown(), WlcsEvent::NewClient { stream, client_id } => { let client: smithay::reexports::wayland_server::Client = state .display_handle @@ -50,31 +80,103 @@ fn handle_event(event: WlcsEvent, state: &mut State) { client_id, surface_id, location, - } => warn!("PositionWindow"), - WlcsEvent::PointerMoveAbsolute { - device_id, - location, - } => warn!("PointerMoveAbsolute"), - WlcsEvent::PointerMoveRelative { - device_id, - location, - } => warn!("PointerMoveRelative"), - WlcsEvent::PointerButtonUp { - device_id, + } => { + let client = state.backend.wlcs_mut().clients.get(&client_id); + let toplevel = state.space.elements().find(|w| { + if let Some(surface) = w.wl_surface() { + state.display_handle.get_client(surface.id()).ok().as_ref() == client + && surface.id().protocol_id() == surface_id + } else { + false + } + }); + + if let Some(toplevel) = toplevel { + state.space.map_element(toplevel.clone(), location, false); + } + } + WlcsEvent::PointerMove { + device_id: _, + position, + absolute, + } => { + let serial = SERIAL_COUNTER.next_serial(); + let ptr = state.seat.get_pointer().unwrap(); + let ptr_location = ptr.current_location(); + + let location = if absolute { position } else { ptr_location + position }; + + let under = state + .space + .element_under(location) + .and_then(|(w, _)| w.wl_surface()) + .map(|surf| (PointerFocusTarget::WlSurface(surf), location.to_i32_round())); + + let time = Duration::from(state.clock.now()).as_millis() as u32; + ptr.motion( + state, + under.clone(), + &MotionEvent { + location, + serial, + time, + }, + ); + + if !absolute { + let utime = Duration::from(state.clock.now()).as_micros() as u64; + ptr.relative_motion( + state, + under, + &RelativeMotionEvent { + delta: position, + delta_unaccel: position, + utime, + }, + ) + } + ptr.frame(state); + } + WlcsEvent::PointerButton { + device_id: _, button_id, - } => warn!("PointerButtonUp"), - WlcsEvent::PointerButtonDown { - device_id, - button_id, - } => warn!("PointerButtonDown"), - WlcsEvent::TouchDown { - device_id, - location, - } => warn!("TouchDown"), - WlcsEvent::TouchMove { - device_id, - location, - } => warn!("TouchMove"), - WlcsEvent::TouchUp { device_id } => warn!("TouchUp"), + pressed, + } => { + let serial = SERIAL_COUNTER.next_serial(); + let ptr = state.seat.get_pointer().unwrap(); + if !ptr.is_grabbed() { + let ptr_location = ptr.current_location(); + let under = state + .space + .element_under(ptr_location) + .map(|(w, _)| w.clone()); + if let Some(win) = &under { + state.space.raise_element(win, true); + } + state.seat.get_keyboard().unwrap().set_focus( + state, + under.map(|w| KeyboardFocusTarget::Window(w)), + serial, + ); + } + let time = Duration::from(state.clock.now()).as_millis() as u32; + ptr.button( + state, + &ButtonEvent { + serial, + time, + button: button_id as u32, + state: if pressed { + ButtonState::Pressed + } else { + ButtonState::Released + }, + }, + ); + ptr.frame(state); + } + WlcsEvent::TouchDown { .. } => warn!("TouchDown"), + WlcsEvent::TouchMove { .. } => warn!("TouchMove"), + WlcsEvent::TouchUp { .. } => warn!("TouchUp"), } } diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock b/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock new file mode 100644 index 0000000..a2fed59 --- /dev/null +++ b/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock @@ -0,0 +1,1315 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "memmap2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" +dependencies = [ + "libc", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multimap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.2.6", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pinnacle-api" +version = "0.0.2" +source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" +dependencies = [ + "futures", + "num_enum", + "pinnacle-api-defs", + "pinnacle-api-macros", + "rand", + "tokio", + "tokio-stream", + "tonic", + "tower", + "xkbcommon", +] + +[[package]] +name = "pinnacle-api-defs" +version = "0.0.1" +source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" +dependencies = [ + "const_format", + "prost", + "tonic", + "tonic-build", +] + +[[package]] +name = "pinnacle-api-macros" +version = "0.0.2" +source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pinnacle-config" +version = "0.1.0" +dependencies = [ + "pinnacle-api", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "syn" +version = "2.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "xkbcommon" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13867d259930edc7091a6c41b4ce6eee464328c6ff9659b7e4c668ca20d4c91e" +dependencies = [ + "libc", + "memmap2", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml b/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml new file mode 100644 index 0000000..ed668e2 --- /dev/null +++ b/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "wlcs_pinnacle_config" +version = "0.1.0" +edition = "2021" + +[dependencies] +pinnacle-api = { path = "../../api/rust" } diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml b/wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml new file mode 100644 index 0000000..2afc257 --- /dev/null +++ b/wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml @@ -0,0 +1,46 @@ +# This metaconfig.toml file dictates what config Pinnacle will run. +# +# When running Pinnacle, the compositor will look in the following directories for a metaconfig.toml file, +# in order from top to bottom: +# $PINNACLE_CONFIG_DIR +# $XDG_CONFIG_HOME/pinnacle/ +# ~/.config/pinnacle/ +# +# When Pinnacle finds a metaconfig.toml file, it will execute the command provided to `command`. +# To use a Rust config, this should be changed to something like ["cargo", "run"]. +# +# Because configuration is done using an external process, if it ever crashes, you lose all of your keybinds. +# The compositor will load the default config if that happens, but in the event that you don't have +# the necessary dependencies for it to run, you may get softlocked. +# In order prevent you from getting stuck in the compositor, you must define keybinds to reload your config +# and kill Pinnacle. +# +# More details on each setting can be found below. + +# The command Pinnacle will run on startup and when you reload your config. +# Paths are relative to the directory the metaconfig.toml file is in. +# This must be an array. +command = ["./pinnacle-config"] + +### Keybinds ### +# Each keybind takes in a table with two fields: `modifiers` and `key`. +# - `modifiers` can be one of "Ctrl", "Alt", "Shift", or "Super". +# - `key` can be a string of any lowercase letter, number, +# "numN" where N is a number for numpad keys, or "esc"/"escape". +# Support for any xkbcommon key is planned for a future update. + +# The keybind that will reload your config. +reload_keybind = { modifiers = ["Ctrl", "Alt"], key = "r" } +# The keybind that will kill Pinnacle. +kill_keybind = { modifiers = ["Ctrl", "Alt", "Shift"], key = "escape" } + +### Socket directory ### +# Pinnacle will open a Unix socket at `$XDG_RUNTIME_DIR` by default, falling back to `/tmp` if it doesn't exist. +# If you want/need to change this, use the `socket_dir` setting set to the directory of your choosing. +# +# socket_dir = "/your/dir/here/" + +### Environment Variables ### +# If you need to spawn your config with any environment variables, list them here. +[envs] +# key = "value" diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config b/wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config new file mode 120000 index 0000000..a1bddd4 --- /dev/null +++ b/wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config @@ -0,0 +1 @@ +../../target/debug/pinnacle-config \ No newline at end of file diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs b/wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs new file mode 100644 index 0000000..6e47f45 --- /dev/null +++ b/wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs @@ -0,0 +1,36 @@ +use pinnacle_api::layout::{CyclingLayoutManager, MasterStackLayout}; +use pinnacle_api::ApiModules; + +// Pinnacle needs to perform some setup before and after your config. +// The `#[pinnacle_api::config(modules)]` attribute does so and +// will bind all the config structs to the provided identifier. +#[pinnacle_api::config(modules)] +async fn main() { + // Deconstruct to get all the APIs. + #[allow(unused_variables)] + let ApiModules { + pinnacle, + process, + window, + input, + output, + tag, + layout, + render, + } = modules; + + let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ + Box::::default() as _, + ])); + + // Setup all monitors with tags "1" through "5" + output.connect_for_all(move |op| { + let tags = tag.add(op, ["tag"]); + tags.first().unwrap().set_active(true); + }); + + // Enable sloppy focus + /* window.connect_signal(WindowSignal::PointerEnter(Box::new(|win| { + win.set_focused(true); + }))); */ +} From fb8b6e166c8096e1ad9b12ff57bfca355468252a Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Tue, 16 Apr 2024 20:58:13 +0200 Subject: [PATCH 04/12] Clean up some stuff and move the config for wlcs tests --- Cargo.toml | 2 +- wlcs_pinnacle/{wlcs_pinnacle_config => config}/Cargo.lock | 0 wlcs_pinnacle/{wlcs_pinnacle_config => config}/Cargo.toml | 0 wlcs_pinnacle/{wlcs_pinnacle_config => config}/metaconfig.toml | 0 wlcs_pinnacle/{wlcs_pinnacle_config => config}/pinnacle-config | 0 wlcs_pinnacle/{wlcs_pinnacle_config => config}/src/main.rs | 0 wlcs_pinnacle/src/lib.rs | 2 +- wlcs_pinnacle/src/main_loop.rs | 2 +- 8 files changed, 3 insertions(+), 3 deletions(-) rename wlcs_pinnacle/{wlcs_pinnacle_config => config}/Cargo.lock (100%) rename wlcs_pinnacle/{wlcs_pinnacle_config => config}/Cargo.toml (100%) rename wlcs_pinnacle/{wlcs_pinnacle_config => config}/metaconfig.toml (100%) rename wlcs_pinnacle/{wlcs_pinnacle_config => config}/pinnacle-config (100%) rename wlcs_pinnacle/{wlcs_pinnacle_config => config}/src/main.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index cc19785..5c74d85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "api/rust", "api/rust/pinnacle-api-macros", "wlcs_pinnacle", - "wlcs_pinnacle/wlcs_pinnacle_config", + "wlcs_pinnacle/config", ] [workspace.package] diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock b/wlcs_pinnacle/config/Cargo.lock similarity index 100% rename from wlcs_pinnacle/wlcs_pinnacle_config/Cargo.lock rename to wlcs_pinnacle/config/Cargo.lock diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml b/wlcs_pinnacle/config/Cargo.toml similarity index 100% rename from wlcs_pinnacle/wlcs_pinnacle_config/Cargo.toml rename to wlcs_pinnacle/config/Cargo.toml diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml b/wlcs_pinnacle/config/metaconfig.toml similarity index 100% rename from wlcs_pinnacle/wlcs_pinnacle_config/metaconfig.toml rename to wlcs_pinnacle/config/metaconfig.toml diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config b/wlcs_pinnacle/config/pinnacle-config similarity index 100% rename from wlcs_pinnacle/wlcs_pinnacle_config/pinnacle-config rename to wlcs_pinnacle/config/pinnacle-config diff --git a/wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs b/wlcs_pinnacle/config/src/main.rs similarity index 100% rename from wlcs_pinnacle/wlcs_pinnacle_config/src/main.rs rename to wlcs_pinnacle/config/src/main.rs diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index 2ffbfe8..a4cb482 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -138,7 +138,7 @@ impl Wlcs for PinnacleHandle { fn stop(&mut self) { if let Some(conn) = self.server_conn.take() { let _ = conn.sender.send(WlcsEvent::Stop); - conn.join.join().expect("failed to join"); + let _ = conn.join.join(); } } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index eb1f98f..02a5b90 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -1,4 +1,4 @@ -use std::{sync::Arc, thread, time::Duration}; +use std::{sync::Arc, time::Duration}; use pinnacle::{ backend::dummy::setup_dummy, From abb21d99243ccd8ea39a0d2b9f1bf54cba3b0358 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Wed, 17 Apr 2024 20:59:19 +0200 Subject: [PATCH 05/12] Perform wlcs interactions using an InputBackend --- src/backend.rs | 4 +- src/config.rs | 4 +- wlcs_pinnacle/src/input_backend.rs | 332 +++++++++++++++++++++++++++++ wlcs_pinnacle/src/lib.rs | 48 +++-- wlcs_pinnacle/src/main_loop.rs | 163 +++++++------- 5 files changed, 449 insertions(+), 102 deletions(-) create mode 100644 wlcs_pinnacle/src/input_backend.rs diff --git a/src/backend.rs b/src/backend.rs index 0d2d23e..659e546 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -43,10 +43,10 @@ use self::{udev::Udev, winit::Winit}; #[cfg(feature = "testing")] pub mod dummy; -#[cfg(feature = "wlcs")] -pub mod wlcs; pub mod udev; pub mod winit; +#[cfg(feature = "wlcs")] +pub mod wlcs; pub enum Backend { /// The compositor is running in a Winit window diff --git a/src/config.rs b/src/config.rs index db6ebdf..7a56042 100644 --- a/src/config.rs +++ b/src/config.rs @@ -563,14 +563,14 @@ impl State { error!("gRPC server error: {err}"); } })); - }, + } None => { self.grpc_server_join_handle = Some(tokio::spawn(async move { if let Err(err) = grpc_server.serve_with_incoming(uds_stream).await { error!("gRPC server error: {err}"); } })); - }, + } // FIXME: Not really high priority but if you somehow reload the config really, REALLY // | fast at startup then I think there's a chance that the gRPC server // | could get started twice. diff --git a/wlcs_pinnacle/src/input_backend.rs b/wlcs_pinnacle/src/input_backend.rs new file mode 100644 index 0000000..cf916a9 --- /dev/null +++ b/wlcs_pinnacle/src/input_backend.rs @@ -0,0 +1,332 @@ +use core::hash::Hash; + +use smithay::{ + backend::input::{ + AbsolutePositionEvent, ButtonState, Device, DeviceCapability, Event, InputBackend, + InputEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent, + TouchDownEvent, TouchEvent, TouchMotionEvent, TouchSlot, TouchUpEvent, UnusedEvent, + }, + utils::{Logical, Point}, +}; + +pub struct WlcsInputBackend {} + +impl InputBackend for WlcsInputBackend { + type Device = WlcsDevice; + type KeyboardKeyEvent = UnusedEvent; + type PointerAxisEvent = UnusedEvent; + type PointerButtonEvent = WlcsPointerButtonEvent; + type PointerMotionEvent = WlcsPointerMotionEvent; + type PointerMotionAbsoluteEvent = WlcsPointerMotionAbsoluteEvent; + type GestureSwipeBeginEvent = UnusedEvent; + type GestureSwipeUpdateEvent = UnusedEvent; + type GestureSwipeEndEvent = UnusedEvent; + type GesturePinchBeginEvent = UnusedEvent; + type GesturePinchUpdateEvent = UnusedEvent; + type GesturePinchEndEvent = UnusedEvent; + type GestureHoldBeginEvent = UnusedEvent; + type GestureHoldEndEvent = UnusedEvent; + type TouchDownEvent = WlcsTouchDownEvent; + type TouchUpEvent = WlcsTouchUpEvent; + type TouchMotionEvent = WlcsTouchMotionEvent; + type TouchCancelEvent = UnusedEvent; + type TouchFrameEvent = UnusedEvent; + type TabletToolAxisEvent = UnusedEvent; + type TabletToolProximityEvent = UnusedEvent; + type TabletToolTipEvent = UnusedEvent; + type TabletToolButtonEvent = UnusedEvent; + type SwitchToggleEvent = UnusedEvent; + type SpecialEvent = (); +} + +#[derive(PartialEq, Eq)] +pub struct WlcsDevice { + pub device_id: u32, + pub capability: DeviceCapability, +} + +impl Hash for WlcsDevice { + fn hash(&self, state: &mut H) { + self.device_id.hash(state); + } +} + +impl Device for WlcsDevice { + fn id(&self) -> String { + format!("{}", self.device_id).into() + } + + fn name(&self) -> String { + format!("wlcs-device-{}", self.device_id).into() + } + + fn has_capability(&self, capability: DeviceCapability) -> bool { + self.capability == capability + } + + fn usb_id(&self) -> Option<(u32, u32)> { + None + } + + fn syspath(&self) -> Option { + None + } +} + +pub struct WlcsPointerButtonEvent { + pub device_id: u32, + pub time: u64, + pub button_code: u32, + pub state: ButtonState, +} + +impl Into> for WlcsPointerButtonEvent { + fn into(self) -> InputEvent { + InputEvent::::PointerButton { event: self } + } +} + +impl Event for WlcsPointerButtonEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Pointer, + } + } +} + +impl PointerButtonEvent for WlcsPointerButtonEvent { + fn button_code(&self) -> u32 { + self.button_code + } + + fn state(&self) -> ButtonState { + self.state + } +} + +pub struct WlcsPointerMotionEvent { + pub device_id: u32, + pub time: u64, + pub delta: Point, +} + +impl Into> for WlcsPointerMotionEvent { + fn into(self) -> InputEvent { + InputEvent::::PointerMotion { event: self } + } +} + +impl Event for WlcsPointerMotionEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Pointer, + } + } +} + +impl PointerMotionEvent for WlcsPointerMotionEvent { + fn delta_x(&self) -> f64 { + self.delta.x + } + + fn delta_y(&self) -> f64 { + self.delta.y + } + + fn delta_x_unaccel(&self) -> f64 { + self.delta_x() + } + + fn delta_y_unaccel(&self) -> f64 { + self.delta_y() + } +} + +pub struct WlcsPointerMotionAbsoluteEvent { + pub device_id: u32, + pub time: u64, + pub position: Point, +} + +impl Into> for WlcsPointerMotionAbsoluteEvent { + fn into(self) -> InputEvent { + InputEvent::::PointerMotionAbsolute { event: self } + } +} + +impl Event for WlcsPointerMotionAbsoluteEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Pointer, + } + } +} + +impl AbsolutePositionEvent for WlcsPointerMotionAbsoluteEvent { + fn x(&self) -> f64 { + self.position.x + } + + fn y(&self) -> f64 { + self.position.y + } + + fn x_transformed(&self, _width: i32) -> f64 { + self.x() + } + + fn y_transformed(&self, _height: i32) -> f64 { + self.y() + } +} + +impl PointerMotionAbsoluteEvent for WlcsPointerMotionAbsoluteEvent {} + +pub struct WlcsTouchDownEvent { + pub device_id: u32, + pub time: u64, + pub position: Point, +} + +impl Into> for WlcsTouchDownEvent { + fn into(self) -> InputEvent { + InputEvent::::TouchDown { event: self } + } +} + +impl Event for WlcsTouchDownEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Touch, + } + } +} + +impl TouchEvent for WlcsTouchDownEvent { + fn slot(&self) -> TouchSlot { + None.into() + } +} + +impl AbsolutePositionEvent for WlcsTouchDownEvent { + fn x(&self) -> f64 { + self.position.x + } + + fn y(&self) -> f64 { + self.position.y + } + + fn x_transformed(&self, _width: i32) -> f64 { + self.x() + } + + fn y_transformed(&self, _height: i32) -> f64 { + self.y() + } +} + +impl TouchDownEvent for WlcsTouchDownEvent {} + +pub struct WlcsTouchUpEvent { + pub device_id: u32, + pub time: u64, +} + +impl Into> for WlcsTouchUpEvent { + fn into(self) -> InputEvent { + InputEvent::::TouchUp { event: self } + } +} + +impl Event for WlcsTouchUpEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Touch, + } + } +} + +impl TouchEvent for WlcsTouchUpEvent { + fn slot(&self) -> TouchSlot { + None.into() + } +} + +impl TouchUpEvent for WlcsTouchUpEvent {} + +pub struct WlcsTouchMotionEvent { + pub device_id: u32, + pub time: u64, + pub position: Point, +} + +impl Into> for WlcsTouchMotionEvent { + fn into(self) -> InputEvent { + InputEvent::::TouchMotion { event: self } + } +} + +impl Event for WlcsTouchMotionEvent { + fn time(&self) -> u64 { + self.time + } + + fn device(&self) -> ::Device { + WlcsDevice { + device_id: self.device_id, + capability: DeviceCapability::Touch, + } + } +} + +impl TouchEvent for WlcsTouchMotionEvent { + fn slot(&self) -> TouchSlot { + None.into() + } +} + +impl AbsolutePositionEvent for WlcsTouchMotionEvent { + fn x(&self) -> f64 { + self.position.x + } + + fn y(&self) -> f64 { + self.position.y + } + + fn x_transformed(&self, _width: i32) -> f64 { + self.x() + } + + fn y_transformed(&self, _height: i32) -> f64 { + self.y() + } +} + +impl TouchMotionEvent for WlcsTouchMotionEvent {} diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index a4cb482..1e7e608 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -1,3 +1,4 @@ +mod input_backend; mod main_loop; use std::{ @@ -47,23 +48,32 @@ pub enum WlcsEvent { surface_id: u32, location: Point, }, - PointerMove { + NewPointer { + device_id: u32, + }, + PointerMoveRelative { + device_id: u32, + delta: Point, + }, + PointerMoveAbsolute { device_id: u32, position: Point, - absolute: bool, }, PointerButton { device_id: u32, button_id: i32, pressed: bool, }, + NewTouch { + device_id: u32, + }, TouchDown { device_id: u32, - location: Point, + position: Point, }, TouchMove { device_id: u32, - location: Point, + position: Point, }, TouchUp { device_id: u32, @@ -88,12 +98,18 @@ struct PinnacleHandle { } static SUPPORTED_EXTENSIONS: &[WlcsExtensionDescriptor] = extension_list!( - // ("wl_compositor", 4), - // ("wl_subcompositor", 1), - // ("wl_data_device_manager", 3), - // ("wl_seat", 7), - // ("wl_output", 4), - // ("xdg_wm_base", 3), + // Skip reasons: + // 5 Missing extension: gtk_primary_selection_device_manager>= 1 + // 1 Missing extension: wlcs_non_existent_extension>= 1 + // 89 Missing extension: wl_shell>= 2 + // 1 Missing extension: xdg_not_really_an_extension>= 1 + // 30 Missing extension: zwlr_foreign_toplevel_manager_v1>= 1 + // 12 Missing extension: zwlr_virtual_pointer_manager_v1>= 1 + // 15 Missing extension: zwp_pointer_constraints_v1>= 1 + // 3 Missing extension: zwp_relative_pointer_manager_v1>= 1 + // 12 Missing extension: zwp_text_input_manager_v2>= 1 + // 11 Missing extension: zwp_text_input_manager_v3>= 1 + // 180 Missing extension: zxdg_shell_v6>= 1 ); static DESCRIPTOR: WlcsIntegrationDescriptor = WlcsIntegrationDescriptor { @@ -218,20 +234,18 @@ struct PointerHandle { impl Pointer for PointerHandle { fn move_absolute(&mut self, x: wl_fixed_t, y: wl_fixed_t) { self.sender - .send(WlcsEvent::PointerMove { + .send(WlcsEvent::PointerMoveAbsolute { device_id: self.device_id, position: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), - absolute: true, }) .expect("failed to send move_absolute"); } fn move_relative(&mut self, dx: wl_fixed_t, dy: wl_fixed_t) { self.sender - .send(WlcsEvent::PointerMove { + .send(WlcsEvent::PointerMoveRelative { device_id: self.device_id, - position: (wl_fixed_to_double(dx), wl_fixed_to_double(dy)).into(), - absolute: false, + delta: (wl_fixed_to_double(dx), wl_fixed_to_double(dy)).into(), }) .expect("failed to send move_relative"); } @@ -267,7 +281,7 @@ impl Touch for TouchHandle { self.sender .send(WlcsEvent::TouchDown { device_id: self.device_id, - location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + position: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), }) .expect("failed to send touch_down"); } @@ -276,7 +290,7 @@ impl Touch for TouchHandle { self.sender .send(WlcsEvent::TouchMove { device_id: self.device_id, - location: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), + position: (wl_fixed_to_double(x), wl_fixed_to_double(y)).into(), }) .expect("failed to send touch_move"); } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index 02a5b90..e6a602e 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -2,22 +2,24 @@ use std::{sync::Arc, time::Duration}; use pinnacle::{ backend::dummy::setup_dummy, - focus::{keyboard::KeyboardFocusTarget, pointer::PointerFocusTarget}, state::{ClientState, State}, }; use smithay::{ - backend::input::ButtonState, - input::pointer::{ButtonEvent, MotionEvent, RelativeMotionEvent}, + backend::input::{ButtonState, DeviceCapability, InputEvent}, reexports::{ calloop::channel::{Channel, Event}, wayland_server::Resource, }, - utils::SERIAL_COUNTER, wayland::seat::WaylandFocus, }; -use tracing::warn; -use crate::WlcsEvent; +use crate::{ + input_backend::{ + WlcsDevice, WlcsInputBackend, WlcsPointerButtonEvent, WlcsPointerMotionAbsoluteEvent, + WlcsPointerMotionEvent, WlcsTouchDownEvent, WlcsTouchUpEvent, + }, + WlcsEvent, +}; pub(crate) fn run(channel: Channel) { let config_path = @@ -95,88 +97,87 @@ fn handle_event(event: WlcsEvent, state: &mut State) { state.space.map_element(toplevel.clone(), location, false); } } - WlcsEvent::PointerMove { - device_id: _, - position, - absolute, - } => { - let serial = SERIAL_COUNTER.next_serial(); - let ptr = state.seat.get_pointer().unwrap(); - let ptr_location = ptr.current_location(); - let location = if absolute { position } else { ptr_location + position }; - - let under = state - .space - .element_under(location) - .and_then(|(w, _)| w.wl_surface()) - .map(|surf| (PointerFocusTarget::WlSurface(surf), location.to_i32_round())); - - let time = Duration::from(state.clock.now()).as_millis() as u32; - ptr.motion( - state, - under.clone(), - &MotionEvent { - location, - serial, - time, + WlcsEvent::NewPointer { device_id } => { + state.process_input_event(InputEvent::::DeviceAdded { + device: WlcsDevice { + device_id, + capability: DeviceCapability::Pointer, }, - ); - - if !absolute { - let utime = Duration::from(state.clock.now()).as_micros() as u64; - ptr.relative_motion( - state, - under, - &RelativeMotionEvent { - delta: position, - delta_unaccel: position, - utime, - }, - ) - } - ptr.frame(state); + }) } + WlcsEvent::PointerMoveAbsolute { + device_id, + position, + } => state.process_input_event( + WlcsPointerMotionAbsoluteEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + position, + } + .into(), + ), + WlcsEvent::PointerMoveRelative { device_id, delta } => state.process_input_event( + WlcsPointerMotionEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + delta, + } + .into(), + ), WlcsEvent::PointerButton { - device_id: _, + device_id, button_id, pressed, - } => { - let serial = SERIAL_COUNTER.next_serial(); - let ptr = state.seat.get_pointer().unwrap(); - if !ptr.is_grabbed() { - let ptr_location = ptr.current_location(); - let under = state - .space - .element_under(ptr_location) - .map(|(w, _)| w.clone()); - if let Some(win) = &under { - state.space.raise_element(win, true); - } - state.seat.get_keyboard().unwrap().set_focus( - state, - under.map(|w| KeyboardFocusTarget::Window(w)), - serial, - ); - } - let time = Duration::from(state.clock.now()).as_millis() as u32; - ptr.button( - state, - &ButtonEvent { - serial, - time, - button: button_id as u32, - state: if pressed { - ButtonState::Pressed - } else { - ButtonState::Released - }, + } => state.process_input_event( + WlcsPointerButtonEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + button_code: button_id as u32, + state: if pressed { + ButtonState::Pressed + } else { + ButtonState::Released }, - ); - ptr.frame(state); + } + .into(), + ), + WlcsEvent::NewTouch { device_id } => { + state.process_input_event(InputEvent::::DeviceAdded { + device: WlcsDevice { + device_id, + capability: DeviceCapability::Pointer, + }, + }) } - WlcsEvent::TouchDown { .. } => warn!("TouchDown"), - WlcsEvent::TouchMove { .. } => warn!("TouchMove"), - WlcsEvent::TouchUp { .. } => warn!("TouchUp"), + WlcsEvent::TouchDown { + device_id, + position, + } => state.process_input_event( + WlcsTouchDownEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + position, + } + .into(), + ), + WlcsEvent::TouchMove { + device_id, + position, + } => state.process_input_event( + WlcsTouchDownEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + position, + } + .into(), + ), + WlcsEvent::TouchUp { device_id } => state.process_input_event( + WlcsTouchUpEvent { + device_id, + time: Duration::from(state.clock.now()).as_millis() as u64, + } + .into(), + ), } } From c0fe55003bd6ebf654e8f19367138ee9c628522e Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Fri, 19 Apr 2024 18:32:05 +0200 Subject: [PATCH 06/12] Fix xwayland and cleanup --- src/backend/dummy.rs | 11 +--- src/backend/wlcs.rs | 86 +++++++++++++++++++++++++++- src/config.rs | 11 +--- wlcs_pinnacle/config/metaconfig.toml | 40 ------------- wlcs_pinnacle/config/src/main.rs | 26 +-------- wlcs_pinnacle/src/lib.rs | 18 ++++-- wlcs_pinnacle/src/main_loop.rs | 22 ++++--- 7 files changed, 116 insertions(+), 98 deletions(-) diff --git a/src/backend/dummy.rs b/src/backend/dummy.rs index d46ae37..704bbcc 100644 --- a/src/backend/dummy.rs +++ b/src/backend/dummy.rs @@ -31,15 +31,10 @@ pub struct Dummy { } impl Backend { - fn dummy_mut(&mut self) -> &mut Dummy { + fn dummy_mut(&mut self) -> &Dummy { let Backend::Dummy(dummy) = self else { unreachable!() }; dummy } - - #[cfg(feature = "wlcs")] - pub fn wlcs_mut(&mut self) -> &mut Wlcs { - &mut self.dummy_mut().wlcs_state - } } impl BackendData for Dummy { @@ -121,7 +116,7 @@ pub fn setup_dummy( state.space.map_output(&output, (0, 0)); - /* if let Err(err) = state.xwayland.start( + if let Err(err) = state.xwayland.start( state.loop_handle.clone(), None, std::iter::empty::<(OsString, OsString)>(), @@ -129,7 +124,7 @@ pub fn setup_dummy( |_| {}, ) { tracing::error!("Failed to start XWayland: {err}"); - } */ + } Ok((state, event_loop)) } diff --git a/src/backend/wlcs.rs b/src/backend/wlcs.rs index e290b03..c736c0b 100644 --- a/src/backend/wlcs.rs +++ b/src/backend/wlcs.rs @@ -1,9 +1,89 @@ -use std::{collections::HashMap, sync::{atomic::AtomicBool, Arc}}; +use std::{collections::HashMap, path::PathBuf}; -use smithay::reexports::wayland_server::Client; +use smithay::{ + backend::renderer::{test::DummyRenderer, ImportMemWl}, + output::{Output, Subpixel}, + reexports::{ + calloop::EventLoop, + wayland_server::{Client, Display}, + }, + utils::Transform, +}; + +use crate::state::State; + +use super::{dummy::Dummy, Backend}; #[derive(Default)] pub struct Wlcs { pub clients: HashMap, - pub running: Arc, +} + +impl Backend { + pub fn wlcs_mut(&mut self) -> &mut Wlcs { + let Backend::Dummy(dummy) = self else { unreachable!() }; + &mut dummy.wlcs_state + } +} + +pub fn setup_wlcs_dummy( + no_config: bool, + config_dir: Option, +) -> anyhow::Result<(State, EventLoop<'static, State>)> { + let event_loop: EventLoop = EventLoop::try_new()?; + + let display: Display = Display::new()?; + let display_handle = display.handle(); + + let loop_handle = event_loop.handle(); + + let mode = smithay::output::Mode { + size: (1920, 1080).into(), + refresh: 60_000, + }; + + let physical_properties = smithay::output::PhysicalProperties { + size: (0, 0).into(), + subpixel: Subpixel::Unknown, + make: "Pinnacle".to_string(), + model: "Dummy Window".to_string(), + }; + + let output = Output::new("Pinnacle Window".to_string(), physical_properties); + + output.create_global::(&display_handle); + + output.change_current_state( + Some(mode), + Some(Transform::Flipped180), + None, + Some((0, 0).into()), + ); + + output.set_preferred(mode); + + let renderer = DummyRenderer::new(); + let shm_formats = renderer.shm_formats(); + + let backend = Dummy { + renderer, + wlcs_state: Wlcs::default(), + }; + + let mut state = State::init( + super::Backend::Dummy(backend), + display, + event_loop.get_signal(), + loop_handle, + no_config, + config_dir, + )?; + + state.output_focus_stack.set_focus(output.clone()); + + state.shm_state.update_formats(shm_formats); + + state.space.map_output(&output, (0, 0)); + + Ok((state, event_loop)) } diff --git a/src/config.rs b/src/config.rs index 7a56042..918f15a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -564,17 +564,10 @@ impl State { } })); } - None => { - self.grpc_server_join_handle = Some(tokio::spawn(async move { - if let Err(err) = grpc_server.serve_with_incoming(uds_stream).await { - error!("gRPC server error: {err}"); - } - })); - } // FIXME: Not really high priority but if you somehow reload the config really, REALLY // | fast at startup then I think there's a chance that the gRPC server // | could get started twice. - /* None => self.schedule( + None => self.schedule( |state| state.xdisplay.is_some(), move |state| { state.grpc_server_join_handle = Some(tokio::spawn(async move { @@ -583,7 +576,7 @@ impl State { } })); }, - ), */ + ), } Ok(()) diff --git a/wlcs_pinnacle/config/metaconfig.toml b/wlcs_pinnacle/config/metaconfig.toml index 2afc257..4309020 100644 --- a/wlcs_pinnacle/config/metaconfig.toml +++ b/wlcs_pinnacle/config/metaconfig.toml @@ -1,46 +1,6 @@ -# This metaconfig.toml file dictates what config Pinnacle will run. -# -# When running Pinnacle, the compositor will look in the following directories for a metaconfig.toml file, -# in order from top to bottom: -# $PINNACLE_CONFIG_DIR -# $XDG_CONFIG_HOME/pinnacle/ -# ~/.config/pinnacle/ -# -# When Pinnacle finds a metaconfig.toml file, it will execute the command provided to `command`. -# To use a Rust config, this should be changed to something like ["cargo", "run"]. -# -# Because configuration is done using an external process, if it ever crashes, you lose all of your keybinds. -# The compositor will load the default config if that happens, but in the event that you don't have -# the necessary dependencies for it to run, you may get softlocked. -# In order prevent you from getting stuck in the compositor, you must define keybinds to reload your config -# and kill Pinnacle. -# -# More details on each setting can be found below. - -# The command Pinnacle will run on startup and when you reload your config. -# Paths are relative to the directory the metaconfig.toml file is in. -# This must be an array. command = ["./pinnacle-config"] -### Keybinds ### -# Each keybind takes in a table with two fields: `modifiers` and `key`. -# - `modifiers` can be one of "Ctrl", "Alt", "Shift", or "Super". -# - `key` can be a string of any lowercase letter, number, -# "numN" where N is a number for numpad keys, or "esc"/"escape". -# Support for any xkbcommon key is planned for a future update. - -# The keybind that will reload your config. reload_keybind = { modifiers = ["Ctrl", "Alt"], key = "r" } -# The keybind that will kill Pinnacle. kill_keybind = { modifiers = ["Ctrl", "Alt", "Shift"], key = "escape" } -### Socket directory ### -# Pinnacle will open a Unix socket at `$XDG_RUNTIME_DIR` by default, falling back to `/tmp` if it doesn't exist. -# If you want/need to change this, use the `socket_dir` setting set to the directory of your choosing. -# -# socket_dir = "/your/dir/here/" - -### Environment Variables ### -# If you need to spawn your config with any environment variables, list them here. [envs] -# key = "value" diff --git a/wlcs_pinnacle/config/src/main.rs b/wlcs_pinnacle/config/src/main.rs index 6e47f45..d7330f3 100644 --- a/wlcs_pinnacle/config/src/main.rs +++ b/wlcs_pinnacle/config/src/main.rs @@ -1,36 +1,12 @@ use pinnacle_api::layout::{CyclingLayoutManager, MasterStackLayout}; use pinnacle_api::ApiModules; -// Pinnacle needs to perform some setup before and after your config. -// The `#[pinnacle_api::config(modules)]` attribute does so and -// will bind all the config structs to the provided identifier. #[pinnacle_api::config(modules)] async fn main() { - // Deconstruct to get all the APIs. #[allow(unused_variables)] - let ApiModules { - pinnacle, - process, - window, - input, - output, - tag, - layout, - render, - } = modules; + let ApiModules { layout, .. } = modules; let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ Box::::default() as _, ])); - - // Setup all monitors with tags "1" through "5" - output.connect_for_all(move |op| { - let tags = tag.add(op, ["tag"]); - tags.first().unwrap().set_active(true); - }); - - // Enable sloppy focus - /* window.connect_signal(WindowSignal::PointerEnter(Box::new(|win| { - win.set_focused(true); - }))); */ } diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index 1e7e608..dde658e 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -202,22 +202,28 @@ impl Wlcs for PinnacleHandle { } fn create_pointer(&mut self) -> Option { + let device_id = new_device_id(); self.server_conn .as_ref() .map(|conn| conn.sender.clone()) - .map(|sender| PointerHandle { - device_id: new_device_id(), - sender, + .map(|sender| { + sender + .send(WlcsEvent::NewPointer { device_id }) + .expect("failed to send new_pointer"); + PointerHandle { device_id, sender } }) } fn create_touch(&mut self) -> Option { + let device_id = new_device_id(); self.server_conn .as_ref() .map(|conn| conn.sender.clone()) - .map(|sender| TouchHandle { - device_id: new_device_id(), - sender, + .map(|sender| { + sender + .send(WlcsEvent::NewTouch { device_id }) + .expect("failed to send new_touch"); + TouchHandle { device_id, sender } }) } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index e6a602e..f5b5480 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -1,14 +1,14 @@ use std::{sync::Arc, time::Duration}; use pinnacle::{ - backend::dummy::setup_dummy, + backend::wlcs::setup_wlcs_dummy, state::{ClientState, State}, }; use smithay::{ backend::input::{ButtonState, DeviceCapability, InputEvent}, reexports::{ calloop::channel::{Channel, Event}, - wayland_server::Resource, + wayland_server::{Client, Resource}, }, wayland::seat::WaylandFocus, }; @@ -26,7 +26,7 @@ pub(crate) fn run(channel: Channel) { &std::env::var("PINNACLE_WLCS_CONFIG_PATH").expect("PINNACLE_WLCS_CONFIG_PATH not set"); let (mut state, mut event_loop) = - setup_dummy(false, Some(config_path.into())).expect("failed to setup dummy backend"); + setup_wlcs_dummy(false, Some(config_path.into())).expect("failed to setup dummy backend"); event_loop .handle() @@ -40,19 +40,27 @@ pub(crate) fn run(channel: Channel) { let rt = tokio::runtime::Runtime::new().expect("failed to create tokio runtime"); let _handle = rt.enter(); + // FIXME: once starting pinnacle without xwayland is a thing, handle this + // | properly; in this case, we probably no longer need to start the + // | config manually anymore either, as this is only needed now, + // | because the config is started after xwayland reports its ready + + // when xdiplay is None when starting the config, the grpc server is not + // started, until it is set; this bypasses this for now + state.xdisplay = Some(u32::MAX); if let Err(err) = state.start_config(config_path) { panic!("failed to start config: {err}"); } - // FIXME: different sock_dir per instance? + // FIXME: use a custom socker_dir to avoid having to number sockets + + // wait for the config to connect to the layout service while state.layout_state.layout_request_sender.is_none() { event_loop .dispatch(Some(Duration::from_millis(10)), &mut state) .expect("event_loop error while waiting for config"); } - // TODO: handle no-xwayland properly - event_loop .run(None, &mut state, |state| { state.update_pointer_focus(); @@ -72,7 +80,7 @@ fn handle_event(event: WlcsEvent, state: &mut State) { match event { WlcsEvent::Stop => state.shutdown(), WlcsEvent::NewClient { stream, client_id } => { - let client: smithay::reexports::wayland_server::Client = state + let client: Client = state .display_handle .insert_client(stream, Arc::new(ClientState::default())) .expect("failed to insert new client"); From 0b353c45f26f707cbc34a39c91e9d65ba382fd2e Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Wed, 24 Apr 2024 19:02:15 +0200 Subject: [PATCH 07/12] Use an embedded config for tests --- Cargo.lock | 9 +- Cargo.toml | 1 - src/backend/wlcs.rs | 68 +- src/config.rs | 4 +- wlcs_pinnacle/Cargo.toml | 5 +- wlcs_pinnacle/config/Cargo.lock | 1315 -------------------------- wlcs_pinnacle/config/Cargo.toml | 7 - wlcs_pinnacle/config/metaconfig.toml | 6 - wlcs_pinnacle/config/pinnacle-config | 1 - wlcs_pinnacle/config/src/main.rs | 12 - wlcs_pinnacle/src/config.rs | 34 + wlcs_pinnacle/src/lib.rs | 1 + wlcs_pinnacle/src/main_loop.rs | 15 +- 13 files changed, 107 insertions(+), 1371 deletions(-) delete mode 100644 wlcs_pinnacle/config/Cargo.lock delete mode 100644 wlcs_pinnacle/config/Cargo.toml delete mode 100644 wlcs_pinnacle/config/metaconfig.toml delete mode 120000 wlcs_pinnacle/config/pinnacle-config delete mode 100644 wlcs_pinnacle/config/src/main.rs create mode 100644 wlcs_pinnacle/src/config.rs diff --git a/Cargo.lock b/Cargo.lock index cabd5b1..febcb59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3455,7 +3455,9 @@ name = "wlcs_pinnacle" version = "0.0.1" dependencies = [ "pinnacle", + "pinnacle-api", "smithay", + "tempfile", "tokio", "tracing", "tracing-subscriber", @@ -3463,13 +3465,6 @@ dependencies = [ "wlcs", ] -[[package]] -name = "wlcs_pinnacle_config" -version = "0.1.0" -dependencies = [ - "pinnacle-api", -] - [[package]] name = "x11-dl" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 5c74d85..40dae18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ members = [ "api/rust", "api/rust/pinnacle-api-macros", "wlcs_pinnacle", - "wlcs_pinnacle/config", ] [workspace.package] diff --git a/src/backend/wlcs.rs b/src/backend/wlcs.rs index c736c0b..286421c 100644 --- a/src/backend/wlcs.rs +++ b/src/backend/wlcs.rs @@ -1,16 +1,20 @@ -use std::{collections::HashMap, path::PathBuf}; +use std::{collections::HashMap, path::Path}; use smithay::{ backend::renderer::{test::DummyRenderer, ImportMemWl}, output::{Output, Subpixel}, reexports::{ - calloop::EventLoop, + calloop::{self, EventLoop}, wayland_server::{Client, Display}, }, utils::Transform, }; +use tracing::debug; -use crate::state::State; +use crate::{ + state::{State, WithState}, + tag::TagId, +}; use super::{dummy::Dummy, Backend}; @@ -26,10 +30,7 @@ impl Backend { } } -pub fn setup_wlcs_dummy( - no_config: bool, - config_dir: Option, -) -> anyhow::Result<(State, EventLoop<'static, State>)> { +pub fn setup_wlcs_dummy() -> anyhow::Result<(State, EventLoop<'static, State>)> { let event_loop: EventLoop = EventLoop::try_new()?; let display: Display = Display::new()?; @@ -75,8 +76,8 @@ pub fn setup_wlcs_dummy( display, event_loop.get_signal(), loop_handle, - no_config, - config_dir, + false, + None, )?; state.output_focus_stack.set_focus(output.clone()); @@ -87,3 +88,52 @@ pub fn setup_wlcs_dummy( Ok((state, event_loop)) } + +impl State { + pub fn start_wlcs_config( + &mut self, + socket_dir: &Path, + run_config: F, + ) -> anyhow::Result<()> + where + F: FnOnce() -> () + Send + 'static, + { + // Clear state + debug!("Clearing tags"); + for output in self.space.outputs() { + output.with_state_mut(|state| state.tags.clear()); + } + + TagId::reset(); + + debug!("Clearing input state"); + + self.input_state.clear(); + + self.config.clear(&self.loop_handle); + + self.signal_state.clear(); + + self.input_state.reload_keybind = None; + self.input_state.kill_keybind = None; + + if self.grpc_server_join_handle.is_none() { + self.start_grpc_server(socket_dir)?; + } + + let (pinger, ping_source) = calloop::ping::make_ping()?; + + let token = self + .loop_handle + .insert_source(ping_source, move |_, _, _state| {})?; + + std::thread::spawn(move || { + run_config(); + pinger.ping(); + }); + + self.config.config_reload_on_crash_token = Some(token); + + Ok(()) + } +} diff --git a/src/config.rs b/src/config.rs index 918f15a..87aab43 100644 --- a/src/config.rs +++ b/src/config.rs @@ -184,7 +184,7 @@ pub struct Config { pub connector_saved_states: HashMap, pub config_join_handle: Option>, - config_reload_on_crash_token: Option, + pub(crate) config_reload_on_crash_token: Option, pub shutdown_sender: Option>>, @@ -208,7 +208,7 @@ impl Config { .unwrap_or_else(|| get_config_dir(xdg_base_dirs)) } - fn clear(&mut self, loop_handle: &LoopHandle) { + pub(crate) fn clear(&mut self, loop_handle: &LoopHandle) { self.window_rules.clear(); self.connector_saved_states.clear(); if let Some(join_handle) = self.config_join_handle.take() { diff --git a/wlcs_pinnacle/Cargo.toml b/wlcs_pinnacle/Cargo.toml index aeddf74..00d4f73 100644 --- a/wlcs_pinnacle/Cargo.toml +++ b/wlcs_pinnacle/Cargo.toml @@ -12,10 +12,13 @@ crate-type = ["cdylib"] [dependencies] smithay = { workspace = true } pinnacle = { path = "..", features = [ "wlcs" ] } +pinnacle-api = { path = "../api/rust" } wayland-sys = { version = "0.31.1", features = ["client", "server"] } wlcs = "0.1" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } -tokio = { workspace = true, features = ["net", "rt"] } \ No newline at end of file +tokio = { workspace = true, features = ["net", "rt"] } + +tempfile = "3.10.1" \ No newline at end of file diff --git a/wlcs_pinnacle/config/Cargo.lock b/wlcs_pinnacle/config/Cargo.lock deleted file mode 100644 index a2fed59..0000000 --- a/wlcs_pinnacle/config/Cargo.lock +++ /dev/null @@ -1,1315 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" - -[[package]] -name = "async-stream" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-trait" -version = "0.1.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http", - "http-body", - "hyper", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - -[[package]] -name = "backtrace" -version = "0.3.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - -[[package]] -name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cc" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const_format" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "either" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "futures" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-executor" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "getrandom" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 2.2.6", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "0.14.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-timeout" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" -dependencies = [ - "hyper", - "pin-project-lite", - "tokio", - "tokio-io-timeout", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown 0.14.3", -] - -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "matchit" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "memmap2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" -dependencies = [ - "libc", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "multimap" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap 2.2.6", -] - -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pinnacle-api" -version = "0.0.2" -source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" -dependencies = [ - "futures", - "num_enum", - "pinnacle-api-defs", - "pinnacle-api-macros", - "rand", - "tokio", - "tokio-stream", - "tonic", - "tower", - "xkbcommon", -] - -[[package]] -name = "pinnacle-api-defs" -version = "0.0.1" -source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" -dependencies = [ - "const_format", - "prost", - "tonic", - "tonic-build", -] - -[[package]] -name = "pinnacle-api-macros" -version = "0.0.2" -source = "git+http://github.com/pinnacle-comp/pinnacle#220be6d505662aeddb891a67b2c595df8ff574d8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pinnacle-config" -version = "0.1.0" -dependencies = [ - "pinnacle-api", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "prettyplease" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] -name = "proc-macro-crate" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" -dependencies = [ - "bytes", - "heck", - "itertools", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" -dependencies = [ - "prost", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustix" -version = "0.38.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustversion" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "socket2" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "syn" -version = "2.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "tokio" -version = "1.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "pin-project-lite", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-stream" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tonic" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64", - "bytes", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic-build" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build", - "quote", - "syn", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "indexmap 1.9.3", - "pin-project", - "pin-project-lite", - "rand", - "slab", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.4", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" -dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" - -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - -[[package]] -name = "xkbcommon" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13867d259930edc7091a6c41b4ce6eee464328c6ff9659b7e4c668ca20d4c91e" -dependencies = [ - "libc", - "memmap2", - "xkeysym", -] - -[[package]] -name = "xkeysym" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" diff --git a/wlcs_pinnacle/config/Cargo.toml b/wlcs_pinnacle/config/Cargo.toml deleted file mode 100644 index ed668e2..0000000 --- a/wlcs_pinnacle/config/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "wlcs_pinnacle_config" -version = "0.1.0" -edition = "2021" - -[dependencies] -pinnacle-api = { path = "../../api/rust" } diff --git a/wlcs_pinnacle/config/metaconfig.toml b/wlcs_pinnacle/config/metaconfig.toml deleted file mode 100644 index 4309020..0000000 --- a/wlcs_pinnacle/config/metaconfig.toml +++ /dev/null @@ -1,6 +0,0 @@ -command = ["./pinnacle-config"] - -reload_keybind = { modifiers = ["Ctrl", "Alt"], key = "r" } -kill_keybind = { modifiers = ["Ctrl", "Alt", "Shift"], key = "escape" } - -[envs] diff --git a/wlcs_pinnacle/config/pinnacle-config b/wlcs_pinnacle/config/pinnacle-config deleted file mode 120000 index a1bddd4..0000000 --- a/wlcs_pinnacle/config/pinnacle-config +++ /dev/null @@ -1 +0,0 @@ -../../target/debug/pinnacle-config \ No newline at end of file diff --git a/wlcs_pinnacle/config/src/main.rs b/wlcs_pinnacle/config/src/main.rs deleted file mode 100644 index d7330f3..0000000 --- a/wlcs_pinnacle/config/src/main.rs +++ /dev/null @@ -1,12 +0,0 @@ -use pinnacle_api::layout::{CyclingLayoutManager, MasterStackLayout}; -use pinnacle_api::ApiModules; - -#[pinnacle_api::config(modules)] -async fn main() { - #[allow(unused_variables)] - let ApiModules { layout, .. } = modules; - - let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ - Box::::default() as _, - ])); -} diff --git a/wlcs_pinnacle/src/config.rs b/wlcs_pinnacle/src/config.rs new file mode 100644 index 0000000..2fd4466 --- /dev/null +++ b/wlcs_pinnacle/src/config.rs @@ -0,0 +1,34 @@ +use pinnacle::state::State; + +mod inner { + use pinnacle_api::layout::{CyclingLayoutManager, MasterStackLayout}; + use pinnacle_api::ApiModules; + + #[pinnacle_api::config(modules)] + async fn main() { + #[allow(unused_variables)] + let ApiModules { layout, .. } = modules; + + let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ + Box::::default() as _, + ])); + } + + pub(crate) fn start_config() { + main() + } +} + +pub fn run_config(state: &mut State) { + let temp_dir = tempfile::tempdir().expect("failed to setup temp dir for socket"); + let socket_dir = temp_dir.path().to_owned(); + state + .start_wlcs_config( + &socket_dir, + move || { + inner::start_config(); + drop(temp_dir); + }, + ) + .expect("failed to start wlcs config"); +} diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index dde658e..73d105e 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -1,5 +1,6 @@ mod input_backend; mod main_loop; +pub(crate) mod config; use std::{ io, diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index f5b5480..8477dc9 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -14,19 +14,15 @@ use smithay::{ }; use crate::{ - input_backend::{ + config::run_config, input_backend::{ WlcsDevice, WlcsInputBackend, WlcsPointerButtonEvent, WlcsPointerMotionAbsoluteEvent, WlcsPointerMotionEvent, WlcsTouchDownEvent, WlcsTouchUpEvent, - }, - WlcsEvent, + }, WlcsEvent }; pub(crate) fn run(channel: Channel) { - let config_path = - &std::env::var("PINNACLE_WLCS_CONFIG_PATH").expect("PINNACLE_WLCS_CONFIG_PATH not set"); - let (mut state, mut event_loop) = - setup_wlcs_dummy(false, Some(config_path.into())).expect("failed to setup dummy backend"); + setup_wlcs_dummy().expect("failed to setup dummy backend"); event_loop .handle() @@ -48,9 +44,7 @@ pub(crate) fn run(channel: Channel) { // when xdiplay is None when starting the config, the grpc server is not // started, until it is set; this bypasses this for now state.xdisplay = Some(u32::MAX); - if let Err(err) = state.start_config(config_path) { - panic!("failed to start config: {err}"); - } + run_config(&mut state); // FIXME: use a custom socker_dir to avoid having to number sockets @@ -91,6 +85,7 @@ fn handle_event(event: WlcsEvent, state: &mut State) { surface_id, location, } => { + // TODO: handle this in a Pinnacle-applicable way (LayoutManager?) let client = state.backend.wlcs_mut().clients.get(&client_id); let toplevel = state.space.elements().find(|w| { if let Some(surface) = w.wl_surface() { From 194da9e5577b3983ffa8ecc5935f896aba1a48d9 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Wed, 24 Apr 2024 21:57:00 +0200 Subject: [PATCH 08/12] Float all windows for tests and improve window positioning --- src/backend/wlcs.rs | 6 +--- wlcs_pinnacle/src/config.rs | 27 ++++++++------- wlcs_pinnacle/src/lib.rs | 27 +++++++++++---- wlcs_pinnacle/src/main_loop.rs | 60 ++++++++++++++++++++++++---------- 4 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/backend/wlcs.rs b/src/backend/wlcs.rs index 286421c..20dff16 100644 --- a/src/backend/wlcs.rs +++ b/src/backend/wlcs.rs @@ -90,11 +90,7 @@ pub fn setup_wlcs_dummy() -> anyhow::Result<(State, EventLoop<'static, State>)> } impl State { - pub fn start_wlcs_config( - &mut self, - socket_dir: &Path, - run_config: F, - ) -> anyhow::Result<()> + pub fn start_wlcs_config(&mut self, socket_dir: &Path, run_config: F) -> anyhow::Result<()> where F: FnOnce() -> () + Send + 'static, { diff --git a/wlcs_pinnacle/src/config.rs b/wlcs_pinnacle/src/config.rs index 2fd4466..44df232 100644 --- a/wlcs_pinnacle/src/config.rs +++ b/wlcs_pinnacle/src/config.rs @@ -1,17 +1,23 @@ use pinnacle::state::State; - mod inner { use pinnacle_api::layout::{CyclingLayoutManager, MasterStackLayout}; + use pinnacle_api::window::rules::{WindowRule, WindowRuleCondition}; use pinnacle_api::ApiModules; #[pinnacle_api::config(modules)] async fn main() { #[allow(unused_variables)] - let ApiModules { layout, .. } = modules; + let ApiModules { layout, window, .. } = modules; - let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ - Box::::default() as _, - ])); + window.add_window_rule( + WindowRuleCondition::default().all(vec![]), + WindowRule::new().floating(true), + ); + + let _layout_requester = + layout.set_manager(CyclingLayoutManager::new([ + Box::new(MasterStackLayout::default()) as _, + ])); } pub(crate) fn start_config() { @@ -23,12 +29,9 @@ pub fn run_config(state: &mut State) { let temp_dir = tempfile::tempdir().expect("failed to setup temp dir for socket"); let socket_dir = temp_dir.path().to_owned(); state - .start_wlcs_config( - &socket_dir, - move || { - inner::start_config(); - drop(temp_dir); - }, - ) + .start_wlcs_config(&socket_dir, move || { + inner::start_config(); + drop(temp_dir); + }) .expect("failed to start wlcs config"); } diff --git a/wlcs_pinnacle/src/lib.rs b/wlcs_pinnacle/src/lib.rs index 73d105e..e509238 100644 --- a/wlcs_pinnacle/src/lib.rs +++ b/wlcs_pinnacle/src/lib.rs @@ -1,6 +1,6 @@ +pub(crate) mod config; mod input_backend; mod main_loop; -pub(crate) mod config; use std::{ io, @@ -111,6 +111,19 @@ static SUPPORTED_EXTENSIONS: &[WlcsExtensionDescriptor] = extension_list!( // 12 Missing extension: zwp_text_input_manager_v2>= 1 // 11 Missing extension: zwp_text_input_manager_v3>= 1 // 180 Missing extension: zxdg_shell_v6>= 1 + + // mostly from https://github.com/Smithay/smithay/issues/781 + ("wl_compositor", 6), + ("wl_subcompositor", 1), + ("wl_shm", 1), + ("wl_data_device_manager", 3), + ("wl_seat", 9), + ("wl_output", 4), + ("wp_presentation", 1), + ("wp_viewporter", 1), + ("xdg_shell", 6), + ("linux-dmabuf-v1", 5), + ("xdg_shell", 6), ); static DESCRIPTOR: WlcsIntegrationDescriptor = WlcsIntegrationDescriptor { @@ -194,11 +207,13 @@ impl Wlcs for PinnacleHandle { unsafe { ffi_dispatch!(wayland_client_handle(), wl_display_get_fd, display) }; let surface_id = unsafe { ffi_dispatch!(wayland_client_handle(), wl_proxy_get_id, surface) }; - let _ = conn.sender.send(WlcsEvent::PositionWindow { - client_id, - surface_id, - location: (x, y).into(), - }); + conn.sender + .send(WlcsEvent::PositionWindow { + client_id, + surface_id, + location: (x, y).into(), + }) + .expect("failed to send position_window_absolute"); } } diff --git a/wlcs_pinnacle/src/main_loop.rs b/wlcs_pinnacle/src/main_loop.rs index 8477dc9..f789bbc 100644 --- a/wlcs_pinnacle/src/main_loop.rs +++ b/wlcs_pinnacle/src/main_loop.rs @@ -2,7 +2,8 @@ use std::{sync::Arc, time::Duration}; use pinnacle::{ backend::wlcs::setup_wlcs_dummy, - state::{ClientState, State}, + state::{ClientState, State, WithState}, + window::window_state::FloatingOrTiled, }; use smithay::{ backend::input::{ButtonState, DeviceCapability, InputEvent}, @@ -10,19 +11,21 @@ use smithay::{ calloop::channel::{Channel, Event}, wayland_server::{Client, Resource}, }, + utils::Rectangle, wayland::seat::WaylandFocus, }; use crate::{ - config::run_config, input_backend::{ + config::run_config, + input_backend::{ WlcsDevice, WlcsInputBackend, WlcsPointerButtonEvent, WlcsPointerMotionAbsoluteEvent, WlcsPointerMotionEvent, WlcsTouchDownEvent, WlcsTouchUpEvent, - }, WlcsEvent + }, + WlcsEvent, }; pub(crate) fn run(channel: Channel) { - let (mut state, mut event_loop) = - setup_wlcs_dummy().expect("failed to setup dummy backend"); + let (mut state, mut event_loop) = setup_wlcs_dummy().expect("failed to setup dummy backend"); event_loop .handle() @@ -46,8 +49,6 @@ pub(crate) fn run(channel: Channel) { state.xdisplay = Some(u32::MAX); run_config(&mut state); - // FIXME: use a custom socker_dir to avoid having to number sockets - // wait for the config to connect to the layout service while state.layout_state.layout_request_sender.is_none() { event_loop @@ -71,6 +72,7 @@ pub(crate) fn run(channel: Channel) { } fn handle_event(event: WlcsEvent, state: &mut State) { + tracing::debug!("handle_event {:?}", event); match event { WlcsEvent::Stop => state.shutdown(), WlcsEvent::NewClient { stream, client_id } => { @@ -85,19 +87,41 @@ fn handle_event(event: WlcsEvent, state: &mut State) { surface_id, location, } => { - // TODO: handle this in a Pinnacle-applicable way (LayoutManager?) let client = state.backend.wlcs_mut().clients.get(&client_id); - let toplevel = state.space.elements().find(|w| { - if let Some(surface) = w.wl_surface() { - state.display_handle.get_client(surface.id()).ok().as_ref() == client - && surface.id().protocol_id() == surface_id - } else { - false - } - }); + let window = state + .space + .elements() + .find(|w| { + if let Some(surface) = w.wl_surface() { + state.display_handle.get_client(surface.id()).ok().as_ref() == client + && surface.id().protocol_id() == surface_id + } else { + false + } + }) + .cloned(); - if let Some(toplevel) = toplevel { - state.space.map_element(toplevel.clone(), location, false); + if let Some(window) = window { + state.space.map_element(window.clone(), location, false); + + let size = state + .space + .element_geometry(&window) + .expect("window to be positioned was not mapped") + .size; + + if window.with_state(|state| state.floating_or_tiled.is_tiled()) { + window.toggle_floating(); + } + + window.with_state_mut(|state| { + state.floating_or_tiled = + FloatingOrTiled::Floating(Rectangle::from_loc_and_size(location, size)); + }); + + for output in state.space.outputs_for_element(&window) { + state.schedule_render(&output); + } } } From 13df2d161bf35d5d650b08325897c008c8ae4b86 Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Thu, 25 Apr 2024 10:41:03 +0200 Subject: [PATCH 09/12] Fix lua tests hanging --- src/backend/wlcs.rs | 2 +- tests/lua_api.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/wlcs.rs b/src/backend/wlcs.rs index 20dff16..6c7f560 100644 --- a/src/backend/wlcs.rs +++ b/src/backend/wlcs.rs @@ -92,7 +92,7 @@ pub fn setup_wlcs_dummy() -> anyhow::Result<(State, EventLoop<'static, State>)> impl State { pub fn start_wlcs_config(&mut self, socket_dir: &Path, run_config: F) -> anyhow::Result<()> where - F: FnOnce() -> () + Send + 'static, + F: FnOnce() + Send + 'static, { // Clear state debug!("Clearing tags"); diff --git a/tests/lua_api.rs b/tests/lua_api.rs index 6b0f62b..0a3afc3 100644 --- a/tests/lua_api.rs +++ b/tests/lua_api.rs @@ -483,7 +483,7 @@ mod output { local props = Pinnacle.output.get_focused():props() assert(props.make == "Pinnacle") - assert(props.model == "Winit Window") + assert(props.model == "Dummy Window") assert(props.x == 0) assert(props.y == 0) assert(props.logical_width == 1920) From 29e7d7bd5fcfa78ea337712e9e20c5d07b8d1e7b Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Thu, 25 Apr 2024 11:14:31 +0200 Subject: [PATCH 10/12] Make clippy happy --- wlcs_pinnacle/src/config.rs | 7 +++--- wlcs_pinnacle/src/input_backend.rs | 40 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/wlcs_pinnacle/src/config.rs b/wlcs_pinnacle/src/config.rs index 44df232..fa5334c 100644 --- a/wlcs_pinnacle/src/config.rs +++ b/wlcs_pinnacle/src/config.rs @@ -14,10 +14,9 @@ mod inner { WindowRule::new().floating(true), ); - let _layout_requester = - layout.set_manager(CyclingLayoutManager::new([ - Box::new(MasterStackLayout::default()) as _, - ])); + let _layout_requester = layout.set_manager(CyclingLayoutManager::new([ + Box::::default() as _, + ])); } pub(crate) fn start_config() { diff --git a/wlcs_pinnacle/src/input_backend.rs b/wlcs_pinnacle/src/input_backend.rs index cf916a9..6c632aa 100644 --- a/wlcs_pinnacle/src/input_backend.rs +++ b/wlcs_pinnacle/src/input_backend.rs @@ -53,11 +53,11 @@ impl Hash for WlcsDevice { impl Device for WlcsDevice { fn id(&self) -> String { - format!("{}", self.device_id).into() + format!("{}", self.device_id) } fn name(&self) -> String { - format!("wlcs-device-{}", self.device_id).into() + format!("wlcs-device-{}", self.device_id) } fn has_capability(&self, capability: DeviceCapability) -> bool { @@ -80,9 +80,9 @@ pub struct WlcsPointerButtonEvent { pub state: ButtonState, } -impl Into> for WlcsPointerButtonEvent { - fn into(self) -> InputEvent { - InputEvent::::PointerButton { event: self } +impl From for InputEvent { + fn from(event: WlcsPointerButtonEvent) -> Self { + InputEvent::::PointerButton { event } } } @@ -115,9 +115,9 @@ pub struct WlcsPointerMotionEvent { pub delta: Point, } -impl Into> for WlcsPointerMotionEvent { - fn into(self) -> InputEvent { - InputEvent::::PointerMotion { event: self } +impl From for InputEvent { + fn from(event: WlcsPointerMotionEvent) -> Self { + InputEvent::::PointerMotion { event } } } @@ -158,9 +158,9 @@ pub struct WlcsPointerMotionAbsoluteEvent { pub position: Point, } -impl Into> for WlcsPointerMotionAbsoluteEvent { - fn into(self) -> InputEvent { - InputEvent::::PointerMotionAbsolute { event: self } +impl From for InputEvent { + fn from(event: WlcsPointerMotionAbsoluteEvent) -> Self { + InputEvent::::PointerMotionAbsolute { event } } } @@ -203,9 +203,9 @@ pub struct WlcsTouchDownEvent { pub position: Point, } -impl Into> for WlcsTouchDownEvent { - fn into(self) -> InputEvent { - InputEvent::::TouchDown { event: self } +impl From for InputEvent { + fn from(event: WlcsTouchDownEvent) -> Self { + InputEvent::::TouchDown { event } } } @@ -253,9 +253,9 @@ pub struct WlcsTouchUpEvent { pub time: u64, } -impl Into> for WlcsTouchUpEvent { - fn into(self) -> InputEvent { - InputEvent::::TouchUp { event: self } +impl From for InputEvent { + fn from(event: WlcsTouchUpEvent) -> Self { + InputEvent::::TouchUp { event } } } @@ -286,9 +286,9 @@ pub struct WlcsTouchMotionEvent { pub position: Point, } -impl Into> for WlcsTouchMotionEvent { - fn into(self) -> InputEvent { - InputEvent::::TouchMotion { event: self } +impl From for InputEvent { + fn from(event: WlcsTouchMotionEvent) -> Self { + InputEvent::::TouchMotion { event } } } From bdcac3b01654cda7dfda3fd46c78b7dc578b001d Mon Sep 17 00:00:00 2001 From: Leon Vack Date: Fri, 26 Apr 2024 10:21:43 +0200 Subject: [PATCH 11/12] Cleanup up dependencies --- Cargo.toml | 10 +++++++--- flake.nix | 5 ----- wlcs_pinnacle/Cargo.toml | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40dae18..89c21ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,9 @@ prost = "0.12.4" tonic = "0.11.0" tonic-reflection = "0.11.0" tonic-build = "0.11.0" +# Tracing +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } # API definitions pinnacle-api-defs = { path = "./pinnacle-api-defs" } # Misc. @@ -28,6 +31,7 @@ xdg = "2.5.2" bitflags = "2.5.0" clap = { version = "4.5.4", features = ["derive"] } dircpy = "0.3.16" +tempfile = "3.10.1" ########################################################################yo😎########### @@ -47,8 +51,8 @@ keywords = ["wayland", "compositor", "smithay", "lua"] # smithay is down there somewhere smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "c293ec7" } # Tracing -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } tracing-appender = "0.2.3" # Errors anyhow = { version = "1.0.81", features = ["backtrace"] } @@ -116,7 +120,7 @@ xdg = { workspace = true } [dev-dependencies] temp-env = "0.3.6" -tempfile = "3.10.1" +tempfile = { workspace = true } test-log = { version = "0.2.15", default-features = false, features = ["trace"] } pinnacle = { path = ".", features = ["wlcs"] } pinnacle-api = { path = "./api/rust" } diff --git a/flake.nix b/flake.nix index 081803d..06052eb 100644 --- a/flake.nix +++ b/flake.nix @@ -37,11 +37,6 @@ ${wlcs}/libexec/wlcs/wlcs "$@" '') - # build time stuff - pkg-config - protobuf - luarocks - wayland # build time stuff diff --git a/wlcs_pinnacle/Cargo.toml b/wlcs_pinnacle/Cargo.toml index 00d4f73..44d1170 100644 --- a/wlcs_pinnacle/Cargo.toml +++ b/wlcs_pinnacle/Cargo.toml @@ -16,9 +16,9 @@ pinnacle-api = { path = "../api/rust" } wayland-sys = { version = "0.31.1", features = ["client", "server"] } wlcs = "0.1" -tracing = "0.1.40" -tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } tokio = { workspace = true, features = ["net", "rt"] } -tempfile = "3.10.1" \ No newline at end of file +tempfile = { workspace = true } \ No newline at end of file From 612b1ccda0c79d39b94ad7ca2a4075c4bdfae454 Mon Sep 17 00:00:00 2001 From: Ottatop Date: Fri, 26 Apr 2024 13:03:17 -0500 Subject: [PATCH 12/12] Add wlcs compilation script --- .gitignore | 4 ++++ compile_wlcs.sh | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 compile_wlcs.sh diff --git a/.gitignore b/.gitignore index 815b989..9a64ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,9 @@ target/ # MSVC Windows builds of rustc generate these, which store debugging information *.pdb +# Don't push local doc builds api/lua/doc/doc +# This is a library api/rust/Cargo.lock +# Don't push compiled WLCS +wlcs diff --git a/compile_wlcs.sh b/compile_wlcs.sh new file mode 100755 index 0000000..be9c814 --- /dev/null +++ b/compile_wlcs.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +WLCS_SHA=26c5a8cfef265b4ae021adebfec90d758c08792e + +if [ -f "./wlcs/wlcs" ] && [ "$(cd wlcs; git rev-parse HEAD)" = "${WLCS_SHA}" ] ; then + echo "WLCS commit 26c5a8c is already compiled" +else + echo "Compiling WLCS" + git clone https://github.com/canonical/wlcs + cd wlcs || exit + # checkout a specific revision + git reset --hard "${WLCS_SHA}" + cmake -DWLCS_BUILD_ASAN=False -DWLCS_BUILD_TSAN=False -DWLCS_BUILD_UBSAN=False -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . + make +fi