Move stuff to where they should be

This commit is contained in:
Ottatop 2023-10-19 20:19:00 -05:00
parent 87574a40e3
commit 9da918bc40
6 changed files with 105 additions and 68 deletions

View file

@ -1,7 +1,7 @@
use xkbcommon::xkb::Keysym;
use crate::{
msg::{Args, CallbackId, KeyIntOrString, Modifier, MouseEdge, Msg},
msg::{Args, CallbackId, KeyIntOrString, Msg},
send_msg, CALLBACK_VEC,
};
@ -69,17 +69,34 @@ impl Input {
}
}
/// A mouse button.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MouseButton {
/// The left mouse button.
Left = 0x110,
/// The right mouse button.
Right,
/// The middle mouse button, pressed usually by clicking the scroll wheel.
Middle,
///
Side,
///
Extra,
///
Forward,
///
Back,
}
/// The edge on which you want things to trigger.
#[derive(Debug, Hash, serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum MouseEdge {
/// Actions will be triggered on button press.
Press,
/// Actions will be triggered on button release.
Release,
}
impl From<char> for KeyIntOrString {
fn from(value: char) -> Self {
Self::String(value.to_string())
@ -97,3 +114,18 @@ impl From<Keysym> for KeyIntOrString {
Self::Int(value.raw())
}
}
/// A modifier key.
#[derive(Debug, PartialEq, Eq, Copy, Clone, serde::Serialize, serde::Deserialize)]
pub enum Modifier {
/// The shift key.
Shift,
/// The control key.
Ctrl,
/// The alt key.
Alt,
/// The super key.
///
/// This is also known as the Windows key, meta, or Mod4 for those coming from Xorg.
Super,
}

View file

@ -1,3 +1,7 @@
#![warn(missing_docs)]
//! The Rust implementation of the Pinnacle API.
mod input;
mod msg;
mod output;
@ -6,9 +10,9 @@ mod tag;
mod window;
use input::Input;
pub use input::Modifier;
pub use input::MouseButton;
pub use msg::Modifier;
pub use msg::MouseEdge;
pub use input::MouseEdge;
use output::Output;
use tag::Tag;
use window::Window;
@ -172,10 +176,18 @@ fn request(request: Request) -> RequestResponse {
response
}
/// The entry to configuration.
///
/// This struct houses every submodule you'll need to configure Pinnacle.
pub struct Pinnacle {
/// Process management.
pub process: Process,
/// Window management.
pub window: Window,
/// Input management.
pub input: Input,
/// Output management.
pub output: Output,
/// Tag management.
pub tag: Tag,
}

View file

@ -1,48 +1,15 @@
use std::num::NonZeroU32;
use crate::{
output::OutputName,
tag::{Layout, TagId},
window::{FloatingOrTiled, FullscreenOrMaximized, WindowId},
Modifier, MouseEdge,
};
#[derive(Debug, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, Clone, Copy)]
pub struct CallbackId(pub u32);
#[derive(Debug, Hash, serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum MouseEdge {
Press,
Release,
}
/// A unique identifier for each window.
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum WindowId {
/// A config API returned an invalid window. It should be using this variant.
None,
/// A valid window id.
#[serde(untagged)]
Some(u32),
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, serde::Serialize, serde::Deserialize)]
pub enum TagId {
None,
#[serde(untagged)]
Some(u32),
}
/// A unique identifier for an output.
///
/// An empty string represents an invalid output.
#[derive(Debug, Hash, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct OutputName(pub String);
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
pub enum Layout {
MasterStack,
Dwindle,
Spiral,
CornerTopLeft,
CornerTopRight,
CornerBottomLeft,
CornerBottomRight,
}
#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)]
pub enum AccelProfile {
Flat,
@ -110,19 +77,6 @@ pub struct WindowRuleCondition {
tag: Option<Vec<TagId>>,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize)]
pub enum FloatingOrTiled {
Floating,
Tiled,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum FullscreenOrMaximized {
Neither,
Fullscreen,
Maximized,
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
pub struct WindowRule {
/// Set the output the window will open on.
@ -292,14 +246,6 @@ pub enum KeyIntOrString {
String(String),
}
#[derive(Debug, PartialEq, Eq, Copy, Clone, serde::Serialize, serde::Deserialize)]
pub enum Modifier {
Shift,
Ctrl,
Alt,
Super,
}
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
pub enum Args {
/// Send a message with lines from the spawned process.

View file

@ -1,10 +1,16 @@
use crate::{
msg::{Args, CallbackId, Msg, OutputName, Request, RequestResponse},
msg::{Args, CallbackId, Msg, Request, RequestResponse},
request, send_msg,
tag::{Tag, TagHandle},
CALLBACK_VEC,
};
/// A unique identifier for an output.
///
/// An empty string represents an invalid output.
#[derive(Debug, Hash, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct OutputName(pub String);
/// Output management.
pub struct Output;

View file

@ -1,8 +1,8 @@
use std::collections::HashMap;
use crate::{
msg::{Layout, Msg, OutputName, Request, RequestResponse, TagId},
output::{Output, OutputHandle},
msg::{Msg, Request, RequestResponse},
output::{Output, OutputHandle, OutputName},
request, send_msg,
};
@ -115,6 +115,13 @@ impl LayoutCycler {
}
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, serde::Serialize, serde::Deserialize)]
pub enum TagId {
None,
#[serde(untagged)]
Some(u32),
}
pub struct TagHandle(pub TagId);
pub struct TagProperties {
@ -160,3 +167,14 @@ impl TagHandle {
send_msg(msg).unwrap()
}
}
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
pub enum Layout {
MasterStack,
Dwindle,
Spiral,
CornerTopLeft,
CornerTopRight,
CornerBottomLeft,
CornerBottomRight,
}

View file

@ -1,10 +1,20 @@
use crate::{
msg::{FullscreenOrMaximized, Msg, Request, RequestResponse, WindowId},
msg::{Msg, Request, RequestResponse},
request, send_msg,
tag::TagHandle,
MouseButton,
};
/// A unique identifier for each window.
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum WindowId {
/// A config API returned an invalid window. It should be using this variant.
None,
/// A valid window id.
#[serde(untagged)]
Some(u32),
}
pub struct Window;
impl Window {
@ -125,3 +135,16 @@ impl WindowHandle {
send_msg(msg).unwrap();
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize)]
pub enum FloatingOrTiled {
Floating,
Tiled,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum FullscreenOrMaximized {
Neither,
Fullscreen,
Maximized,
}