mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
parent
157e34ceb8
commit
a4eb149816
4 changed files with 35 additions and 10 deletions
|
@ -66,6 +66,7 @@ impl Compositor {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "keyboard")]
|
||||
pub fn create_keyboard_layout_client(
|
||||
clients: &mut super::Clients,
|
||||
) -> ClientResult<dyn KeyboardLayoutClient + Send + Sync> {
|
||||
|
@ -78,7 +79,11 @@ impl Compositor {
|
|||
.map(|client| client as Arc<dyn KeyboardLayoutClient + Send + Sync>),
|
||||
#[cfg(feature = "keyboard+hyprland")]
|
||||
Self::Hyprland => Ok(clients.hyprland()),
|
||||
Self::Niri | Self::Unsupported => Err(Report::msg("Unsupported compositor").note(
|
||||
#[cfg(feature = "workspaces")]
|
||||
Self::Niri => Err(Report::msg("Unsupported compositor").note(
|
||||
"Currently keyboard layout functionality are only supported by Sway and Hyprland",
|
||||
)),
|
||||
Self::Unsupported => Err(Report::msg("Unsupported compositor").note(
|
||||
"Currently keyboard layout functionality are only supported by Sway and Hyprland",
|
||||
)),
|
||||
}
|
||||
|
@ -86,6 +91,7 @@ impl Compositor {
|
|||
|
||||
/// Creates a new instance of
|
||||
/// the workspace client for the current compositor.
|
||||
#[cfg(feature = "workspaces")]
|
||||
pub fn create_workspace_client(
|
||||
clients: &mut super::Clients,
|
||||
) -> Result<Arc<dyn WorkspaceClient + Send + Sync>> {
|
||||
|
@ -183,6 +189,7 @@ pub enum WorkspaceUpdate {
|
|||
Unknown,
|
||||
}
|
||||
|
||||
#[cfg(feature = "workspaces")]
|
||||
pub trait WorkspaceClient: Debug + Send + Sync {
|
||||
/// Requests the workspace with this id is focused.
|
||||
fn focus(&self, id: i64);
|
||||
|
@ -191,8 +198,10 @@ pub trait WorkspaceClient: Debug + Send + Sync {
|
|||
fn subscribe(&self) -> broadcast::Receiver<WorkspaceUpdate>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "workspaces")]
|
||||
register_fallible_client!(dyn WorkspaceClient, workspaces);
|
||||
|
||||
#[cfg(feature = "keyboard")]
|
||||
pub trait KeyboardLayoutClient: Debug + Send + Sync {
|
||||
/// Switches to the next layout.
|
||||
fn set_next_active(&self);
|
||||
|
@ -201,4 +210,5 @@ pub trait KeyboardLayoutClient: Debug + Send + Sync {
|
|||
fn subscribe(&self) -> broadcast::Receiver<KeyboardLayoutUpdate>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "keyboard")]
|
||||
register_fallible_client!(dyn KeyboardLayoutClient, keyboard_layout);
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::sync::Arc;
|
|||
|
||||
#[cfg(feature = "clipboard")]
|
||||
pub mod clipboard;
|
||||
#[cfg(feature = "workspaces")]
|
||||
#[cfg(any(feature = "keyboard", feature = "workspaces"))]
|
||||
pub mod compositor;
|
||||
#[cfg(feature = "keyboard")]
|
||||
pub mod libinput;
|
||||
|
@ -46,7 +46,7 @@ pub struct Clients {
|
|||
clipboard: Option<Arc<clipboard::Client>>,
|
||||
#[cfg(feature = "keyboard")]
|
||||
libinput: HashMap<Box<str>, Arc<libinput::Client>>,
|
||||
#[cfg(any(feature = "keyboard+sway", feature = "keyboard+hyprland"))]
|
||||
#[cfg(feature = "keyboard")]
|
||||
keyboard_layout: Option<Arc<dyn compositor::KeyboardLayoutClient>>,
|
||||
#[cfg(feature = "cairo")]
|
||||
lua: Option<Rc<lua::LuaEngine>>,
|
||||
|
@ -101,7 +101,7 @@ impl Clients {
|
|||
Ok(client)
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "keyboard+sway", feature = "keyboard+hyprland"))]
|
||||
#[cfg(feature = "keyboard")]
|
||||
pub fn keyboard_layout(&mut self) -> ClientResult<dyn compositor::KeyboardLayoutClient> {
|
||||
let client = if let Some(keyboard_layout) = &self.keyboard_layout {
|
||||
keyboard_layout.clone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue