mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 14:21:03 +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()
|
||||
|
|
|
@ -4,14 +4,24 @@ use gtk::prelude::*;
|
|||
use gtk::{Button, IconTheme, Image, Label, Orientation};
|
||||
use std::ops::Deref;
|
||||
|
||||
#[cfg(any(feature = "music", feature = "workspaces", feature = "clipboard"))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg(any(
|
||||
feature = "clipboard",
|
||||
feature = "keyboard",
|
||||
feature = "music",
|
||||
feature = "workspaces"
|
||||
))]
|
||||
pub struct IconButton {
|
||||
button: Button,
|
||||
label: Label,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "music", feature = "workspaces", feature = "clipboard"))]
|
||||
#[cfg(any(
|
||||
feature = "clipboard",
|
||||
feature = "keyboard",
|
||||
feature = "music",
|
||||
feature = "workspaces"
|
||||
))]
|
||||
impl IconButton {
|
||||
pub fn new(input: &str, icon_theme: &IconTheme, size: i32) -> Self {
|
||||
let button = Button::new();
|
||||
|
@ -55,7 +65,7 @@ impl Deref for IconButton {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "music", feature = "keyboard"))]
|
||||
#[cfg(any(feature = "keyboard", feature = "music", feature = "workspaces"))]
|
||||
pub struct IconLabel {
|
||||
container: gtk::Box,
|
||||
label: Label,
|
||||
|
@ -65,7 +75,7 @@ pub struct IconLabel {
|
|||
size: i32,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "music", feature = "keyboard"))]
|
||||
#[cfg(any(feature = "keyboard", feature = "music", feature = "workspaces"))]
|
||||
impl IconLabel {
|
||||
pub fn new(input: &str, icon_theme: &IconTheme, size: i32) -> Self {
|
||||
let container = gtk::Box::new(Orientation::Horizontal, 0);
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#[cfg(any(feature = "music", feature = "workspaces", feature = "clipboard"))]
|
||||
#[cfg(any(
|
||||
feature = "clipboard",
|
||||
feature = "keyboard",
|
||||
feature = "music",
|
||||
feature = "workspaces"
|
||||
))]
|
||||
mod gtk;
|
||||
mod provider;
|
||||
|
||||
#[cfg(any(feature = "music", feature = "workspaces"))]
|
||||
#[cfg(any(feature = "keyboard", feature = "music", feature = "workspaces"))]
|
||||
pub use self::gtk::*;
|
||||
pub use provider::ImageProvider;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue