From 2da90fc625725c6d3465c920826e2718579cfb40 Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Wed, 12 Apr 2023 12:05:08 +0300 Subject: WIP: hyprland support --- src/wm_info_provider.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/wm_info_provider.rs') diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs index 12e4fb8..7f2d941 100644 --- a/src/wm_info_provider.rs +++ b/src/wm_info_provider.rs @@ -1,3 +1,4 @@ +mod ext_workspace_unstable; mod river; use wayrs_client::connection::Connection; @@ -6,10 +7,13 @@ use wayrs_client::global::*; use crate::pointer_btn::PointerBtn; use crate::protocol::*; use crate::state::State; +use ext_workspace_unstable::*; +use river::*; pub enum WmInfoProvider { None, - River(river::RiverInfoProvider), + River(RiverInfoProvider), + EWU(ExtWorkspaceUnstable), } pub type WmInfoCallback = fn(&mut Connection, &mut State, WlOutput, WmInfo); @@ -20,21 +24,28 @@ impl WmInfoProvider { globals: &Globals, callback: WmInfoCallback, ) -> WmInfoProvider { - let Some(river) = river::RiverInfoProvider::bind(conn, globals, callback) else { return Self::None }; - Self::River(river) + if let Some(river) = RiverInfoProvider::bind(conn, globals, callback) { + Self::River(river) + } else if let Some(ext_wp_u) = ExtWorkspaceUnstable::bind(conn, globals, callback) { + Self::EWU(ext_wp_u) + } else { + Self::None + } } pub fn new_ouput(&mut self, conn: &mut Connection, output: WlOutput) { match self { Self::None => (), - Self::River(river) => river.new_output(conn, output), + Self::River(x) => x.new_output(conn, output), + Self::EWU(x) => x.new_ouput(conn, output), } } pub fn output_removed(&mut self, conn: &mut Connection, output: WlOutput) { match self { Self::None => (), - Self::River(river) => river.output_removed(conn, output), + Self::River(x) => x.output_removed(conn, output), + Self::EWU(x) => x.output_removed(conn, output), } } @@ -48,17 +59,19 @@ impl WmInfoProvider { ) { match self { Self::None => (), - Self::River(river) => river.click_on_tag(conn, output, seat, tag, btn), + Self::River(x) => x.click_on_tag(conn, output, seat, tag, btn), + Self::EWU(x) => x.click_on_tag(conn, output, seat, tag, btn), } } } -#[derive(Default)] +#[derive(Default, Debug)] pub struct WmInfo { pub layout_name: Option, pub tags: Vec, } +#[derive(Debug)] pub struct Tag { pub name: String, pub is_focused: bool, -- cgit v1.3.1 From 2c9bc7c4b6609bf6b840f6494618034a6dd3cafc Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Thu, 1 Jun 2023 13:55:13 +0300 Subject: fix clippy lint --- src/wm_info_provider.rs | 10 +++++----- src/wm_info_provider/ext_workspace_unstable.rs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/wm_info_provider.rs') diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs index 7f2d941..134bc77 100644 --- a/src/wm_info_provider.rs +++ b/src/wm_info_provider.rs @@ -13,7 +13,7 @@ use river::*; pub enum WmInfoProvider { None, River(RiverInfoProvider), - EWU(ExtWorkspaceUnstable), + Ewu(ExtWorkspaceUnstable), } pub type WmInfoCallback = fn(&mut Connection, &mut State, WlOutput, WmInfo); @@ -27,7 +27,7 @@ impl WmInfoProvider { if let Some(river) = RiverInfoProvider::bind(conn, globals, callback) { Self::River(river) } else if let Some(ext_wp_u) = ExtWorkspaceUnstable::bind(conn, globals, callback) { - Self::EWU(ext_wp_u) + Self::Ewu(ext_wp_u) } else { Self::None } @@ -37,7 +37,7 @@ impl WmInfoProvider { match self { Self::None => (), Self::River(x) => x.new_output(conn, output), - Self::EWU(x) => x.new_ouput(conn, output), + Self::Ewu(x) => x.new_ouput(conn, output), } } @@ -45,7 +45,7 @@ impl WmInfoProvider { match self { Self::None => (), Self::River(x) => x.output_removed(conn, output), - Self::EWU(x) => x.output_removed(conn, output), + Self::Ewu(x) => x.output_removed(conn, output), } } @@ -60,7 +60,7 @@ impl WmInfoProvider { match self { Self::None => (), Self::River(x) => x.click_on_tag(conn, output, seat, tag, btn), - Self::EWU(x) => x.click_on_tag(conn, output, seat, tag, btn), + Self::Ewu(x) => x.click_on_tag(conn, output, seat, tag, btn), } } } diff --git a/src/wm_info_provider/ext_workspace_unstable.rs b/src/wm_info_provider/ext_workspace_unstable.rs index 7b482da..793f78f 100644 --- a/src/wm_info_provider/ext_workspace_unstable.rs +++ b/src/wm_info_provider/ext_workspace_unstable.rs @@ -85,7 +85,7 @@ fn manager_cb( _: ZextWorkspaceManagerV1, event: zext_workspace_manager_v1::Event, ) { - let WmInfoProvider::EWU(state) = &mut s.shared_state.wm_info_provider else { unreachable!() }; + let WmInfoProvider::Ewu(state) = &mut s.shared_state.wm_info_provider else { unreachable!() }; match event { zext_workspace_manager_v1::Event::WorkspaceGroup(group_handle) => { @@ -141,7 +141,7 @@ fn group_cb( group_handle: ZextWorkspaceGroupHandleV1, event: zext_workspace_group_handle_v1::Event, ) { - let WmInfoProvider::EWU(state) = &mut state.shared_state.wm_info_provider else { unreachable!() }; + let WmInfoProvider::Ewu(state) = &mut state.shared_state.wm_info_provider else { unreachable!() }; let group = state .groups .iter_mut() @@ -174,7 +174,7 @@ fn workspace_cb( workspace_handle: ZextWorkspaceHandleV1, event: zext_workspace_handle_v1::Event, ) { - let WmInfoProvider::EWU(state) = &mut state.shared_state.wm_info_provider else { unreachable!() }; + let WmInfoProvider::Ewu(state) = &mut state.shared_state.wm_info_provider else { unreachable!() }; let group = state .groups .iter_mut() -- cgit v1.3.1 From 13c08ca31ee1ccbbeceb8962d739a077048d59ac Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Thu, 1 Jun 2023 16:32:34 +0300 Subject: pub hyprland support behind feature flag --- Cargo.toml | 3 +++ README.md | 4 ++++ src/protocol.rs | 2 ++ src/wm_info_provider.rs | 26 ++++++++++++++++++-------- src/wm_info_provider/ext_workspace_unstable.rs | 1 - src/wm_info_provider/river.rs | 1 - 6 files changed, 27 insertions(+), 10 deletions(-) (limited to 'src/wm_info_provider.rs') diff --git a/Cargo.toml b/Cargo.toml index 68e91ec..d2ba84b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,9 @@ edition = "2021" license = "GPL-3.0-only" authors = ["MaxVerevkin "] +[features] +hyprland = [] + [dependencies] anyhow = "1" toml = { version = "0.7", default-features = false, features = ["parse"] } diff --git a/README.md b/README.md index 9fc5f2b..f1cf446 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ A list of things that are missing (for now): - Support for rounded corners - Show/hide with `pkill -SIGUSR1 i3bar-river` +## Hyprland support + +Hyprland/wlr_ext_workspaces support is experimental and is behind `hyprland` feature flag. Build with `-F hyprland` to enable it. + ## Installation ### Arch diff --git a/src/protocol.rs b/src/protocol.rs index c393850..d14d92a 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -4,4 +4,6 @@ pub use wayrs_protocols::viewporter::*; pub use wayrs_protocols::wlr_layer_shell_unstable_v1::*; wayrs_client::scanner::generate!("protocols/river-status-unstable-v1.xml"); wayrs_client::scanner::generate!("protocols/river-control-unstable-v1.xml"); + +#[cfg(feature = "hyprland")] wayrs_client::scanner::generate!("protocols/ext-workspace-unstable-v1.xml"); diff --git a/src/wm_info_provider.rs b/src/wm_info_provider.rs index 134bc77..e11e48e 100644 --- a/src/wm_info_provider.rs +++ b/src/wm_info_provider.rs @@ -1,18 +1,22 @@ -mod ext_workspace_unstable; -mod river; - use wayrs_client::connection::Connection; use wayrs_client::global::*; use crate::pointer_btn::PointerBtn; use crate::protocol::*; use crate::state::State; + +#[cfg(feature = "hyprland")] +mod ext_workspace_unstable; +#[cfg(feature = "hyprland")] use ext_workspace_unstable::*; + +mod river; use river::*; pub enum WmInfoProvider { None, River(RiverInfoProvider), + #[cfg(feature = "hyprland")] Ewu(ExtWorkspaceUnstable), } @@ -25,18 +29,22 @@ impl WmInfoProvider { callback: WmInfoCallback, ) -> WmInfoProvider { if let Some(river) = RiverInfoProvider::bind(conn, globals, callback) { - Self::River(river) - } else if let Some(ext_wp_u) = ExtWorkspaceUnstable::bind(conn, globals, callback) { - Self::Ewu(ext_wp_u) - } else { - Self::None + return Self::River(river); } + + #[cfg(feature = "hyprland")] + if let Some(ext_wp_u) = ExtWorkspaceUnstable::bind(conn, globals, callback) { + return Self::Ewu(ext_wp_u); + } + + Self::None } pub fn new_ouput(&mut self, conn: &mut Connection, output: WlOutput) { match self { Self::None => (), Self::River(x) => x.new_output(conn, output), + #[cfg(feature = "hyprland")] Self::Ewu(x) => x.new_ouput(conn, output), } } @@ -45,6 +53,7 @@ impl WmInfoProvider { match self { Self::None => (), Self::River(x) => x.output_removed(conn, output), + #[cfg(feature = "hyprland")] Self::Ewu(x) => x.output_removed(conn, output), } } @@ -60,6 +69,7 @@ impl WmInfoProvider { match self { Self::None => (), Self::River(x) => x.click_on_tag(conn, output, seat, tag, btn), + #[cfg(feature = "hyprland")] Self::Ewu(x) => x.click_on_tag(conn, output, seat, tag, btn), } } diff --git a/src/wm_info_provider/ext_workspace_unstable.rs b/src/wm_info_provider/ext_workspace_unstable.rs index 793f78f..0af550b 100644 --- a/src/wm_info_provider/ext_workspace_unstable.rs +++ b/src/wm_info_provider/ext_workspace_unstable.rs @@ -4,7 +4,6 @@ use wayrs_client::object::ObjectId; use wayrs_client::proxy::Proxy; use super::*; -use crate::protocol::*; use crate::state::State; pub struct ExtWorkspaceUnstable { diff --git a/src/wm_info_provider/river.rs b/src/wm_info_provider/river.rs index c7740a3..82fa5d8 100644 --- a/src/wm_info_provider/river.rs +++ b/src/wm_info_provider/river.rs @@ -4,7 +4,6 @@ use wayrs_client::connection::Connection; use wayrs_client::{cstr, global::*}; use super::*; -use crate::protocol::*; use crate::state::State; pub struct RiverInfoProvider { -- cgit v1.3.1