Skip to content

Commit

Permalink
workspaceOsd.js: destroy and recreate the label on each display
Browse files Browse the repository at this point in the history
This forces the switcher to allocate the proper amount of space for the
workspace name. Fixes and issue with the text getting ellipsized.
  • Loading branch information
JosephMcc committed Sep 23, 2024
1 parent 261612a commit a312d61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/theme/cinnamon-sass/widgets/_osd.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ $ws_dot_inactive: $ws_indicator_height / 6;
@extend %osd_base;
@extend %title_4;

min-width: 140px;
margin-bottom: 4em;
border-radius: 9999px;
font-weight: bold;
Expand Down
21 changes: 18 additions & 3 deletions js/ui/workspaceOsd.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ class WorkspaceOsd extends Clutter.Actor {
});
this.add_child(this._vbox);

this._label = new St.Label();
this._vbox.add_child(this._label);
this._labelBin = new St.Bin();
this._activeWorkspaceName = null;
this._label = null;
this._vbox.add_child(this._labelBin);

this._list = new St.BoxLayout({
style_class: 'workspace-switch-osd-indicator-box',
x_align: Clutter.ActorAlign.CENTER,
});
this._vbox.add_child(this._list);

Expand All @@ -64,6 +67,18 @@ class WorkspaceOsd extends Clutter.Actor {
}

_redisplay() {
if (!this._activeWorkspaceName)
return;

if (this._label !== null)
this._label.destroy();

this._label = new St.Label ({
text: this._activeWorkspaceName,
});

this._labelBin.set_child(this._label);

let workspaceManager = global.workspace_manager;

this._list.destroy_all_children();
Expand All @@ -82,7 +97,7 @@ class WorkspaceOsd extends Clutter.Actor {

display(activeWorkspaceIndex, workspaceName) {
this._activeWorkspaceIndex = activeWorkspaceIndex;
this._label.text = workspaceName;
this._activeWorkspaceName = workspaceName;

this._redisplay();
if (this._timeoutId != 0)
Expand Down

0 comments on commit a312d61

Please sign in to comment.