Skip to content

Commit

Permalink
ref: Change ambiguous struct name WaySipKind
Browse files Browse the repository at this point in the history
Signed-off-by: Shinyzenith <[email protected]>
  • Loading branch information
Shinyzenith committed Apr 7, 2024
1 parent 6de35fa commit 4e5df38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libwaysip/examples/base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use libwaysip::{get_area, state::WaySipKind};
use libwaysip::{get_area, state::SelectionType};
fn main() {
println!("{:?}", get_area(WaySipKind::Area));
}
2 changes: 1 addition & 1 deletion libwaysip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn get_cursor_buffer(connection: &Connection, shm: &WlShm) -> Option<CursorImage
}

/// get the selected area
pub fn get_area(kind: state::WaySipKind) -> Result<Option<state::AreaInfo>, WaySipError> {
pub fn get_area(kind: state::SelectionType) -> Result<Option<state::AreaInfo>, WaySipError> {
let connection =
Connection::connect_to_env().map_err(|e| WaySipError::InitFailed(e.to_string()))?;
let (globals, _) = registry_queue_init::<state::WaysipState>(&connection)
Expand Down
10 changes: 5 additions & 5 deletions libwaysip/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -132,7 +132,7 @@ pub struct WaysipState {
pub outputs: Vec<WlOutputInfo>,
pub zxdgoutputs: Vec<ZXdgOutputInfo>,
pub running: bool,
pub waysipkind: WaySipKind,
pub waysipkind: SelectionType,
pub wl_surfaces: Vec<LayerSurfaceInfo>,
pub current_pos: (f64, f64),
pub start_pos: Option<(f64, f64)>,
Expand All @@ -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(),
Expand All @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions waysip/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -24,7 +24,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

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 {
Expand All @@ -46,19 +46,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

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();
Expand All @@ -70,7 +70,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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();
Expand Down

0 comments on commit 4e5df38

Please sign in to comment.