diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2023-01-31 23:39:16 +0200 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2023-01-31 23:39:16 +0200 |
| commit | e8c64f46d9a8e79afb13874813fa6a739025d28c (patch) | |
| tree | d4a5ce6354b5fe42ee91064e018ff0547f451d19 /src/wm_info_provider.rs | |
| parent | 3200ac24848dd8820ad65b5ec83dc741999b1581 (diff) | |
| download | i3bar-mango-e8c64f46d9a8e79afb13874813fa6a739025d28c.tar.gz | |
abstract over tag and layout name provider
Diffstat (limited to 'src/wm_info_provider.rs')
| -rw-r--r-- | src/wm_info_provider.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs new file mode 100644 index 0000000..b7854b1 --- /dev/null +++ b/src/wm_info_provider.rs @@ -0,0 +1,58 @@ +mod river; + +use std::any::Any; + +use wayrs_client::connection::Connection; +use wayrs_client::global::*; + +use crate::protocol::*; +use crate::state::State; + +pub type WmInfoCallback = fn(&mut Connection<State>, &mut State, WlOutput, WmInfo); + +pub trait WmInfoProvider { + fn as_any(&mut self) -> &mut dyn Any; + + fn new_outut(&mut self, conn: &mut Connection<State>, output: WlOutput); + + fn output_removed(&mut self, conn: &mut Connection<State>, output: WlOutput); + + fn left_click_on_tag( + &mut self, + conn: &mut Connection<State>, + output: WlOutput, + seat: WlSeat, + tag: &str, + ); + + fn middle_click_on_tag( + &mut self, + conn: &mut Connection<State>, + output: WlOutput, + seat: WlSeat, + tag: &str, + ); +} + +#[derive(Default)] +pub struct WmInfo { + pub layout_name: Option<String>, + pub tags: Vec<Tag>, +} + +pub struct Tag { + pub name: String, + pub is_focused: bool, + 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)) +} |
