Skip to content

Commit df55cdf

Browse files
authored
Merge pull request #748 from JakeStanger/fix/workspaces
Workspaces module rewrite
2 parents 42e18da + 03136e7 commit df55cdf

File tree

9 files changed

+611
-471
lines changed

9 files changed

+611
-471
lines changed

Diff for: docs/modules/Workspaces.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Shows all current workspaces. Clicking a workspace changes focus to it.
88

99
> Type: `workspaces`
1010
11-
| Name | Type | Default | Description |
12-
|----------------|---------------------------------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
13-
| `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. |
14-
| `favorites` | `Map<string, string[]>` or `string[]` | `[]` | Workspaces to always show. This can be for all monitors, or a map to set per monitor. |
15-
| `hidden` | `string[]` | `[]` | A list of workspace names to never show |
16-
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
17-
| `all_monitors` | `boolean` | `false` | Whether to display workspaces from all monitors. When `false`, only shows workspaces on the current monitor. |
18-
| `sort` | `'added'` or `'alphanumeric'` | `alphanumeric` | The method used for sorting workspaces. `added` always appends to the end, `alphanumeric` sorts by number/name. |
11+
| Name | Type | Default | Description |
12+
|----------------|---------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
13+
| `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. |
14+
| `favorites` | `Map<string, string[]>` or `string[]` | `[]` | Workspaces to always show. This can be for all monitors, or a map to set per monitor. |
15+
| `hidden` | `string[]` | `[]` | A list of workspace names to never show |
16+
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
17+
| `all_monitors` | `boolean` | `false` | Whether to display workspaces from all monitors. When `false`, only shows workspaces on the current monitor. |
18+
| `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. |
1919

2020
<details>
2121
<summary>JSON</summary>

Diff for: src/clients/compositor/hyprland.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Client {
119119
{
120120
Self::send_focus_change(&mut prev_workspace, workspace, &tx);
121121
} else {
122-
error!("Unable to locate workspace");
122+
error!("unable to locate workspace: {workspace_name}");
123123
}
124124
});
125125
}
@@ -154,6 +154,7 @@ impl Client {
154154

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

158159
send!(
159160
tx,

Diff for: src/clients/compositor/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,25 @@ pub struct Workspace {
8686
pub visibility: Visibility,
8787
}
8888

89-
/// Indicates workspace visibility. Visible workspaces have a boolean flag to indicate if they are also focused.
90-
/// Yes, this is the same signature as Option<bool>, but it's impl is a lot more suited for our case.
89+
/// Indicates workspace visibility.
90+
/// Visible workspaces have a boolean flag to indicate if they are also focused.
9191
#[derive(Debug, Copy, Clone)]
9292
pub enum Visibility {
93-
Visible(bool),
93+
Visible { focused: bool },
9494
Hidden,
9595
}
9696

9797
impl Visibility {
9898
pub fn visible() -> Self {
99-
Self::Visible(false)
99+
Self::Visible { focused: false }
100100
}
101101

102102
pub fn focused() -> Self {
103-
Self::Visible(true)
104-
}
105-
106-
pub fn is_visible(self) -> bool {
107-
matches!(self, Self::Visible(_))
103+
Self::Visible { focused: true }
108104
}
109105

110106
pub fn is_focused(self) -> bool {
111-
if let Self::Visible(focused) = self {
107+
if let Self::Visible { focused } = self {
112108
focused
113109
} else {
114110
false

Diff for: src/gtk_helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct WidgetGeometry {
2020
pub trait IronbarGtkExt {
2121
/// Adds a new CSS class to the widget.
2222
fn add_class(&self, class: &str);
23-
/// Removes a CSS class to the widget.
23+
/// Removes a CSS class from the widget
2424
fn remove_class(&self, class: &str);
2525
/// Gets the geometry for the widget
2626
fn geometry(&self, orientation: Orientation) -> WidgetGeometry;

0 commit comments

Comments
 (0)