Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspaces module rewrite #748

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/clients/compositor/hyprland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Client {
{
Self::send_focus_change(&mut prev_workspace, workspace, &tx);
} else {
error!("Unable to locate workspace");
error!("unable to locate workspace: {workspace_name}");
}
});
}
Expand Down Expand Up @@ -154,6 +154,7 @@ impl Client {

event_listener.add_workspace_rename_handler(move |data| {
let _lock = lock!(lock);
debug!("Received workspace rename: {data:?}");

send!(
tx,
Expand Down
12 changes: 4 additions & 8 deletions src/clients/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,21 @@ pub struct Workspace {
/// Yes, this is the same signature as Option<bool>, but it's impl is a lot more suited for our case.
#[derive(Debug, Copy, Clone)]
pub enum Visibility {
Visible(bool),
Visible { focused: bool },
Hidden,
}

impl Visibility {
pub fn visible() -> Self {
Self::Visible(false)
Self::Visible { focused: false }
}

pub fn focused() -> Self {
Self::Visible(true)
}

pub fn is_visible(self) -> bool {
matches!(self, Self::Visible(_))
Self::Visible { focused: true }
}

pub fn is_focused(self) -> bool {
if let Self::Visible(focused) = self {
if let Self::Visible { focused } = self {
focused
} else {
false
Expand Down
7 changes: 7 additions & 0 deletions src/gtk_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub struct WidgetGeometry {
pub trait IronbarGtkExt {
/// Adds a new CSS class to the widget.
fn add_class(&self, class: &str);

/// Removes a CSS class from the widget
fn remove_class(&self, class: &str);
/// Gets the geometry for the widget
fn geometry(&self, orientation: Orientation) -> WidgetGeometry;

Expand All @@ -32,6 +35,10 @@ impl<W: IsA<Widget>> IronbarGtkExt for W {
self.style_context().add_class(class);
}

fn remove_class(&self, class: &str) {
self.style_context().remove_class(class);
}

fn geometry(&self, orientation: Orientation) -> WidgetGeometry {
let allocation = self.allocation();

Expand Down
Loading
Loading