wzrd

An ICCCM & EWMH compliant X11 reparenting, dynamic window manager, written in Rust
git clone git://git.deurzen.net/wzrd
Log | Files | Refs | LICENSE

change.rs (1233B)


      1 use crate::decoration::Decoration;
      2 
      3 use winsys::geometry::Region;
      4 
      5 use std::ops::Add;
      6 use std::ops::Mul;
      7 use std::ops::Sub;
      8 
      9 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
     10 pub enum Toggle {
     11     On,
     12     Off,
     13     Reverse,
     14 }
     15 
     16 impl From<bool> for Toggle {
     17     #[inline(always)]
     18     fn from(toggle: bool) -> Self {
     19         match toggle {
     20             true => Toggle::On,
     21             false => Toggle::Off,
     22         }
     23     }
     24 }
     25 
     26 impl Toggle {
     27     #[inline(always)]
     28     pub fn eval(
     29         self,
     30         current: bool,
     31     ) -> bool {
     32         match self {
     33             Toggle::On => true,
     34             Toggle::Off => false,
     35             Toggle::Reverse => !current,
     36         }
     37     }
     38 }
     39 
     40 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
     41 pub enum Direction {
     42     Forward,
     43     Backward,
     44 }
     45 
     46 impl Direction {
     47     pub fn rev(&self) -> Self {
     48         match self {
     49             Self::Forward => Self::Backward,
     50             Self::Backward => Self::Forward,
     51         }
     52     }
     53 }
     54 
     55 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
     56 pub enum Change<T>
     57 where
     58     T: Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
     59 {
     60     Inc(T),
     61     Dec(T),
     62 }
     63 
     64 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
     65 pub enum Disposition {
     66     Unchanged(Decoration),
     67     Changed(Region, Decoration),
     68 }