From ea913e898c5e34f7f116f21961879548ca0ad433 Mon Sep 17 00:00:00 2001 From: Ottatop Date: Wed, 20 Sep 2023 15:27:51 -0500 Subject: [PATCH] Move api stuff into single mod --- src/backend/udev.rs | 4 ++-- src/{metaconfig.rs => config.rs} | 4 +++- src/{ => config}/api.rs | 0 src/{ => config}/api/msg.rs | 0 src/{ => config}/api/msg/window_rules.rs | 0 src/input.rs | 6 +++--- src/main.rs | 3 +-- src/state.rs | 12 ++++++------ src/state/api_handlers.rs | 22 +++++++++++----------- src/window.rs | 2 +- 10 files changed, 27 insertions(+), 26 deletions(-) rename src/{metaconfig.rs => config.rs} (98%) rename src/{ => config}/api.rs (100%) rename src/{ => config}/api/msg.rs (100%) rename src/{ => config}/api/msg/window_rules.rs (100%) diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 99bb8a6..7f4a06c 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -84,7 +84,7 @@ use smithay_drm_extras::{ }; use crate::{ - api::msg::{Args, OutgoingMsg}, + config::api::msg::{Args, OutgoingMsg}, render::{pointer::PointerElement, CustomRenderElements}, state::{ take_presentation_feedback, Backend, CalloopData, State, SurfaceDmabufFeedback, WithState, @@ -952,7 +952,7 @@ impl State { .expect("Stream doesn't exist"); let mut stream = stream.lock().expect("Couldn't lock stream"); for callback_id in dt.state.output_callback_ids.iter() { - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id: *callback_id, diff --git a/src/metaconfig.rs b/src/config.rs similarity index 98% rename from src/metaconfig.rs rename to src/config.rs index 0e698a4..c3d727a 100644 --- a/src/metaconfig.rs +++ b/src/config.rs @@ -1,10 +1,12 @@ +pub mod api; + use std::path::Path; use anyhow::Context; use smithay::input::keyboard::keysyms; use toml::Table; -use crate::api::msg::Modifier; +use api::msg::Modifier; #[derive(serde::Deserialize, Debug)] pub struct Metaconfig { diff --git a/src/api.rs b/src/config/api.rs similarity index 100% rename from src/api.rs rename to src/config/api.rs diff --git a/src/api/msg.rs b/src/config/api/msg.rs similarity index 100% rename from src/api/msg.rs rename to src/config/api/msg.rs diff --git a/src/api/msg/window_rules.rs b/src/config/api/msg/window_rules.rs similarity index 100% rename from src/api/msg/window_rules.rs rename to src/config/api/msg/window_rules.rs diff --git a/src/input.rs b/src/input.rs index e3f66a6..635c674 100644 --- a/src/input.rs +++ b/src/input.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ - api::msg::{CallbackId, Modifier, ModifierMask, MouseEdge, OutgoingMsg}, + config::api::msg::{CallbackId, Modifier, ModifierMask, MouseEdge, OutgoingMsg}, focus::FocusTarget, state::{Backend, WithState}, window::WindowElement, @@ -235,7 +235,7 @@ impl State { match action { Some(KeyAction::CallCallback(callback_id)) => { if let Some(stream) = self.api_state.stream.as_ref() { - if let Err(err) = crate::api::send_to_client( + if let Err(err) = crate::config::api::send_to_client( &mut stream.lock().expect("Could not lock stream mutex"), &OutgoingMsg::CallCallback { callback_id, @@ -289,7 +289,7 @@ impl State { { if let Some(stream) = self.api_state.stream.clone() { let mut stream = stream.lock().expect("failed to lock api stream"); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id, diff --git a/src/main.rs b/src/main.rs index bb666b5..8734827 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,15 +16,14 @@ use tracing_appender::rolling::Rotation; use tracing_subscriber::{fmt::writer::MakeWriterExt, EnvFilter}; use xdg::BaseDirectories; -mod api; mod backend; +mod config; mod cursor; mod focus; mod grab; mod handlers; mod input; mod layout; -mod metaconfig; mod output; mod pointer; mod render; diff --git a/src/state.rs b/src/state.rs index 9783316..ff2a622 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,18 +11,18 @@ use std::{ }; use crate::{ - api::{ + backend::{udev::Udev, winit::Winit, BackendData}, + config::api::{ msg::{ window_rules::{WindowRule, WindowRuleCondition}, CallbackId, ModifierMask, Msg, }, PinnacleSocketSource, }, - backend::{udev::Udev, winit::Winit, BackendData}, + config::Metaconfig, cursor::Cursor, focus::FocusState, grab::resize_grab::ResizeSurfaceState, - metaconfig::Metaconfig, tag::TagId, window::WindowElement, }; @@ -206,7 +206,7 @@ impl State { let config_dir = get_config_dir(); tracing::debug!("config dir is {:?}", config_dir); - let metaconfig = crate::metaconfig::parse(&config_dir)?; + let metaconfig = crate::config::parse(&config_dir)?; // If a socket is provided in the metaconfig, use it. let socket_dir = if let Some(socket_dir) = &metaconfig.socket_dir { @@ -223,7 +223,7 @@ impl State { crate::XDG_BASE_DIRS .get_runtime_directory() .cloned() - .unwrap_or(PathBuf::from(crate::api::DEFAULT_SOCKET_DIR)) + .unwrap_or(PathBuf::from(crate::config::api::DEFAULT_SOCKET_DIR)) }; let socket_source = PinnacleSocketSource::new(tx_channel, &socket_dir) @@ -497,7 +497,7 @@ impl State { let config_dir = get_config_dir(); let metaconfig = - crate::metaconfig::parse(&config_dir).context("Failed to parse metaconfig.toml")?; + crate::config::parse(&config_dir).context("Failed to parse metaconfig.toml")?; let ConfigReturn { reload_keybind, diff --git a/src/state/api_handlers.rs b/src/state/api_handlers.rs index 2443494..b8840b6 100644 --- a/src/state/api_handlers.rs +++ b/src/state/api_handlers.rs @@ -10,7 +10,7 @@ use smithay::{ }; use crate::{ - api::msg::{ + config::api::msg::{ Args, CallbackId, KeyIntOrString, Msg, OutgoingMsg, Request, RequestId, RequestResponse, }, focus::FocusTarget, @@ -313,7 +313,7 @@ impl State { .expect("stream doesn't exist"); let mut stream = stream.lock().expect("couldn't lock stream"); for output in self.space.outputs() { - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id, @@ -372,7 +372,7 @@ impl State { .collect::>(); // FIXME: figure out what to do if error - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -418,7 +418,7 @@ impl State { let fullscreen_or_maximized = window .as_ref() .map(|win| win.with_state(|state| state.fullscreen_or_maximized)); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -441,7 +441,7 @@ impl State { .outputs() .map(|output| output.name()) .collect::>(); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -486,7 +486,7 @@ impl State { state.tags.iter().map(|tag| tag.id()).collect::>() }) }); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -512,7 +512,7 @@ impl State { .map(|tag| tag.id()) .collect::>(); tracing::debug!("GetTags: {:?}", tag_ids); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -529,7 +529,7 @@ impl State { .map(|output| output.name()); let active = tag.as_ref().map(|tag| tag.active()); let name = tag.as_ref().map(|tag| tag.name()); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::RequestResponse { request_id, @@ -609,7 +609,7 @@ impl State { Ok(0) => break, Ok(_) => { let mut stream = stream_out.lock().expect("Couldn't lock stream"); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id, @@ -645,7 +645,7 @@ impl State { Ok(0) => break, Ok(_) => { let mut stream = stream_err.lock().expect("Couldn't lock stream"); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id, @@ -675,7 +675,7 @@ impl State { match child.status().await { Ok(exit_status) => { let mut stream = stream_exit.lock().expect("Couldn't lock stream"); - crate::api::send_to_client( + crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { callback_id, diff --git a/src/window.rs b/src/window.rs index 2be940c..30fd3ae 100644 --- a/src/window.rs +++ b/src/window.rs @@ -34,7 +34,7 @@ use smithay::{ }; use crate::{ - api::msg::window_rules::{self, WindowRule}, + config::api::msg::window_rules::{self, WindowRule}, state::{State, WithState}, };