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

Merged
merged 3 commits into from
Dec 28, 2024
Merged
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
16 changes: 8 additions & 8 deletions docs/modules/Workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Shows all current workspaces. Clicking a workspace changes focus to it.

> Type: `workspaces`

| Name | Type | Default | Description |
|----------------|---------------------------------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name_map` | `Map<string, string or image>` | `{}` | A map of actual workspace names to their display labels/images. Workspaces use their actual name if not present in the map. See [here](images) for information on images. |
| `favorites` | `Map<string, string[]>` or `string[]` | `[]` | Workspaces to always show. This can be for all monitors, or a map to set per monitor. |
| `hidden` | `string[]` | `[]` | A list of workspace names to never show |
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
| `all_monitors` | `boolean` | `false` | Whether to display workspaces from all monitors. When `false`, only shows workspaces on the current monitor. |
| `sort` | `'added'` or `'alphanumeric'` | `alphanumeric` | The method used for sorting workspaces. `added` always appends to the end, `alphanumeric` sorts by number/name. |
| Name | Type | Default | Description |
|----------------|---------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name_map` | `Map<string, string or image>` | `{}` | A map of actual workspace names to their display labels/images. Workspaces use their actual name if not present in the map. See [here](images) for information on images. |
| `favorites` | `Map<string, string[]>` or `string[]` | `[]` | Workspaces to always show. This can be for all monitors, or a map to set per monitor. |
| `hidden` | `string[]` | `[]` | A list of workspace names to never show |
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
| `all_monitors` | `boolean` | `false` | Whether to display workspaces from all monitors. When `false`, only shows workspaces on the current monitor. |
| `sort` | `'added'` or `'label'` or `'name'` | `label` | The method used for sorting workspaces. `added` always appends to the end, `label` sorts by displayed value, and `name` sorts by workspace name. |

<details>
<summary>JSON</summary>
Expand Down
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
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
Loading