Skip to content
Open
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
4 changes: 4 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,10 @@
"description": "Show the widget glyph or custom image",
"label": "Show Glyph"
},
"show-icons": {
"description": "Show the focused app icon on the active pill",
"label": "Show Icons"
},
"show-label": {
"description": "Show the widget's text label",
"label": "Show Label"
Expand Down
20 changes: 10 additions & 10 deletions src/shell/bar/widgets/workspaces_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ WorkspacesWidget::WorkspacesWidget(
)
: m_platform(platform), m_configService(config), m_output(output), m_labelSource(options.labelSource),
m_showLabels(options.showLabels), m_maxLabelChars(options.maxLabelChars),
m_labelsOnlyWhenOccupied(options.labelsOnlyWhenOccupied), m_hideWhenEmpty(options.hideWhenEmpty),
m_showAllOutputs(options.showAllOutputs), m_pillScale(options.pillScale),
m_labelsOnlyWhenOccupied(options.labelsOnlyWhenOccupied), m_showIcons(options.showIcons),
m_hideWhenEmpty(options.hideWhenEmpty), m_showAllOutputs(options.showAllOutputs), m_pillScale(options.pillScale),
m_activePillSize(std::clamp(options.activePillSize, 0.25F, 8.0F)),
m_inactivePillSize(std::clamp(options.inactivePillSize, 0.25F, 8.0F)), m_style(options.style),
m_focusedOutputOnly(options.focusedOutputOnly), m_changeColorOnHover(options.changeColorOnHover),
Expand Down Expand Up @@ -188,7 +188,7 @@ bool WorkspacesWidget::releaseHeldVisualStyles() {
}

void WorkspacesWidget::doUpdate(Renderer& renderer) {
if (m_iconColorizeRefreshPending && isFocusHint()) {
if (m_iconColorizeRefreshPending && isFocusHint() && m_showIcons) {
for (auto& item : m_items) {
syncActiveWindowIcon(renderer, item);
}
Expand Down Expand Up @@ -268,7 +268,7 @@ void WorkspacesWidget::doUpdate(Renderer& renderer) {
bool structuralChange = current.size() != m_cachedState.size();
bool activeChange = false;
bool hideWhenEmptyTransition = false;
if (isFocusHint()) {
if (isFocusHint() && m_showIcons) {
const auto desktopVersion = desktopEntriesVersion();
if (desktopVersion != m_desktopEntriesVersion) {
buildDesktopIconIndex();
Expand Down Expand Up @@ -510,7 +510,7 @@ void WorkspacesWidget::rebuild(Renderer& renderer) {

if (isFocusHint()) {
const float dotSize = focusedPillDotSize();
const bool hasIcon = entry.workspace.active && !activeWindowAppId().empty();
const bool hasIcon = m_showIcons && entry.workspace.active && !activeWindowAppId().empty();
if (!entry.workspace.active) {
slot.inactiveWidth = dotSize;
slot.activeWidth = dotSize;
Expand Down Expand Up @@ -599,7 +599,7 @@ void WorkspacesWidget::rebuild(Renderer& renderer) {
item.text->measure(renderer);
}

if (isFocusHint() && ws.active) {
if (isFocusHint() && m_showIcons && ws.active) {
item.showIcon = true;
item.icon = static_cast<Image*>(area->addChild(
ui::image({
Expand Down Expand Up @@ -879,7 +879,7 @@ void WorkspacesWidget::recalculateItemMetrics(
}
} else if (isFocusHint()) {
const float dotSize = focusedPillDotSize();
const bool hasIcon = workspace.active && !activeWindowAppId().empty();
const bool hasIcon = m_showIcons && workspace.active && !activeWindowAppId().empty();
if (!workspace.active) {
item.inactiveWidth = dotSize;
item.activeWidth = dotSize;
Expand All @@ -902,7 +902,7 @@ void WorkspacesWidget::recalculateItemMetrics(
}

ensureItemLabel(renderer, item, workspace);
if (isFocusHint() && workspace.active && item.icon == nullptr && item.area != nullptr) {
if (isFocusHint() && m_showIcons && workspace.active && item.icon == nullptr && item.area != nullptr) {
item.showIcon = true;
item.icon = static_cast<Image*>(item.area->addChild(
ui::image({
Expand Down Expand Up @@ -1145,7 +1145,7 @@ void WorkspacesWidget::applyItemLayout(Item& it) {
&& it.currentWidth + 0.5F >= it.inactiveWidth
&& (!isFocusHint() || it.workspace.active);
const bool showIcon =
isFocusHint() && it.workspace.active && it.showIcon && it.icon != nullptr && it.icon->hasImage();
isFocusHint() && m_showIcons && it.workspace.active && it.showIcon && it.icon != nullptr && it.icon->hasImage();
if (it.text != nullptr) {
it.text->setVisible(showText);
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ std::string WorkspacesWidget::resolveIconPath(const std::string& appId) {
}

void WorkspacesWidget::syncActiveWindowIcon(Renderer& renderer, Item& item) {
if (!isFocusHint() || item.icon == nullptr) {
if (!isFocusHint() || !m_showIcons || item.icon == nullptr) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/shell/bar/widgets/workspaces_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class WorkspacesWidget : public Widget {
WorkspacesStyle style = WorkspacesStyle::Regular;
WorkspacesLabelSource labelSource = WorkspacesLabelSource::Id;
bool showLabels = true;
bool showIcons = true;
ColorSpec focusedColor = colorSpecFromRole(ColorRole::Primary);
ColorSpec occupiedColor = colorSpecFromRole(ColorRole::Secondary);
ColorSpec emptyColor = colorSpecFromRole(ColorRole::Secondary);
Expand Down Expand Up @@ -160,6 +161,7 @@ class WorkspacesWidget : public Widget {
bool m_showLabels = true;
std::size_t m_maxLabelChars = 1;
bool m_labelsOnlyWhenOccupied = false;
bool m_showIcons = true;
bool m_hideWhenEmpty = false;
bool m_showAllOutputs = false;
float m_pillScale = 1.0F;
Expand Down
14 changes: 14 additions & 0 deletions src/shell/bar/widgets/workspaces_widget_definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ namespace {
return visibility;
}

settings::WidgetSettingVisibility focusHintStyleOnly() {
settings::WidgetSettingVisibility visibility;
visibility.all = {{"style", {"focus_hint"}}};
return visibility;
}

} // namespace

const noctalia::bar::WidgetDefinition<WorkspacesWidget::Options>& workspacesWidgetDefinition() {
Expand Down Expand Up @@ -102,6 +108,14 @@ const noctalia::bar::WidgetDefinition<WorkspacesWidget::Options>& workspacesWidg
.visibleWhen = labelsShown(),
},
}),
field<&Options::showIcons>({
.key = "show_icons",
.presentation =
settings::WidgetSettingPresentation{
.group = "workspaces.list",
.visibleWhen = focusHintStyleOnly(),
},
}),
field<&Options::style>({
.key = "style",
.choices =
Expand Down