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 Oct 22, 2024
1 parent c1e8b26 commit 2cd2d25
Show file tree
Hide file tree
Showing 7 changed files with 561 additions and 436 deletions.
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

0 comments on commit 2cd2d25

Please sign in to comment.