1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

fix(workspaces): rewrite module to fix several small issues

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.
This commit is contained in:
Jake Stanger 2024-10-19 00:07:49 +01:00
parent 8cdbe7e083
commit fa6f27d4b9
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
7 changed files with 578 additions and 462 deletions

View file

@ -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