3434
3535TaskbarWidget::TaskbarWidget (CompositorPlatform& platform, wl_output* output, bool groupByWorkspace,
3636 bool showAllOutputs, bool onlyActiveWorkspace, bool showWorkspaceLabel,
37- bool hideEmptyWorkspaces, std::string barPosition, ShellConfig::ShadowConfig shadowConfig)
37+ bool hideEmptyWorkspaces, bool showWindowTitle, float windowTitleLength,
38+ std::string barPosition, ShellConfig::ShadowConfig shadowConfig)
3839 : m_platform(platform), m_output(output), m_groupByWorkspace(groupByWorkspace), m_showAllOutputs(showAllOutputs),
3940 m_onlyActiveWorkspace(onlyActiveWorkspace), m_showWorkspaceLabel(showWorkspaceLabel),
40- m_hideEmptyWorkspaces(hideEmptyWorkspaces), m_barPosition(std::move(barPosition)),
41+ m_hideEmptyWorkspaces(hideEmptyWorkspaces), m_showWindowTitle(showWindowTitle),
42+ m_windowTitleLength(windowTitleLength), m_barPosition(std::move(barPosition)),
4143 m_shadowConfig(std::move(shadowConfig)) {
4244 buildDesktopIconIndex ();
4345}
@@ -144,7 +146,8 @@ void TaskbarWidget::buildTaskButtons(Renderer& renderer) {
144146 }
145147 const float iconSize = Style::barGlyphSize * m_contentScale;
146148 const float tilePadding = Style::spaceXs * 0 .35f * m_contentScale;
147- const float tileSize = iconSize + tilePadding * 2 .0f ;
149+ const float tileHeight = iconSize + tilePadding * 2 .0f ;
150+ const float tileWidth = tileHeight + (m_showWindowTitle ? m_windowTitleLength * m_contentScale + tilePadding : 0 .0f );
148151 const auto workspaceAxisHandler = [this ](const InputArea::PointerData& data) -> bool {
149152 if (!m_groupByWorkspace) {
150153 return false ;
@@ -169,7 +172,7 @@ void TaskbarWidget::buildTaskButtons(Renderer& renderer) {
169172 };
170173 auto createTaskTile = [&](const TaskModel& task) {
171174 auto area = std::make_unique<InputArea>();
172- area->setFrameSize (tileSize, tileSize );
175+ area->setFrameSize (tileWidth, tileHeight );
173176 area->setAcceptedButtons (InputArea::buttonMask ({BTN_LEFT , BTN_RIGHT }));
174177 area->setOnAxisHandler (workspaceAxisHandler);
175178
@@ -213,25 +216,41 @@ void TaskbarWidget::buildTaskButtons(Renderer& renderer) {
213216 auto image = std::make_unique<Image>();
214217 image->setFit (ImageFit::Contain);
215218 image->setSize (iconSize, iconSize);
216- image->setPosition (std::round ((tileSize - iconSize) * 0 .5f ), std::round ((tileSize - iconSize) * 0 .5f ));
219+ image->setPosition (std::round ((tileHeight - iconSize) * 0 .5f ), std::round ((tileHeight - iconSize) * 0 .5f ));
217220 image->setSourceFile (renderer, task.iconPath , static_cast <int >(std::round (48 .0f * m_contentScale)), true );
218221 area->addChild (std::move (image));
219222 } else {
220223 auto glyph = std::make_unique<Glyph>();
221224 glyph->setGlyph (" apps" );
222225 glyph->setGlyphSize (iconSize);
223- glyph->setPosition (std::round ((tileSize - iconSize) * 0 .5f ), std::round ((tileSize - iconSize) * 0 .5f ));
226+ glyph->setPosition (std::round ((tileHeight - iconSize) * 0 .5f ), std::round ((tileHeight - iconSize) * 0 .5f ));
224227 area->addChild (std::move (glyph));
225228 }
226229
230+ if (m_showWindowTitle) {
231+ auto label = std::make_unique<Label>();
232+ label->setText (task.title );
233+ label->setFontSize (Style::fontSizeCaption * m_contentScale);
234+ label->setMaxWidth (m_windowTitleLength * m_contentScale);
235+ label->setPosition (std::round (tileHeight + tilePadding), 0 );
236+ area->addChild (std::move (label));
237+ }
238+
227239 if (task.active ) {
228240 const float d = std::max (4 .0f , std::round (Style::barGlyphSize * 0 .32f * m_contentScale));
229241 const float bottomInset = 0 .25f * m_contentScale;
230242 auto indicator = std::make_unique<Box>();
231243 indicator->setFill (colorSpecFromRole (ColorRole::Primary));
232- indicator->setRadius (d * 0 .5f );
233- indicator->setFrameSize (d, d);
234- indicator->setPosition (std::round ((tileSize - d) * 0 .5f ), std::round (tileSize - d - bottomInset));
244+ if (m_showWindowTitle) {
245+ const float lineThickness = d * 0 .5f ;
246+ indicator->setRadius (lineThickness * 0 .5f );
247+ indicator->setSize (tileWidth - tilePadding * 2 , lineThickness);
248+ indicator->setPosition (tilePadding, std::round (tileHeight));
249+ } else {
250+ indicator->setRadius (d * 0 .5f );
251+ indicator->setFrameSize (d, d);
252+ indicator->setPosition (std::round ((tileHeight - d) * 0 .5f ), std::round (tileHeight - d - bottomInset));
253+ }
235254 area->addChild (std::move (indicator));
236255 }
237256 return area;
@@ -289,11 +308,11 @@ void TaskbarWidget::buildTaskButtons(Renderer& renderer) {
289308 }
290309 const float taskCount = std::max (1 .0f , static_cast <float >(tasks.size ()));
291310 const float gapCount = tasks.empty () ? 0 .0f : (taskCount - 1 .0f );
292- const float runLength = (tileSize * taskCount) + (groupGap * gapCount);
293- const float groupWidth = m_vertical ? std::round (tileSize + (groupPadCross * 2 .0f ))
311+ const float runLength = (tileWidth * taskCount) + (groupGap * gapCount);
312+ const float groupWidth = m_vertical ? std::round (tileWidth + (groupPadCross * 2 .0f ))
294313 : std::round (groupPadStart + groupPadEnd + runLength);
295314 const float groupHeight = m_vertical ? std::round (groupPadStart + groupPadEnd + runLength)
296- : std::round (tileSize + (groupPadCross * 2 .0f ));
315+ : std::round (tileHeight + (groupPadCross * 2 .0f ));
297316
298317 auto group = std::make_unique<Box>();
299318 group->setFrameSize (groupWidth, groupHeight);
@@ -319,7 +338,7 @@ void TaskbarWidget::buildTaskButtons(Renderer& renderer) {
319338 }
320339
321340 for (std::size_t i = 0 ; i < tasks.size (); ++i) {
322- const float tileOffset = (tileSize + groupGap) * static_cast <float >(i);
341+ const float tileOffset = (tileWidth + groupGap) * static_cast <float >(i);
323342 auto tile = createTaskTile (*tasks[i]);
324343 if (m_vertical) {
325344 tile->setPosition (std::round (groupPadCross), std::round (groupPadStart + tileOffset));
0 commit comments