fix(window-title): shrink group to content width instead of always filling max

This commit is contained in:
Damocles 2026-04-17 09:31:55 +02:00
parent 69e3711aec
commit 20159f0514
2 changed files with 10 additions and 2 deletions

View file

@ -146,7 +146,9 @@ PanelWindow {
clip: true clip: true
visible: M.Modules.windowTitle.enable && M.NiriIpc.focusedTitle !== "" visible: M.Modules.windowTitle.enable && M.NiriIpc.focusedTitle !== ""
M.WindowTitle { M.WindowTitle {
width: Math.max(0, centerSection.x - _windowTitleGroup.x - 2 * M.Theme.groupPadding - M.Theme.groupSpacing) id: _windowTitle
readonly property real _maxWidth: Math.max(0, centerSection.x - _windowTitleGroup.x - 2 * M.Theme.groupPadding - M.Theme.groupSpacing)
width: Math.min(implicitWidth, _maxWidth)
} }
} }
Item { Item {

View file

@ -16,6 +16,11 @@ M.BarSection {
return entry ? Quickshell.iconPath(entry.icon) : ""; return entry ? Quickshell.iconPath(entry.icon) : "";
} }
readonly property real _iconOffset: _icon.visible ? _icon.width + root.spacing : 0
// Natural content width Bar.qml uses this to cap the group width
implicitWidth: _iconOffset + _label.implicitWidth
IconImage { IconImage {
id: _icon id: _icon
visible: root._iconSource !== "" visible: root._iconSource !== ""
@ -30,10 +35,11 @@ M.BarSection {
} }
M.BarLabel { M.BarLabel {
id: _label
label: M.NiriIpc.focusedTitle label: M.NiriIpc.focusedTitle
color: root.accentColor color: root.accentColor
elide: Text.ElideRight elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: root.width - (_icon.visible ? _icon.width + root.spacing : 0) width: Math.min(implicitWidth, Math.max(0, root.width - root._iconOffset))
} }
} }