wzrd

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

connection.rs (6959B)


      1 use crate::event::Event;
      2 use crate::geometry::Dim;
      3 use crate::geometry::Extents;
      4 use crate::geometry::Pos;
      5 use crate::geometry::Region;
      6 use crate::geometry::Strut;
      7 use crate::hints::Hints;
      8 use crate::hints::SizeHints;
      9 use crate::input::KeyInput;
     10 use crate::input::MouseInput;
     11 use crate::screen::Screen;
     12 use crate::window::IcccmWindowState;
     13 use crate::window::Window;
     14 use crate::window::WindowState;
     15 use crate::window::WindowType;
     16 use crate::Result;
     17 
     18 use std::collections::HashMap;
     19 
     20 pub type Pid = u32;
     21 
     22 pub trait Connection {
     23     fn flush(&self) -> bool;
     24     fn step(&self) -> Option<Event>;
     25     fn connected_outputs(&self) -> Vec<Screen>;
     26     fn top_level_windows(&self) -> Vec<Window>;
     27     fn get_pointer_position(&self) -> Pos;
     28     fn warp_pointer_center_of_window_or_root(
     29         &self,
     30         window: Option<Window>,
     31         screen: &Screen,
     32     );
     33     fn warp_pointer(
     34         &self,
     35         pos: Pos,
     36     );
     37     fn warp_pointer_rpos(
     38         &self,
     39         window: Window,
     40         pos: Pos,
     41     );
     42     fn confine_pointer(
     43         &self,
     44         window: Window,
     45     );
     46     fn release_pointer(&self);
     47     fn cleanup(&self);
     48 
     49     // Window manipulation
     50     fn create_frame(
     51         &self,
     52         region: Region,
     53     ) -> Window;
     54     fn create_handle(&self) -> Window;
     55     fn init_window(
     56         &self,
     57         window: Window,
     58         focus_follows_mouse: bool,
     59     );
     60     fn init_frame(
     61         &self,
     62         window: Window,
     63         focus_follows_mouse: bool,
     64     );
     65     fn init_unmanaged(
     66         &self,
     67         window: Window,
     68     );
     69     fn cleanup_window(
     70         &self,
     71         window: Window,
     72     );
     73     fn map_window(
     74         &self,
     75         window: Window,
     76     );
     77     fn unmap_window(
     78         &self,
     79         window: Window,
     80     );
     81     fn reparent_window(
     82         &self,
     83         window: Window,
     84         parent: Window,
     85         pos: Pos,
     86     );
     87     fn unparent_window(
     88         &self,
     89         window: Window,
     90         pos: Pos,
     91     );
     92     fn destroy_window(
     93         &self,
     94         window: Window,
     95     );
     96     fn close_window(
     97         &self,
     98         window: Window,
     99     ) -> bool;
    100     fn kill_window(
    101         &self,
    102         window: Window,
    103     ) -> bool;
    104     fn place_window(
    105         &self,
    106         window: Window,
    107         region: &Region,
    108     );
    109     fn move_window(
    110         &self,
    111         window: Window,
    112         pos: Pos,
    113     );
    114     fn resize_window(
    115         &self,
    116         window: Window,
    117         dim: Dim,
    118     );
    119     fn focus_window(
    120         &self,
    121         window: Window,
    122     );
    123     fn stack_window_above(
    124         &self,
    125         window: Window,
    126         sibling: Option<Window>,
    127     );
    128     fn stack_window_below(
    129         &self,
    130         window: Window,
    131         sibling: Option<Window>,
    132     );
    133     fn insert_window_in_save_set(
    134         &self,
    135         window: Window,
    136     );
    137     fn grab_bindings(
    138         &self,
    139         key_codes: &[&KeyInput],
    140         mouse_bindings: &[&MouseInput],
    141     );
    142     fn regrab_buttons(
    143         &self,
    144         window: Window,
    145     );
    146     fn ungrab_buttons(
    147         &self,
    148         window: Window,
    149     );
    150     fn unfocus(&self);
    151     fn set_window_border_width(
    152         &self,
    153         window: Window,
    154         width: u32,
    155     );
    156     fn set_window_border_color(
    157         &self,
    158         window: Window,
    159         color: u32,
    160     );
    161     fn set_window_background_color(
    162         &self,
    163         window: Window,
    164         color: u32,
    165     );
    166     fn update_window_offset(
    167         &self,
    168         window: Window,
    169         frame: Window,
    170     );
    171     fn get_focused_window(&self) -> Window;
    172     fn get_window_geometry(
    173         &self,
    174         window: Window,
    175     ) -> Result<Region>;
    176     fn get_window_pid(
    177         &self,
    178         window: Window,
    179     ) -> Option<Pid>;
    180     fn must_manage_window(
    181         &self,
    182         window: Window,
    183     ) -> bool;
    184     fn must_free_window(
    185         &self,
    186         window: Window,
    187     ) -> bool;
    188     fn window_is_mappable(
    189         &self,
    190         window: Window,
    191     ) -> bool;
    192 
    193     // ICCCM
    194     fn set_icccm_window_state(
    195         &self,
    196         window: Window,
    197         state: IcccmWindowState,
    198     );
    199     fn set_icccm_window_hints(
    200         &self,
    201         window: Window,
    202         hints: Hints,
    203     );
    204     fn get_icccm_window_name(
    205         &self,
    206         window: Window,
    207     ) -> String;
    208     fn get_icccm_window_class(
    209         &self,
    210         window: Window,
    211     ) -> String;
    212     fn get_icccm_window_instance(
    213         &self,
    214         window: Window,
    215     ) -> String;
    216     fn get_icccm_window_transient_for(
    217         &self,
    218         window: Window,
    219     ) -> Option<Window>;
    220     fn get_icccm_window_client_leader(
    221         &self,
    222         window: Window,
    223     ) -> Option<Window>;
    224     fn get_icccm_window_hints(
    225         &self,
    226         window: Window,
    227     ) -> Option<Hints>;
    228     fn get_icccm_window_size_hints(
    229         &self,
    230         window: Window,
    231         min_window_dim: Option<Dim>,
    232         current_size_hints: &Option<SizeHints>,
    233     ) -> (bool, Option<SizeHints>);
    234 
    235     // EWMH
    236     fn init_wm_properties(
    237         &self,
    238         wm_name: &str,
    239         desktop_names: &[&str],
    240     );
    241     fn set_current_desktop(
    242         &self,
    243         index: usize,
    244     );
    245     fn set_root_window_name(
    246         &self,
    247         name: &str,
    248     );
    249     fn set_window_desktop(
    250         &self,
    251         window: Window,
    252         index: usize,
    253     );
    254     fn set_window_state(
    255         &self,
    256         window: Window,
    257         state: WindowState,
    258         on: bool,
    259     );
    260     fn set_window_frame_extents(
    261         &self,
    262         window: Window,
    263         extents: Extents,
    264     );
    265     fn set_desktop_geometry(
    266         &self,
    267         geometries: &[&Region],
    268     );
    269     fn set_desktop_viewport(
    270         &self,
    271         viewports: &[&Region],
    272     );
    273     fn set_workarea(
    274         &self,
    275         workareas: &[&Region],
    276     );
    277     fn update_desktops(
    278         &self,
    279         desktop_names: &[&str],
    280     );
    281     fn update_client_list(
    282         &self,
    283         clients: &[Window],
    284     );
    285     fn update_client_list_stacking(
    286         &self,
    287         clients: &[Window],
    288     );
    289     fn get_window_strut(
    290         &self,
    291         window: Window,
    292     ) -> Option<Vec<Option<Strut>>>;
    293     fn get_window_strut_partial(
    294         &self,
    295         window: Window,
    296     ) -> Option<Vec<Option<Strut>>>;
    297     fn get_window_desktop(
    298         &self,
    299         window: Window,
    300     ) -> Option<usize>;
    301     fn get_window_preferred_type(
    302         &self,
    303         window: Window,
    304     ) -> WindowType;
    305     fn get_window_types(
    306         &self,
    307         window: Window,
    308     ) -> Vec<WindowType>;
    309     fn get_window_preferred_state(
    310         &self,
    311         window: Window,
    312     ) -> Option<WindowState>;
    313     fn get_window_states(
    314         &self,
    315         window: Window,
    316     ) -> Vec<WindowState>;
    317     fn window_is_fullscreen(
    318         &self,
    319         window: Window,
    320     ) -> bool;
    321     fn window_is_above(
    322         &self,
    323         window: Window,
    324     ) -> bool;
    325     fn window_is_below(
    326         &self,
    327         window: Window,
    328     ) -> bool;
    329     fn window_is_sticky(
    330         &self,
    331         window: Window,
    332     ) -> bool;
    333 }