diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2023-06-01 13:23:26 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2023-06-01 13:23:26 +0300 |
| commit | 84b8dfe8cd190de33221f465a7059be6a30769f5 (patch) | |
| tree | ab7b9e7b537858a5aa6376be6b8355c723f0fdec /src/wm_info_provider.rs | |
| parent | f11240cb1e30e494be840d2ecef8504dd8cea7ff (diff) | |
| download | i3bar-mango-84b8dfe8cd190de33221f465a7059be6a30769f5.tar.gz | |
small changes
Diffstat (limited to 'src/wm_info_provider.rs')
| -rw-r--r-- | src/wm_info_provider.rs | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs index f5ac615..12e4fb8 100644 --- a/src/wm_info_provider.rs +++ b/src/wm_info_provider.rs @@ -1,37 +1,56 @@ mod river; -use std::any::Any; - use wayrs_client::connection::Connection; use wayrs_client::global::*; +use crate::pointer_btn::PointerBtn; use crate::protocol::*; use crate::state::State; -pub type WmInfoCallback = fn(&mut Connection<State>, &mut State, WlOutput, WmInfo); +pub enum WmInfoProvider { + None, + River(river::RiverInfoProvider), +} -pub trait WmInfoProvider { - fn as_any(&mut self) -> &mut dyn Any; +pub type WmInfoCallback = fn(&mut Connection<State>, &mut State, WlOutput, WmInfo); - fn new_outut(&mut self, conn: &mut Connection<State>, output: WlOutput); +impl WmInfoProvider { + pub fn bind( + conn: &mut Connection<State>, + globals: &Globals, + callback: WmInfoCallback, + ) -> WmInfoProvider { + let Some(river) = river::RiverInfoProvider::bind(conn, globals, callback) else { return Self::None }; + Self::River(river) + } - fn output_removed(&mut self, conn: &mut Connection<State>, output: WlOutput); + pub fn new_ouput(&mut self, conn: &mut Connection<State>, output: WlOutput) { + match self { + Self::None => (), + Self::River(river) => river.new_output(conn, output), + } + } - fn left_click_on_tag( - &mut self, - conn: &mut Connection<State>, - output: WlOutput, - seat: WlSeat, - tag: &str, - ); + pub fn output_removed(&mut self, conn: &mut Connection<State>, output: WlOutput) { + match self { + Self::None => (), + Self::River(river) => river.output_removed(conn, output), + } + } - fn right_click_on_tag( + pub fn click_on_tag( &mut self, conn: &mut Connection<State>, output: WlOutput, seat: WlSeat, tag: &str, - ); + btn: PointerBtn, + ) { + match self { + Self::None => (), + Self::River(river) => river.click_on_tag(conn, output, seat, tag, btn), + } + } } #[derive(Default)] @@ -46,13 +65,3 @@ pub struct Tag { pub is_active: bool, pub is_urgent: bool, } - -pub fn bind_wayland( - conn: &mut Connection<State>, - globals: &Globals, - callback: WmInfoCallback, -) -> Option<Box<dyn WmInfoProvider>> { - // TODO: add more providers - let river = river::RiverInfoProvider::bind(conn, globals, callback)?; - Some(Box::new(river)) -} |
