diff --git a/libwaysip/examples/base.rs b/libwaysip/examples/base.rs index f245c3b..3ed4efc 100644 --- a/libwaysip/examples/base.rs +++ b/libwaysip/examples/base.rs @@ -1,4 +1,4 @@ -use libwaysip::{get_area, state::WaySipKind}; +use libwaysip::{get_area, state::SelectionType}; fn main() { println!("{:?}", get_area(WaySipKind::Area)); } diff --git a/libwaysip/src/lib.rs b/libwaysip/src/lib.rs index 522bd1b..b4b3b16 100644 --- a/libwaysip/src/lib.rs +++ b/libwaysip/src/lib.rs @@ -35,7 +35,7 @@ fn get_cursor_buffer(connection: &Connection, shm: &WlShm) -> Option Result, WaySipError> { +pub fn get_area(kind: state::SelectionType) -> Result, WaySipError> { let connection = Connection::connect_to_env().map_err(|e| WaySipError::InitFailed(e.to_string()))?; let (globals, _) = registry_queue_init::(&connection) diff --git a/libwaysip/src/state.rs b/libwaysip/src/state.rs index 6111bf3..df9ee85 100644 --- a/libwaysip/src/state.rs +++ b/libwaysip/src/state.rs @@ -9,7 +9,7 @@ use wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::ZwlrL /// You are allow to choose three actions of waysip, include area selection, point selection, and /// select sreen #[derive(Debug, Clone, Copy, Default)] -pub enum WaySipKind { +pub enum SelectionType { #[default] Area, Point, @@ -132,7 +132,7 @@ pub struct WaysipState { pub outputs: Vec, pub zxdgoutputs: Vec, pub running: bool, - pub waysipkind: WaySipKind, + pub waysipkind: SelectionType, pub wl_surfaces: Vec, pub current_pos: (f64, f64), pub start_pos: Option<(f64, f64)>, @@ -142,7 +142,7 @@ pub struct WaysipState { } impl WaysipState { - pub fn new(waysipkind: WaySipKind) -> Self { + pub fn new(waysipkind: SelectionType) -> Self { WaysipState { outputs: Vec::new(), zxdgoutputs: Vec::new(), @@ -158,11 +158,11 @@ impl WaysipState { } pub fn is_area(&self) -> bool { - matches!(self.waysipkind, WaySipKind::Area) + matches!(self.waysipkind, SelectionType::Area) } pub fn is_screen(&self) -> bool { - matches!(self.waysipkind, WaySipKind::Screen) + matches!(self.waysipkind, SelectionType::Screen) } pub fn redraw_screen(&self) { diff --git a/waysip/src/main.rs b/waysip/src/main.rs index 5a8dfbc..37ba1f2 100644 --- a/waysip/src/main.rs +++ b/waysip/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use libwaysip::{get_area, state::WaySipKind}; +use libwaysip::{get_area, state::SelectionType}; use std::str::FromStr; #[derive(Debug, Parser)] @@ -24,7 +24,7 @@ fn main() -> Result<(), Box> { let args = Cli::parse(); - // TODO: Enable tracing based logging for dispatch calls etc + // TODO: Enable tracing // TODO: Make errors go through the cli into output macro_rules! get_info { @@ -46,19 +46,19 @@ fn main() -> Result<(), Box> { match args { Cli::Point => { - let info = get_info!(WaySipKind::Point); + let info = get_info!(SelectionType::Point); let (x, y) = info.left_top_point(); println!("{x},{y} 1x1"); } Cli::Dimensions => { - let info = get_info!(WaySipKind::Area); + let info = get_info!(SelectionType::Area); let (x, y) = info.left_top_point(); let width = info.width(); let height = info.height(); println!("{x},{y} {width}x{height}",); } Cli::Screen => { - let info = get_info!(WaySipKind::Screen); + let info = get_info!(SelectionType::Screen); let screen_info = info.selected_screen_info(); let (w, h) = screen_info.get_size(); let name = screen_info.get_name(); @@ -70,7 +70,7 @@ fn main() -> Result<(), Box> { println!("width: {wl_w}, height: {wl_h}"); } Cli::Output => { - let info = get_info!(WaySipKind::Screen); + let info = get_info!(SelectionType::Screen); let screen_info = info.selected_screen_info(); let (x, y) = screen_info.get_position(); let (width, height) = screen_info.get_size();