wzrd

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

rule.rs (1292B)


      1 use crate::change::Toggle;
      2 use crate::client::Client;
      3 
      4 #[derive(Debug)]
      5 pub struct Rules {
      6     pub float: Option<bool>,
      7     pub center: Option<bool>,
      8     pub fullscreen: Option<bool>,
      9     pub workspace: Option<usize>,
     10     pub context: Option<usize>,
     11 }
     12 
     13 impl Rules {
     14     pub fn propagate(
     15         &self,
     16         client: &Client,
     17     ) {
     18         if let Some(float) = self.float {
     19             client.set_floating(Toggle::from(float));
     20         }
     21 
     22         if let Some(fullscreen) = self.fullscreen {
     23             client.set_fullscreen(Toggle::from(fullscreen));
     24         }
     25 
     26         if let Some(workspace) = self.workspace {
     27             client.set_workspace(workspace);
     28         }
     29 
     30         if let Some(context) = self.context {
     31             client.set_context(context);
     32         }
     33     }
     34 
     35     pub fn float(&self) -> bool {
     36         self.float.map_or(false, |float| float)
     37     }
     38 
     39     pub fn center(&self) -> bool {
     40         self.center.map_or(false, |center| center)
     41     }
     42 
     43     pub fn fullscreen(&self) -> bool {
     44         self.fullscreen.map_or(false, |fullscreen| fullscreen)
     45     }
     46 }
     47 
     48 impl Default for Rules {
     49     fn default() -> Self {
     50         Self {
     51             float: None,
     52             center: None,
     53             fullscreen: None,
     54             workspace: None,
     55             context: None,
     56         }
     57     }
     58 }