Skip to content

Commit

Permalink
fix(workspaces): rewrite module to fix several small issues
Browse files Browse the repository at this point in the history
Rewrites the module code to be better structured, in a similar pattern to the launcher. The code is now more robust and more maintainable, yay!

Fixes #705

Fixes an issue with moving favourite workspaces.

Fixes an issue with workspace visible state being incorrect.

Fixes an issue where the `inactive` class looked at hidden instead of closed favourites.
  • Loading branch information
JakeStanger committed Dec 28, 2024
1 parent 8cdbe7e commit af32fd1
Show file tree
Hide file tree
Showing 7 changed files with 578 additions and 462 deletions.
16 changes: 6 additions & 10 deletions src/clients/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,25 @@ pub struct Workspace {
pub visibility: Visibility,
}

/// Indicates workspace visibility. Visible workspaces have a boolean flag to indicate if they are also focused.
/// Yes, this is the same signature as Option<bool>, but it's impl is a lot more suited for our case.
/// Indicates workspace visibility.
/// Visible workspaces have a boolean flag to indicate if they are also focused.
#[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
2 changes: 1 addition & 1 deletion src/gtk_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct WidgetGeometry {
pub trait IronbarGtkExt {
/// Adds a new CSS class to the widget.
fn add_class(&self, class: &str);
/// Removes a CSS class to the widget.
/// 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 Down
Loading

0 comments on commit af32fd1

Please sign in to comment.